%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2599/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2599/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-38.pyc

U

Ӈg��@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZmZmZdd	lmZmZmZmZmZd
Zeddd
ddgZdgZddd�Zddd�Zdd�Zdd�Ze dkr�e�dS)zFDefine 'clean' utility and handler as part of cloud-init command line.�N)�settings)�uses_systemd)�log_util)�CLOUDINIT_NETPLAN_FILE)�Init)�ProcessExecutionError�runparts�subp)�del_dir�del_file�get_config_logfiles�is_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�|stjddd�}|jdddddd	d
�|jddddd
�|jdddddd
�|jddddddd
�|jdddddggdddd�|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)�progZdescriptionz-lz--logs�
store_trueF�remove_logszRemove cloud-init logs.)�action�default�dest�helpz--machine-idz�Set /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_config�network�+�
remove_configzbRemove cloud-init generated config files of a certain type. Config types: all, ssh_config, network)�choicesr�nargsrr)�argparse�ArgumentParser�add_argument��parser�r$�5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�
get_parser*s^	���
����r&Fc	Cs�|��|r$t|j�D]}t|�q|r\t|��ddg�r\tD]}t�|�D]}t|�qLq>|r�t|��ddg�r�tD]}t|�qvt	j
�|jj
�s�dSt	j
�|jj
d�}t�d|jj
�D]�}||kr�|s�q�z*t	j
�|�r�t|�s�t|�nt|�Wq�tk
�r:}z"t�d�|t|���WY�dSd	}~XYq�Xq�zttj�WnBtk
�r�}z"t�d
tj�d|���WY�dSd	}~XYnXdS)a�Helper 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.
    @returns: 0 on success, 1 otherwise.
    rrrrZseedz%s/*zCould not remove {0}: {1}�NzFailure during run-parts of z: )Zread_cfgrZcfgr�set�intersection�GEN_NET_CONFIG_FILES�glob�GEN_SSH_CONFIG_FILES�os�path�isdir�pathsZ	cloud_dir�joinr
r
�OSErrorr�error�format�strrrZCLEAN_RUNPARTS_DIR�	Exception)	�initrrrZlog_filer.ZconfZ	seed_path�er$r$r%�remove_artifactsmsD
�

�r9c
Cs�tgd�}t||j|j|j�}|jrBt�r:ttddd�nt	t�|dkr�|j
r�|jjdddd	�}zt
|d
d�Wn<tk
r�}zt�d�|t|���d
}W5d}~XYnX|S)z3Handle calls to 'cloud-init clean' as a subcommand.)Zds_depszuninitialized
i$)�moder�rebootZnowN)r:Zdelay�messageF)Zcapturez-Could not reboot this system using "{0}": {1}r')rr9rrrZ
machine_idrr�ETC_MACHINE_IDrr;ZdistroZshutdown_commandr	rrr3r4r5)�name�argsr7Z	exit_code�cmdr8r$r$r%�handle_clean_args�s8
����rAcCst�}t�td|����dS)z4Tool to collect and tar all cloud-init related logs.rN)r&�sys�exitrA�
parse_argsr"r$r$r%�main�srE�__main__)N)FN)!�__doc__rr+r-rBZ	cloudinitrZcloudinit.distrosrZ
cloudinit.logrZcloudinit.net.netplanrZcloudinit.stagesrZcloudinit.subprrr	Zcloudinit.utilr
rrr
rr=r*r,r&r9rArE�__name__r$r$r$r%�<module>s6�	�
C
2

Zerion Mini Shell 1.0