%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3/dist-packages/cloudinit/__pycache__/apport.cpython-38.pyc

U

�fk(�$@s�dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZz ddl
mZmZmZmZdZWnek
r�d	ZYnXd
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-g$Zd.Zd/Zed0�d1d2�ZdMd3d4�ZdNd5d6�ZdOd7d8�ZdPd9d:�ZdQd;d<�ZdRd=d>�Zd?d@�ZdAdB�Z eeefd0�dCdD�Z!eeefd0�dEdF�Z"e!e"dG�Z#eddH�dIdJ�Z$dd0�dKdL�Z%dS)SzCloud-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_outputTFZAliYunZAltCloudZAkamaizAmazon - Ec2ZAzureZBigstepZ	BrightboxZ
CloudSigmaZ
CloudStackZDigitalOceanZE24CloudzGCE - Google Compute EnginezHuawei CloudZExoscalez
Hetzner CloudZNWCSz IBM - (aka SoftLayer or BlueMix)ZLXDZMAASZNoCloudZ
OpenNebulaZ	OpenStackZOracleZOVFz'RbxCloud - (HyperOne, Rootbox, Rubikon)ZOpenTelekomCloudzSAP Converged CloudZScalewayZSmartOSZUpCloudZVMwareZVultrZZStackZOutscaleZWSLZOtherz/var/log/cloud-init.logz/var/log/cloud-init-output.log)�returncCst�}|�d�S)NZuserdata_raw)rZ
get_ipath_cur)�paths�r
�2/usr/lib/python3/dist-packages/cloudinit/apport.py�_get_user_data_fileLsrcCs0t|ddd��tddddg�t|dd�d	S)
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.txtz
cloud-initzcollect-logsz-tz/tmp/cloud-init-logs.tgzzlogs.tgzN)r	r
r��report�uir
r
r�attach_cloud_init_logsQs��	
��rcCs$d}|r |�|�r t|ddi�dS)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.txtZlshwN)�yesnor	)rr�promptr
r
r�
attach_hwinfods�rc
Cs�|r�t�}zJt|�d���2}t�|�}|�di��d�s<t�W5QR�WdSQRXWnttjj	tfk
rrYnXd}|�
|�}|dkr�t�|r�d}|�|t
�}|r�t
|d|d<nd	|d<dS)
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�openZget_runpath�json�load�get�AssertionError�IOError�decoderZJSONDecodeErrorr�
StopIterationZchoice�KNOWN_CLOUD_NAMES)rrr�filerr�responser
r
r�attach_cloud_infoos(


�r'cCs*tD] }tj�|j�}t|||j�qdS)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)rr�apport_filer*r
r
r�attach_installer_files�sr-cCsZtj�d�}t||�tj�|�rV|�dd�|drF|dd7<|dd7<dS)z<Attach ubuntu pro logs and tag if keys present in user-data.z/var/log/ubuntu-advantage.log�Tags�� z
ubuntu-proN)r(r)r*r�exists�
setdefault)rrr*r
r
r�attach_ubuntu_pro_info�s
r3cCsp|rlt�}d�|�}|�|�}|dkr*t�|rltj�|�}t||d�tD] }tj�|j�}t	|||j
�qJdS)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�formatrr#r(r)r*rrrr+)rrZuser_data_filerr&r*r,r
r
r�attach_user_data�s&��
�r5cCs�g}|�d�r|�d�|�d�r,|�d�d|��krR|d}d|krR|�d�|�d�rf|�d	�|r�|�d
d�|d
r�|d
d7<|d
d�|�7<d
S)z$Add any appropriate tags to the bug.ZCurtinErrorZcurtinZSubiquityLogZ	subiquityZ
JournalErrorszBreaking ordering cyclezsystemd-orderingZUdiLogzubuntu-desktop-installerr.r/r0N)r�append�keysr2�join)rZnew_tags�errorsr
r
r�add_bug_tags�s 






r:cCsTtstd��t||�t||�t||�t||�t||�t||�t|�dS)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�RuntimeErrorrrr'r5r-r3r:rr
r
r�add_info�s�





r=cCsX|�di��di��d�}|s"iSdddddd	�}i}|��D]\}}||||<q>|S)
NZ	meta_dataZimds�computeZImagePublisherZ
ImageOfferZImageSKUZImageVersionZVMSize)Z	publisherZofferZsku�versionZvmSize�r�items)�ds_datar>Zname_to_report_mapZ
azure_dataZsrc_keyZreport_key_namer
r
r�_get_azure_data�s�rCcsF|�di��di��d�}|s"iSdddddh��fd	d
�|��D�S)NZdynamiczinstance-identity�documentZarchitectureZbillingProductsZimageIdZinstanceType�regioncsi|]\}}|�kr||�qSr
r
)�.0�key�value�Zwanted_keysr
r�
<dictcomp>
sz!_get_ec2_data.<locals>.<dictcomp>r@)rBrDr
rIr�
_get_ec2_datas��
�rK)ZazureZec2)�platformrcCsJt�|�}|sdS||�}|��D]"\}}|s0q"|||��|��<q"dS)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_INFOrrA�
capitalize)rrLrBZ
platform_infoZretrieved_datarGrHr
r
r�add_datasource_specific_infos
rOc	Cs�z0t�sWdStdd��}t�|�}W5QRXWn$tk
rTt���d�YdSX|�d�}|s�t���dt	|�
���dSddd	d
ddd
���D]\}}|�|�}|r�|||<q�t||d|�d��dS)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.rz8instance-data.json lacks 'v1' metadata. Present keys: %sZCloudIDrZCloudArchitectureZ
CloudPlatformZCloudRegionZCloudSubPlatform)Zcloud_idr�machinerLrEZsubplatformrLZds)
rrrr�FileNotFoundError�loggingZ	getLoggerZwarningr�sortedr7rArO)r�_ZfopenrrrGZ
report_keyrHr
r
r�general_add_info%s@�

��

�rV)N)N)N)N)N)N)&�__doc__rrSr(�typingrZcloudinit.cmd.develrZcloudinit.cmd.devel.logsrrZcloudinit.cmd.statusrZapport.hookutilsrrr	r
r;�ImportErrorr$Z
CLOUDINIT_LOGZCLOUDINIT_OUTPUT_LOG�strrrrr'r-r3r5r:r=rCrKrMrOrVr
r
r
r�<module>s�
�(


(





Zerion Mini Shell 1.0