%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/cloudinit/__pycache__/apport.cpython-312.pyc

�

���f!���dZddlZddlZddlZddlmZddlmZmZddl	m
Z
	ddlmZm
Z
mZmZdZgd	�Zdd
�Zdd�Zdd�Zdd
�Zddefd�Zd�Zd�Zdeeeffd�Zdeeeffd�Zeed�Zdeddfd�Zdd�Z y#e$rdZY�RwxYw)zCloud-init apport interface�N)�Dict)�INSTALLER_APPORT_FILES� INSTALLER_APPORT_SENSITIVE_FILES)�is_cloud_init_enabled)�attach_file�attach_file_if_exists�attach_root_command_outputs�root_command_outputTF)$�AliYun�AltCloud�AkamaizAmazon - Ec2�Azure�Bigstep�	Brightbox�
CloudSigma�
CloudStack�DigitalOcean�E24CloudzGCE - Google Compute EnginezHuawei Cloud�Exoscalez
Hetzner Cloud�NWCSz IBM - (aka SoftLayer or BlueMix)�LXD�MAAS�NoCloud�
OpenNebula�	OpenStack�Oracle�OVFz'RbxCloud - (HyperOne, Rootbox, Rubikon)�OpenTelekomCloudzSAP Converged Cloud�Scaleway�SmartOS�UpCloud�VMware�Vultr�ZStack�Outscale�WSL�Otherc�~�t|ddi�gd�}|s|jd�t|�t|dd�y)zBAttach cloud-init logs and tarfile from 'cloud-init collect-logs'.zcloud-init-log-warningsz-egrep -i "warn|error" /var/log/cloud-init.log)z
cloud-initzcollect-logsz-t�/tmp/cloud-init-logs.tgzz--redactr)zlogs.tgzN)r	�appendr
r)�report�ui�include_sensitive�commands    �2/usr/lib/python3/dist-packages/cloudinit/apport.py�attach_cloud_init_logsr0GsE����%�?�	
���G�����z�"��� ���2�J�?�c�N�d}|r!|j|�rt|ddi�yyy)z*Optionally attach hardware info from lshw.z�Your device details (lshw) may be useful to developers when addressing this bug, but gathering it requires admin privileges. Would you like to include this info?zlshw.txt�lshwN)�yesnor	)r+r,�prompts   r/�
attach_hwinfor6]s2��	0��

�b�h�h�v��#�F�Z��,@�A��rr1c�6�tD]B}tjj|j�}t	|||j
��D|rLtD]B}tjj|j�}t	|||j
��Dyy)a Attach any subiquity installer logs config.

    To support decoupling apport integration from installer config/logs,
    we eventually want to either source this function or APPORT_FILES
    attribute from subiquity  and/or ubuntu-desktop-installer package-hooks
    python modules.
    N)r�os�path�realpathr�labelr)r+r,r-�apport_filer:s     r/�attach_installer_filesr=hs���.�C���7�7�#�#�K�$4�$4�5���f�h��0A�0A�B�C��;�	G�K��w�w�'�'��(8�(8�9�H�!�&�(�K�4E�4E�F�	G�r1c��tjjd�}t||�tjj	|�r2|jdd�|dr
|dxxdz
cc<|dxxdz
cc<yy)z<Attach ubuntu pro logs and tag if keys present in user-data.z/var/log/ubuntu-advantage.log�Tags�� z
ubuntu-proN)r8r9r:r�exists�
setdefault)r+r,r:s   r/�attach_ubuntu_pro_inforDysi���w�w��� ?�@�H��&�(�+�	�w�w�~�~�h�����&�"�%��&�>��6�N�c�!�N��v��,�&��	 r1�returnc�B�|syd}|j|�}|�t�|S)z(Optionally provide user-data if desired.FaQYour user data, cloud-config, network config, or autoinstall files can optionally be provided and could be useful to developers when addressing this bug. However, this data should not be included if it contains any sensitive data such as passwords and secrets. Gathering it requires admin privileges. Would you like to include this info?)r4�
StopIteration)r+r,r5�responses    r/�can_attach_sensitiverI�s3��
��	/���x�x���H������Or1c��g}|jd�r|jd�|jd�r|jd�d|j�vr|d}d|vr|jd�|jd�r|jd	�|rA|jd
d�|d
r
|d
xxdz
cc<|d
xxdj	|�z
cc<y
y
)z$Add any appropriate tags to the bug.�CurtinError�curtin�SubiquityLog�	subiquity�
JournalErrorszBreaking ordering cyclezsystemd-ordering�UdiLogzubuntu-desktop-installerr?r@rAN)�getr*�keysrC�join)r+�new_tags�errorss   r/�add_bug_tagsrV�s����H�
�z�z�-� �����!�
�z�z�.�!�����$��&�+�+�-�'���(��$��.��O�O�.�/�
�z�z�(�����2�3�����&�"�%��&�>��6�N�c�!�N��v��#�(�(�8�,�,��	r1c��tstd��t||�}t|||�t	||�t|||�t
||�t|�y)a-This is an entry point to run cloud-init's package-specific hook

    Distros which want apport support will have a cloud-init package-hook at
    /usr/share/apport/package-hooks/cloud-init.py which defines an add_info
    function and returns the result of cloudinit.apport.add_info(report, ui).
    z;No apport imports discovered. Apport functionality disabledT)�
