| Server IP : 3.96.16.70 / Your IP : 216.73.216.15 Web Server : Apache System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3.9/site-packages/cloudinit/cmd/__pycache__/ |
Upload File : |
a
�½b�
� @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZm Z ddl
mZmZm
Z
mZmZ ddd�Zdd d
�Zdd� Zd
d� Zedkr�e� dS )zEDefine 'clean' utility and handler as part of cloud-init commandline.� N)�Init)�ProcessExecutionError�subp)�del_dir�del_file�error�get_config_logfiles�is_linkc C sV | st jddd�} | jdddddd d
� | jddddd
d� | jddddddd
� | 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.
�cleanzARemove logs 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�help�-rz--rebootz;Reboot system after logs are cleaned so cloud-init re-runs.)r r r z-sz--seed�remove_seedz5Remove cloud-init seed directory /var/lib/cloud/seed.)�argparse�ArgumentParser�add_argument��parser� r �7/usr/lib/python3.9/site-packages/cloudinit/cmd/clean.py�
get_parser s: ����r Fc C s� t g d�}|�� | r.t|j�D ]}t|� q tj�|jj �sBdS tj�
|jj d�}t�d|jj �D ]z}||krx|sxqfz*tj�|�r�t|�s�t
|� nt|� W qf ty� } z$td�|t|��� W Y d}~ dS d}~0 0 qfdS )a4 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.
)Zds_depsr Zseedz%s/*zCould not remove {0}: {1}N� )r Zread_cfgr Zcfgr �os�path�isdir�pathsZ cloud_dir�join�globr r �OSErrorr �format�str)r r �initZlog_fileZ seed_pathr �er r r �remove_artifactsD s&