Current File : //usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyo |
�
oB�]c @ s� d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z m
Z
m Z m Z m
Z
d � Z d d � Z e d � Z d � Z d � Z e d
k r� e � n d S( sE Define 'clean' utility and handler as part of cloud-init commandline.i����N( t Init( t ProcessExecutionErrort del_dirt del_filet get_config_logfilest is_linkt subpc C s t j j d | d � d S( Ns ERROR: s
( t syst stderrt write( t msg( ( s7 /usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyt error s c C s� | s! t j d d d d � } n | j d d d d d t d
d d d
�| j d d d d d t d d �| j d d d d d t d
d d 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.
t progt cleant descriptionsA Remove logs and artifacts so cloud-init re-runs on a clean systems -ls --logst actiont
store_truet defaultt destt remove_logst helps Remove cloud-init logs.s -rs --reboots; Reboot system after logs are cleaned so cloud-init re-runs.s -ss --seedt remove_seeds5 Remove cloud-init seed directory /var/lib/cloud/seed.( t argparset ArgumentParsert add_argumentt False( t parser( ( s7 /usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyt
get_parser s c C s+ t d g � } | j � | rF x$ t | j � D] } t | � q/ Wn t j j | j j � sb d St j j
| j j d � } x� t j d | j j � D]� } | | k r� | r� q� n y: t j j | � r� t | � r� t
| � n
t | � Wq� t k
r"} t d j | t | � � � d SXq� Wd S( s4 Helper 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.
t ds_depsi t seeds %s/*s Could not remove {0}: {1}i ( R t read_cfgR t cfgR t ost patht isdirt pathst cloud_dirt joint globR R t OSErrorR t formatt str( R R t initt log_filet seed_pathR! t e( ( s7 /usr/lib/python2.7/site-packages/cloudinit/cmd/clean.pyt remove_artifacts0 s&