Viewing File: /usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyc

ó
oBú]c@sÁdZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZm
Z
d„Zdd„Zed„Zd„Zd	„Zed
kr½eƒndS(sEDefine 'clean' utility and handler as part of cloud-init commandline.iÿÿÿÿN(tInit(tProcessExecutionErrortdel_dirtdel_filetget_config_logfilestis_linktsubpcCstjjd|dƒdS(NsERROR: s
(tsyststderrtwrite(tmsg((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyterrorscCs—|s!tjddddƒ}n|jddddd	td
ddd
ƒ|jddddd	tddƒ|jddddd	td
dddƒ|S(s#Build or extend an arg parser for clean utility.

    @param parser: Optional existing ArgumentParser instance representing the
        clean subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    tprogtcleantdescriptionsARemove logs and artifacts so cloud-init re-runs on a clean systems-ls--logstactiont
store_truetdefaulttdesttremove_logsthelpsRemove cloud-init logs.s-rs--reboots;Reboot system after logs are cleaned so cloud-init re-runs.s-ss--seedtremove_seeds5Remove cloud-init seed directory /var/lib/cloud/seed.(targparsetArgumentParsertadd_argumenttFalse(tparser((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyt
get_parsers		cCs+tdgƒ}|jƒ|rFx$t|jƒD]}t|ƒq/Wntjj|jj	ƒsbdStjj
|jj	dƒ}x§tjd|jj	ƒD]Œ}||kr¶|r¶q—ny:tjj|ƒråt|ƒråt
|ƒn
t|ƒWq—tk
r"}tdj|t|ƒƒƒdSXq—WdS(s4Helper which removes artifacts dir and optionally log files.

    @param: remove_logs: Boolean. Set True to delete the cloud_dir path. False
        preserves them.
    @param: remove_seed: Boolean. Set True to also delete seed subdir in
        paths.cloud_dir.
    @returns: 0 on success, 1 otherwise.
    tds_depsitseeds%s/*sCould not remove {0}: {1}i(Rtread_cfgRtcfgRtostpathtisdirtpathst	cloud_dirtjointglobRRtOSErrorRtformattstr(RRtinittlog_filet	seed_pathR!te((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pytremove_artifacts0s&	
 
	cCsŒt|j|jƒ}|dkrˆ|jrˆdddg}yt|dtƒWqˆtk
r„}tdj|t	|ƒƒƒd}qˆXn|S(s3Handle calls to 'cloud-init clean' as a subcommand.itshutdowns-rtnowtcaptures-Could not reboot this system using "{0}": {1}i(
R.RRtrebootRRRRR(R)(tnametargst	exit_codetcmdR-((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pythandle_clean_argsPs
cCs)tƒ}tjtd|jƒƒƒdS(s4Tool to collect and tar all cloud-init related logs.R
N(RRtexitR7t
parse_args(R((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pytmain_s	t__main__(t__doc__RR&R Rtcloudinit.stagesRtcloudinit.utilRRRRRRRtNoneRRR.R7R:t__name__(((s7/usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyt<module>s.	 		
Back to Directory File Manager