/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__
NameSizeModeActions
clean.cpython-310.pyc54630644editdlrm
cloud_id.cpython-310.pyc30980644editdlrm
main.cpython-310.pyc297020644editdlrm
query.cpython-310.pyc78400644editdlrm
status.cpython-310.pyc133880644editdlrm
__init__.cpython-310.pyc1490644editdlrm
Edit: /usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-310.pyc (5463B)
o th@sdZddlZddlZddlZddlZddlZddlmZmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZmZmZdd lmZmZmZmZmZeeZd Z ed d dddgZ!dgZ"dddZ#dddZ$ddZ%ddZ&edkre&dSdS)zFDefine 'clean' utility and handler as part of cloud-init command line.N)settingssources) cc_mounts) uses_systemd)log_util)CLOUDINIT_NETPLAN_FILE)Init)ProcessExecutionErrorrunpartssubp)del_dirdel_fileget_config_logfilesis_link write_filez/etc/machine-idz-/etc/NetworkManager/conf.d/99-cloud-init.confz?/etc/NetworkManager/conf.d/30-cloud-init-ip6-addr-gen-mode.confz@/etc/NetworkManager/system-connections/cloud-init-*.nmconnectionz,/etc/systemd/network/10-cloud-init-*.networkz+/etc/network/interfaces.d/50-cloud-init.cfgz)/etc/ssh/sshd_config.d/50-cloud-init.confc Cs|s tjddd}|jdddddd d |jd ddd d |jdddddd |jddddddd |jddgdgdddd|S)a#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. cleanzJRemove logs, configs and artifacts so cloud-init re-runs on a clean system)prog descriptionz-lz--logs store_trueF remove_logszRemove cloud-init logs.)actiondefaultdesthelpz --machine-idzSet /etc/machine-id to 'uninitialized ' for golden imagecreation. On next boot, systemd generates a new machine-id. Remove /etc/machine-id on non-systemd environments.)rrrz-rz--rebootz;Reboot system after logs are cleaned so cloud-init re-runs.z-sz--seed remove_seedz5Remove cloud-init seed directory /var/lib/cloud/seed.z-cz --configs)all ssh_confignetwork datasourcefstab+ remove_configzbRemove cloud-init generated config files of a certain type. Config types: all, ssh_config, network)choicesrnargsrr)argparseArgumentParser add_argumentparserr)5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py get_parser-sX  r+Fc Cs ||rt|jD]}t|q |r.t|ddgr.tD]}t|D]}t|q&q|rBt|ddgrBtD]}t|q;|rQt|ddgrQt |o[t|ddg}t j |jjsotjdttjddS|rz|Wntjytjd ttjdYnwt j |jjd }td |jjD]=}||kr|sqzt j |rt|st|nt|Wqty} ztd |t| WYd } ~ dSd } ~ wwzt t!j"WdSt#y} ztdt!j"d| WYd } ~ dSd } ~ ww)aHelper which removes artifacts dir and optionally log files. @param: init: Init object to use @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. @param: remove_config: List of strings. Can be any of: all, network, ssh_config, datasource, fstab. @returns: 0 on success, 1 otherwise. rrrrrzArtifacts already cleaned.)log log_levelrz%No datasource found, nothing cleaned.seedz%s/*zCould not remove {0}: {1}NzFailure during run-parts of z: )$read_cfgrcfgr set intersectionGEN_NET_CONFIG_FILESglobGEN_SSH_CONFIG_FILESr cleanup_fstabospathisdirpaths cloud_dirr multi_logLOGloggingINFOfetchrrDataSourceNotFoundExceptionjoinrr OSErrorerrorformatstrr rCLEAN_RUNPARTS_DIR Exception) initrrr!log_filer9confclean_datasource seed_pather)r)r*remove_artifactsrsx          rPc Cstgd}t||j|j|j}|jr!trttdddnt t|dkr[|j r[|j j dddd }z t |d d W|StyZ}ztd |t|d }WYd}~|Sd}~ww|S)z3Handle calls to 'cloud-init clean' as a subcommand.)ds_depszuninitialized i$)moderrebootnowN)rRdelaymessageF)capturez-Could not reboot this system using "{0}": {1}r/)rrPrrr! machine_idrrETC_MACHINE_IDr rSdistroshutdown_commandr r rrErFrG)nameargsrJ exit_codecmdrOr)r)r*handle_clean_argss4 r`cCst}ttd|dS)z4Tool to collect and tar all cloud-init related logs.rN)r+sysexitr` parse_argsr'r)r)r*mainsrd__main__)N)FN)'__doc__r$r5r?r8ra cloudinitrrcloudinit.configrcloudinit.distrosr cloudinit.logrcloudinit.net.netplanrcloudinit.stagesrcloudinit.subpr r r cloudinit.utilr r rrr getLogger__name__r>rYr4r6r+rPr`rdr)r)r)r*s@         EH