HOME


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

܍~c�$���dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZmZdd	lmZdd
lmZmZmZmZddgZd
ZGd�de	��Zedd��edd��edd��gZedd��edd��edd��edd��edd��ed d!��ed"d#��ed$d%��ed&d'��ed(d)��ed*d)��ed+d,��gZd-efd.�Zd-efd/�Zd;d0�Z d1�Z!d2�Z"d3�Z#d4�Z$d5�Z%d<d6e&fd7�Z'd8�Z(d9�Z)e*d:krej+e)����dSdS)=zGDefine 'collect-logs' utility and handler to include in cloud-init cmd.�N)�datetime)�Path)�
NamedTuple)�read_cfg_paths)�Paths)�ProcessExecutionError�subp)�tempdir)�chdir�copy�
ensure_dir�
write_filez/var/log/cloud-init.logz/var/log/cloud-init-output.logz/run/cloud-initc�$�eZdZUeed<eed<dS)�
ApportFile�path�labelN)�__name__�
__module__�__qualname__�str�__annotations__���:/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.pyrrs"�������

�I�I�I��J�J�J�J�Jrrz(/var/log/installer/autoinstall-user-data�AutoInstallUserDataz/autoinstall.yaml�AutoInstallYAMLz'/etc/cloud/cloud.cfg.d/99-installer.cfg�InstallerCloudCfgz//var/log/installer/ubuntu_desktop_installer.log�UdiLogz-/var/log/installer/subiquity-server-debug.log�SubiquityServerDebugz-/var/log/installer/subiquity-client-debug.log�SubiquityClientDebugz%/var/log/installer/curtin-install.log�	CurtinLogz0/var/log/installer/subiquity-curtin-install.conf�CurtinInstallConfigz8/var/log/installer/curtin-install/subiquity-initial.conf�CurtinConfigInitialz:/var/log/installer/curtin-install/subiquity-curthooks.conf�CurtinConfigCurtHooksz8/var/log/installer/curtin-install/subiquity-extract.conf�CurtinConfigExtractz=/var/log/installer/curtin-install/subiquity-partitioning.conf�CurtinConfigPartitioningz(/var/log/installer/curtin-error-logs.tar�CurtinErrorz$/var/log/installer/curtin-errors.tarz(/var/log/installer/block/probe-data.json�	ProbeData�returnc�H�t��}|�d��S)N�userdata_raw)r�
get_ipath_cur��pathss r�_get_user_data_filer/Ms!�����E����~�.�.�.rc�H�t��}|�d��S)N�data)r�	get_cpathr-s r�_get_cloud_data_pathr3Rs�����E��?�?�6�"�"�"rc
��|stjdd���}|�dddddd	�
��|�ddd
d���t��}|�dddddd�|�����|S)a2Build or extend and arg parser for collect-logs utility.

    @param parser: Optional existing ArgumentParser instance representing the
        collect-logs subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    �collect-logsz)Collect and tar all cloud-init debug info)�prog�descriptionz	--verbosez-v�countr�	verbosityzBe more verbose.)�action�default�dest�helpz	--tarfilez-tzcloud-init.tar.gzzOThe tarfile to create containing all collected logs. Default: cloud-init.tar.gz)r;r=z--include-userdataz-uF�
store_true�userdatazPOptionally include user-data from {0} which could contain sensitive information.)r;r:r<r=)�argparse�ArgumentParser�add_argumentr/�format)�parser�user_data_files  r�
get_parserrFWs����
��(��C�
�
�
���������
�
�
���������#�
*�����)�*�*�N�
�������
�
&�&,�f�^�&<�&<��
�
�
��Mrc��dg}tj��dkr-|�ti��jd��|S)z>Return a list of files to ignore for /run/cloud-init directoryzhook-hotplug-cmdr�instance_data_sensitive)�os�getuid�appendr�lookups)�curdir�files�
ignored_filess   r�_copytree_rundir_ignore_filesrP�sJ��	��M�
�y�{�{�a������U�2�Y�Y�.�/H�I�J�J�J��rc��	t|��\}}t||��td|zd|��|S#t$r<}t|t	|����td|zd|��Yd}~dSd}~wwxYw)zCHelper which runs a command and writes output or error to filename.z
collected %s
�zcollecting %s failed.
N)r	r�_debugrr)�cmd�filename�msgr9�out�_�es       r�_write_command_output_to_filerZ�s�����c�����Q�
	�8�S�!�!�!���#�%�q�)�4�4�4��
��
!�>�>�>��8�S��V�V�$�$�$��(�3�.��9�=�=�=�=�=�=�=�=�=�����>���s�:�
B�1A;�;Bc�T�||kr!tj�|��dSdS�N)�sys�stderr�write)rV�levelr9s   rrSrS�s1���	����
����������rc��tj�|��r&t||��t	d|zd|��dSt	d|zd|��dS)Nzcollected file: %s
rRzfile %s did not exist
�)rIr�isfilerrS)r�out_dirr9s   r�
_collect_filere�sd��	�w�~�~�d���?��T�7�����%��,�a��;�;�;�;�;��(�4�/��I�>�>�>�>�>rc���tD]q}t||jz��j}|���stt
|����t|jt
|��|���r|rytD]s}t||jz��j}|���stt
|����t|jt
|��|���rdSdS)z'Obtain subiquity logs and config files.N)	�INSTALLER_APPORT_FILESrr�parent�existsr
rre� INSTALLER_APPORT_SENSITIVE_FILES)�log_dir�include_userdatar9�src_file�destination_dirs     r�collect_installer_logsro�s��*�F�F���w���6�7�7�>���%�%�'�'�	-��s�?�+�+�,�,�,��h�m�S��%9�%9�9�E�E�E�E��J�8�	J�	J�H�"�7�X�]�#:�;�;�B�O�"�)�)�+�+�
1��3��/�/�0�0�0��(�-��_�)=�)=�y�I�I�I�I�J�J�	J�	Jrrlc��|r8tj��dkr!tj�d��dStj�|��}tj���	���
d��}td���5}tj�||��}tddgtj�|d	��d
|��}tgd�tj�|d��d
|��}|s|r|nd}td|zd|��tdgtj�|d��d|��tgd�tj�|d��d|��tD]}t!|||���|rt#��}t!|||��t%|||��tj�|d��}	t'|	��tj�t*��r�	t-jt*tj�|	d��t0���nj#t,j$rX}
tj�d��tj�t5|
��dz��Yd}
~
nd}
~
wwxYwtdt*zd|��ntdt*zd|��tj�tj�t*d����rnt7t9����}|���r?t-jt5|��t7|t5|��z����t;|��5t=dd||�|d zd!��g��ddd��n#1swxYwYddd��n#1swxYwYtj�d"|z��dS)#z�Collect all cloud-init logs and tar them up into the provided tarfile.

    @param tarfile: The path of the tar-gzipped file to create.
    @param include_userdata: Boolean, true means include user-data.
    rzMTo include userdata, root user is required. Try sudo cloud-init collect-logs
