403Webshell
Server IP : 167.99.254.82  /  Your IP : 216.73.217.78
Web Server : Apache
System : Linux host.techisquad.com 5.15.0-187-generic #197-Ubuntu SMP Fri Jul 17 19:17:01 UTC 2026 x86_64
User : pawluxera ( 1011)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/767809/root/lib/python3/dist-packages/cloudinit/cmd/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/767809/root/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-310.pyc
o

��i��@s dZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZmZmZdd
lmZmZmZmZmZe�e�Z dZ!edd
dddgZ"dgZ#de$de%fdd�Z&d dd�Z'd!dd�Z(dd�Z)dd�Z*edkr�e*�dSdS)"zFDefine 'clean' utility and handler as part of cloud-init command line.�N)�settings�sources)�	cc_mounts)�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.conf�log_file�returncCsDzt�|�}t�|j�st�|j�rWdSWdSty!YdSw)z�Check if a log file should be removed.

    Avoid tracebacks from attempting to remove device files.

    @param log_file: Path to the log file to check.
    @returns: True if the file should be removed, False otherwise.
    FT)�os�stat�S_ISBLK�st_mode�S_ISCHR�OSError)r�	file_stat�r�5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�should_remove_log_file.s
���rc	Cs�|s	tjddd�}|jdddddd	d
�|jddddd
�|jdddddd
�|jddddddd
�|jddgd�gdddd�|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.)�action�default�dest�helpz--machine-idz�Set /etc/machine-id to 'uninitialized\n' for golden image creation. On next boot, systemd generates a new machine-id. Remove /etc/machine-id on non-systemd environments.)r"r#r%z-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�
datasource�fstab�+�
remove_configzbRemove cloud-init generated config files of a certain type. Config types: all, ssh_config, network)�choicesr#�nargsr$r%)�argparse�ArgumentParser�add_argument��parserrrr�
get_parser?sX	���
���r5Fc
Cs|��|rt|j�D]
}t|�rt|�q|r2t|��ddg�r2tD]}t�|�D]}t|�q*q#|rFt|��ddg�rFt	D]}t|�q?|rUt|��ddg�rUt
��|o_t|��ddg�}tj
�|jj�sstjdttjd�dS|r�z|����Wntjy�tjd	ttjd�Ynwtj
�|jjd
�}t�d|jj�D]=}||kr�|s�q�ztj
�|�r�t|�s�t|�nt|�Wq�ty�}	zt�d�|t |	���WYd
}	~	dSd
}	~	wwzt!t"j#�WdSt$�y	}	zt�dt"j#�d|	���WYd
}	~	dSd
}	~	ww)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, datasource, fstab.
    @returns: 0 on success, 1 otherwise.
    r'r)r(r+r*zArtifacts already cleaned.)�log�	log_levelrz%No datasource found, nothing cleaned.�seedz%s/*zCould not remove {0}: {1}N�zFailure during run-parts of z: )%�read_cfgr�cfgrr
�set�intersection�GEN_NET_CONFIG_FILES�glob�GEN_SSH_CONFIG_FILESr�
cleanup_fstabr�path�isdir�paths�	cloud_dirr�	multi_log�LOG�logging�INFO�fetchrr�DataSourceNotFoundException�joinrrr�error�format�strr
r�CLEAN_RUNPARTS_DIR�	Exception)
�initr!r&r-rrB�conf�clean_datasource�	seed_path�errr�remove_artifacts�s|�
��
��
��
�������rWc
Cs�tgd�}t||j|j|j�}|jr!t�rttddd�nt	t�|dkr[|j
r[|jjdddd	�}z	t
|d
d�W|StyZ}zt�d�|t|���d
}WYd}~|Sd}~ww|S)z3Handle calls to 'cloud-init clean' as a subcommand.)�ds_depszuninitialized
i$)�moder�reboot�nowN)rY�delay�messageF)�capturez-Could not reboot this system using "{0}": {1}r9)rrWr!r&r-�
machine_idrr�ETC_MACHINE_IDr
rZ�distro�shutdown_commandrr	rrMrNrO)�name�argsrR�	exit_code�cmdrVrrr�handle_clean_args�s4
�������rgcCst�}t�td|����dS)z4Tool to collect and tar all cloud-init related logs.rN)r5�sys�exitrg�
parse_argsr3rrr�main�srk�__main__)N)FN)+�__doc__r0r?rHrrrh�	cloudinitrr�cloudinit.configr�cloudinit.distrosr�
cloudinit.logr�cloudinit.net.netplanr�cloudinit.stagesr�cloudinit.subpr	r
r�cloudinit.utilrr
rrr�	getLogger�__name__rGr`r>r@rO�boolrr5rWrgrkrrrr�<module>sD
�	�

EI
�

Youez - 2016 - github.com/yon3zu
LinuXploit