has_apport�RuntimeErrorrIr0r6r=rDrV)r+r,r-s   r/�add_inforZ�s_����I�
�	
�-�V�R�8���6�2�'8�9��&�"���6�2�'8�9��6�2�&����r1c���|jdi�jdi�jd�}|siSdddddd	�}i}|j�D]
\}}||||<�|S)
N�	meta_data�imds�compute�ImagePublisher�
ImageOffer�ImageSKU�ImageVersion�VMSize)�	publisher�offer�sku�version�vmSize�rQ�items)�ds_datar^�name_to_report_map�
azure_data�src_key�report_key_names      r/�_get_azure_datarp�s����k�k�+�r�*�.�.�v�r�:�>�>�y�I�G���	�%���!�����J�$6�$<�$<�$>�7� ���&-�g�&6�
�?�#�7��r1c���|jdi�jdi�jd�}|siShd�}|j�D��cic]
\}}||vs�||��c}}Scc}}w)N�dynamiczinstance-identity�document>�region�imageId�architecture�instanceType�billingProductsri)rkrs�wanted_keys�key�values     r/�
_get_ec2_datar|�st�����I�r�"�&�&�':�B�?�C�C�J�O�
���	��K�&.�^�^�%5��!�s�E���9K��U�
����s�
A#�A#)�azure�ec2�platformc���tj|�}|sy||�}|j�D],\}}|s�	|||j�|j�z<�.y)z�Add datasoure specific information from the ds dictionary.

    ds_data contains the "ds" entry from data from
    /run/cloud/instance-data.json.
    N)�PLATFORM_SPECIFIC_INFOrQrj�
capitalize)r+rrk�
platform_info�retrieved_datarzr{s       r/�add_datasource_specific_infor��sg��+�.�.�x�8�M���"�7�+�N�$�*�*�,�A�
��U���;@��x�"�"�$�s�~�~�'7�7�8�Ar1c�8�	t�sytdd�5}tj|�}ddd�jd�}|s<tj�jdt|j���yddd	d
ddd
�j�D]\}}|j|�}|s�|||<� t||d|jd��y#1swY��xYw#t$r&tj�jd�YywxYw)z�Entry point for Apport.

    This hook runs for every apport report

    Add a subset of non-sensitive cloud-init data from
    /run/cloud/instance-data.json that will be helpful for debugging.
    Nz"/run/cloud-init/instance-data.json�rzKcloud-init run data not found on system. Unable to add cloud-specific data.�v1z8instance-data.json lacks 'v1' metadata. Present keys: %s�CloudID�	CloudName�CloudArchitecture�
CloudPlatform�CloudRegion�CloudSubPlatform)�cloud_id�
cloud_name�machinerrt�subplatformr�ds)
r�open�json�load�FileNotFoundError�logging�	getLogger�warningrQ�sortedrRrjr�)r+�_�fopen�
instance_datar�rz�
report_keyr{s        r/�general_add_infor��s"��
�$�&��
�6��
<�	-�� �I�I�e�,�M�	-�
�	�	�4�	 �B�
�����#�#�F��=�%�%�'�(�	
�	��!�&�#��)�
��e�g�
'���Z����s����!&�F�:��
'�!���:��
� 1� 1�$� 7��;	-�	-��������#�#�
1�	
�	��s,�
C*�C*�C�C*�C'�#C*�*,D�D)NF)N)rEN)!�__doc__r�r�r8�typingr�cloudinit.cmd.devel.logsrr�cloudinit.cmd.statusr�apport.hookutilsrrr	r
rX�ImportError�KNOWN_CLOUD_NAMESr0r6r=rD�boolrIrVrZ�strrpr|r�r�r��r1r/�<module>r�s���
"���	���7�
����J�
%��P@�,B�G�"'��T��$-�(�(��S�#�X���"�d�3��8�n��$$3�=�I��
A�3�
A�D�
A� *��s���J��s�A;�;B�B

Zerion Mini Shell 1.0