HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1784574/root/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Current File : //proc/1784574/root/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-311.pyc
�

܍~c����dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZddl
mZmZmZmZmZdZdd�Zdd
�Zd�Zd�Zed
kre��dSdS)zEDefine 'clean' utility and handler as part of cloud-init commandline.�N)�settings)�Init)�ProcessExecutionError�runparts�subp)�del_dir�del_file�error�get_config_logfiles�is_linkz/etc/machine-idc��|stjdd���}|�dddddd	�
��|�dddd�
��|�ddddd�
��|�dddddd�
��|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�helpz--machine-idzWRemove /etc/machine-id for golden image creation. Next boot generates a new machine-id.)rrr�-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.)�argparse�ArgumentParser�add_argument��parsers �5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�
get_parserrs����
��(��!�
�
�
���������
�
&�
����������
5������������
J������������
�
D�
�����M�Fc
�t�tg���}|���|r&t|j��D]}t	|���t
j�|jj	��sdSt
j�
|jj	d��}tjd|jj	z��D]�}||kr|s�	t
j�|��rt|��st|��nt	|���Z#t$r<}td�|t#|������Yd}~dSd}~wwxYw	t%t&j��n7#t*$r*}tdt&j�d	|����Yd}~dSd}~wwxYwdS)
a4Helper 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.
    )�ds_depsr�seedz%s/*zCould not remove {0}: {1}N�zFailure during run-parts of z: )r�read_cfgr�cfgr	�os�path�isdir�paths�	cloud_dir�join�globrr�OSErrorr
�format�strrr�CLEAN_RUNPARTS_DIR�	Exception)rr�init�log_file�	seed_pathr(�es       r�remove_artifactsr7Ps��������D��M�M�O�O�O���+�D�H�5�5�	�	�H��X�����
�7�=�=���-�.�.���q�����T�Z�1�6�:�:�I��	�&�4�:�#7�7�8�8�
�
���9���[���	��w�}�}�T�"�"�
�7�4�=�=�
���
�
�
�
���������	�	�	��-�4�4�T�3�q�6�6�B�B�C�C�C��1�1�1�1�1�1�����	�������,�-�-�-�-������
�M�8�+F�M�M�!�M�M�	
�	
�	
��q�q�q�q�q�����	����

�1s1�A
D�
E#�'0E�E#�'F�
F5�F0�0F5c	�J�t|j|j��}|jrt	t
��|dkrg|jr`gd�}	t|d���nI#t$r<}td�
|t|������d}Yd}~nd}~wwxYw|S)z3Handle calls to 'cloud-init clean' as a subcommand.r)�shutdownr�nowF)�capturez-Could not reboot this system using "{0}": {1}r$N)r7rr�
machine_idr	�ETC_MACHINE_ID�rebootrrr
r/r0)�name�args�	exit_code�cmdr6s     r�handle_clean_argsrCws��� ��!1�4�3C�D�D�I���!��� � � ��A�~�~�$�+�~�'�'�'��	���e�$�$�$�$�$��$�	�	�	��?�F�F���Q�����
�
�
�
�I�I�I�I�I�I�����
	�����s�A�
B �$2B�B c��t��}tjtd|�������dS)z4Tool to collect and tar all cloud-init related logs.rN)r�sys�exitrC�
parse_argsrs r�mainrH�s8��
�\�\�F��H�
�w��(9�(9�(;�(;�
<�
<�=�=�=�=�=r �__main__)N)F)�__doc__rr-r'rE�	cloudinitr�cloudinit.stagesr�cloudinit.subprrr�cloudinit.utilrr	r
rrr=rr7rCrH�__name__�r r�<module>rQs-��L�K���������	�	�	�	�
�
�
�
�������!�!�!�!�!�!�@�@�@�@�@�@�@�@�@�@���������������#��1�1�1�1�h$
�$
�$
�$
�N���&>�>�>��z����D�F�F�F�F�F��r