%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�fk(��2�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZ	ddl
mZmZmZmZdZgd
�ZdZdZd
efd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd�Zd�Z d
eeeffd�Z!d
eeeffd�Z"e!e"d�Z#ded
dfd�Z$dd�Z%y#e$rd	ZY�]wxYw)zCloud-init apport interface�N)�Dict)�read_cfg_paths)�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�Otherz/var/log/cloud-init.logz/var/log/cloud-init-output.log�returnc�8�t�}|jd�S)N�userdata_raw)r�
get_ipath_cur)�pathss �2/usr/lib/python3/dist-packages/cloudinit/apport.py�_get_user_data_filer/Ls����E����~�.�.�c�V�t|ddd��tgd��t|dd�y)zBAttach cloud-init logs and tarfile from 'cloud-init collect-logs'.z-egrep -i "warn|error" /var/log/cloud-init.logz"cat /var/log/cloud-init-output.log)zcloud-init-log-warningszcloud-init-output.log.txt)z
cloud-initzcollect-logsz-t�/tmp/cloud-init-logs.tgzr2zlogs.tgzN)r
rr��report�uis  r.�attach_cloud_init_logsr6Qs:����@�)M�		
���H����*�J�r0c�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
)r4r5�prompts   r.�
attach_hwinfor;ds2��	0��

�b�h�h�v��#�F�Z��,@�A��rr0c���|rjt�}	t|jd��5}tj|�}|jdi�jd�sJ�	ddd�yyyy#1swYnxYwn.#ttjjtf$rYnwxYwd}|j|�}|�t�|s�[d}|j|t�}|rt|d|d<yd	|d<��)
a�Prompt for cloud details if instance-data unavailable.

    When we have valid _get_instance_data, apport/generic-hooks/cloud_init.py
    provides CloudName, CloudID, CloudPlatform and CloudSubPlatform.

    Apport/generic-hooks are delivered by cloud-init's downstream branches
    ubuntu/(devel|kinetic|jammy|focal|bionic) so they will not be represented
    in upstream main.

    In absence of viable instance-data.json format, prompt for the cloud below.
    �
instance_data�v1�
cloud_nameNz/Is this machine running in a cloud environment?zOPlease select the cloud vendor or environment in which this instance is runningr�	CloudName�None)r�open�get_runpath�json�load�get�IOError�decoder�JSONDecodeError�AssertionErrorr9�
StopIteration�choice�KNOWN_CLOUD_NAMES)r4r5r-�filer=r:�responses       r.�attach_cloud_inforPos��
�� ��	��e�'�'��8�9�
�T� $�	�	�$��
�$�(�(��r�2�6�6�|�D�D�D��
�
���
�
�
��
������5�5�~�F�	��	��C���8�8�F�#�������,�
��y�y��):�;�H��&7����&D��{�#�&,��{�#�s(�A;�:A.�"A;�.A7�3A;�;(B&�%B&c��tD]B}tjj|j�}t	|||j
��Dy)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	�label)r4r5�apport_filerTs    r.�attach_installer_filesrW�sA��.�C���7�7�#�#�K�$4�$4�5���f�h��0A�0A�B�Cr0c��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)rRrSrTr	�exists�
setdefault)r4r5rTs   r.�attach_ubuntu_pro_infor^�si���w�w��� ?�@�H��&�(�+�	�w�w�~�~�h�����&�"�%��&�>��6�N�c�!�N��v��,�&��	 r0c�f�|r�t�}dj|�}|j|�}|�t�|rxtj
j
|�}t||d�tD]B}tj
j
|j
�}t|||j��Dyyy)z(Optionally provide user-data if desired.z�Your user-data, cloud-config or autoinstall files can optionally  be provided from {0} and could be useful to developers when addressing this bug. Do you wish to attach user-data to this bug?Nz
user_data.txt)r/�formatr9rKrRrSrTrrr	rU)r4r5�user_data_filer:rOrTrVs       r.�attach_user_datarb�s���	�,�.��
��F�>�*�		��8�8�F�#��������w�w�'�'��7�H����/�:�?�
���7�7�+�+�K�,<�,<�=��%��H�k�&7�&7��
��
r0c��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-installerrYrZr[N)rF�append�keysr]�join)r4�new_tags�errorss   r.�add_bug_tagsro�s����H�
�z�z�-� �����!�
�z�z�.�!�����$��&�+�+�-�'���(��$��.��O�O�.�/�
�z�z�(�����2�3�����&�"�%��&�>��6�N�c�!�N��v��#�(�(�8�,�,��	r0c���tstd��t||�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�RuntimeErrorr6r;rPrbrWr^ror3s  r.�add_infors�s`����I�
�	
��6�2�&��&�"���f�b�!��V�R� ��6�2�&��6�2�&����r0c���|jdi�jdi�jd�}|siSdddddd	�}i}|j�D]
\}}||||<�|S)
N�	meta_data�imds�compute�ImagePublisher�
ImageOffer�ImageSKU�ImageVersion�VMSize)�	publisher�offer�sku�version�vmSize�rF�items)�ds_datarw�name_to_report_map�
azure_data�src_key�report_key_names      r.�_get_azure_datar��s����k�k�+�r�*�.�.�v�r�:�>�>�y�I�G���	�%���!�����J�$6�$<�$<�$>�7� ���&-�g�&6�
�?�#�7��r0c���|jdi�jdi�jd�}|siShd�}|j�D��cic]
\}}||vs�||��c}}Scc}}w)N�dynamiczinstance-identity�document>�region�imageId�architecture�instanceType�billingProductsr�)r�r��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_INFOrFr��
capitalize)r4r�r��
platform_info�retrieved_datar�r�s       r.�add_datasource_specific_infor�sg��+�.�.�x�8�M���"�7�+�N�$�*�*�,�A�
��U���;@��x�"�"�$�s�~�~�'7�7�8�Ar0c�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.r>z8instance-data.json lacks 'v1' metadata. Present keys: %s�CloudIDr@�CloudArchitecture�
CloudPlatform�CloudRegion�CloudSubPlatform)�cloud_idr?�machiner�r��subplatformr��ds)
rrBrDrE�FileNotFoundError�logging�	getLogger�warningrF�sortedrkr�r�)r4�_�fopenr=r>r��
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)N)r)N)&�__doc__rDr�rR�typingr�cloudinit.cmd.develr�cloudinit.cmd.devel.logsrr�cloudinit.cmd.statusr�apport.hookutilsrr	r
rrq�ImportErrorrM�
CLOUDINIT_LOG�CLOUDINIT_OUTPUT_LOG�strr/r6r;rPrWr^rbrorsr�r�r�r�r��r0r.�<module>r�s���
"���	��.��7�
����J�
%��P*�
�7��/�S�/�
�&B�%-�P
C�'��.-�(�*��S�#�X���"�d�3��8�n��$$3�=�I��
A�3�
A�D�
A� *��S���J��s�B�B�B

Zerion Mini Shell 1.0