rRzcloud-init-logs-%Y-%m-%dz/tmp)�dir�
cloud-initz	--version�versionzcloud-init --version)z
dpkg-queryz--showz-f=${Version}
rrzdpkg-versionzdpkg versionz
not-availablez!collected cloud-init version: %s
�dmesgz	dmesg.txtzdmesg output)�
journalctlz--boot=0z-oz
short-precisezjournal.txtzsystemd journal of current boot�run)�ignorez(Failed collecting file(s) due to error:
�
Nzcollected dir %s
zdirectory '%s' did not exist
�disabled�tar�czvf�/�z	Wrote %s
) rIrJr]r^r_r�abspathr�utcnow�date�strftimer
�joinrZrS�CLOUDINIT_LOGSrer/ror
ri�CLOUDINIT_RUN_DIR�shutil�copytreerP�Errorrrr3rr	�replace)�tarfilerlr9rk�tmp_dirrs�dpkg_ver�logrE�run_dirrY�cloud_data_dirs            r�collect_logsr��s�����B�I�K�K�1�,�,��
���
2�	
�	
�	
��q��g�o�o�g�&�&�G��o���$�$�&�&�/�/�0J�K�K�G�	�V�	�	�	�AO���'�,�,�w��0�0��/�
�;�'��G�L�L��)�,�,�"��	
�
��1�E�E�E��G�L�L��.�1�1���	
�
���	@�"*�?�h�h��G��3�g�=�q�)�L�L�L�%�
�I��G�L�L��+�.�.���		
�	
�	
�	&�=�=�=��G�L�L��-�0�0�-��		
�	
�	
�"�	3�	3�C��#�w�	�2�2�2�2��	>�0�2�2�N��.�'�9�=�=�=��w�(8�)�D�D�D��'�,�,�w��.�.���7����
�7�>�>�+�,�,�	�
0���%��G�L�L��,�7�7�8�������
�<�
0�
0�
0��
� � �!L�M�M�M��
� � ��Q���$��/�/�/�/�/�/�/�/�����
0����
�'�*;�;�Q�	�J�J�J�J��0�3D�D���
�
�
�
�7�>�>�"�'�,�,�'8�*�E�E�F�F�	�!�"6�"8�"8�9�9�N��$�$�&�&�
�����'�'���3�~�#6�#6�6�7�7�����7�^�^�	O�	O��%���'�/�/�'�C�-��*L�*L�M�N�N�N�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O�	O����	O�	O�	O�	O�AAO�AO�AO�AO�AO�AO�AO�AO�AO�AO�AO����AO�AO�AO�AO�D�J���\�G�+�,�,�,��1sc�"F$P1�?J�P1�K.�AK)�$P1�)K.�.C5P1�#+P�P1�P	�P1�!P	�"P1�1P5�8P5c�B�t|j|j|j��S)z:Handle calls to 'cloud-init collect-logs' as a subcommand.)r�r�r?r9)�name�argss  r�handle_collect_logs_argsr�
s�����d�m�T�^�D�D�Drc�b�t��}td|�����S)z4Tool to collect and tar all cloud-init related logs.r5)rFr��
parse_args)rDs r�mainr�s'��
�\�\�F�#�N�F�4E�4E�4G�4G�H�H�Hr�__main__r\)r),�__doc__r@rIr�r]r�pathlibr�typingr�cloudinit.cmd.develr�cloudinit.helpersr�cloudinit.subprr	�cloudinit.temp_utilsr
�cloudinit.utilrrr
rr�r�rrjrgrr/r3rFrPrZrSrero�boolr�r�r�r�exitrrr�<module>r�sl��N�M�����	�	�	�	�
�
�
�
�
�
�
�
�������������������.�.�.�.�.�.�#�#�#�#�#�#�6�6�6�6�6�6�6�6�(�(�(�(�(�(�>�>�>�>�>�>�>�>�>�>�>�>�+�-M�N��%������������J�2�4I����J�"�$5�6�6��J�8�:M�N�N�$� ��J�@�(�K�K��J�7�9O����J�7�9O����J�6��D�D��J�:�����J�B�����J�D�����J�B�����J�G�"���
�J�9�=�I�I��J�5�}�E�E��J�9�;�G�G�C"��J/�S�/�/�/�/�
#�c�#�#�#�#�
+�+�+�+�\���
�
�
����
?�?�?�J�J�J�Q
�Q
�D�Q
�Q
�Q
�Q
�hE�E�E�
I�I�I��z����C�H�T�T�V�V�������r