HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3/dist-packages/cloudinit/__pycache__/apport.cpython-310.pyc
o

�Ad��@s�dZddlZddlmZddlmZmZzddlmZm	Z	m
Z
mZdZWne
y/dZYnwgd�Zd	Zd
Zdefdd
�Zddd�Zddd�Zddd�Zddd�Zddd�Zdd�Zdd�ZdS)zCloud-init apport interface�N)�read_cfg_paths)�INSTALLER_APPORT_FILES� INSTALLER_APPORT_SENSITIVE_FILES)�attach_file�attach_file_if_exists�attach_root_command_outputs�root_command_outputTF)"�AliYun�AltCloudz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�Otherz/var/log/cloud-init.logz/var/log/cloud-init-output.log�returncCst�}|�d�S)N�userdata_raw)r�
get_ipath_cur)�paths�r(�2/usr/lib/python3/dist-packages/cloudinit/apport.py�_get_user_data_fileFs
r*cCs,t|ddd��tgd��t|dd�dS)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.tgzr+zlogs.tgzN)rrr��report�uir(r(r)�attach_cloud_init_logsKs��	�r/cCs,d}|r|�|�rt|ddi�dSdSdS)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.�promptr(r(r)�
attach_hwinfo\s
��r3cCs^|r+d}|�|�}|durt�|r-d}|�|t�}|r%t|d|d<dSd|d<dSdSdS)z&Prompt for cloud details if available.z/Is this machine running in a cloud environment?NzOPlease select the cloud vendor or environment in which this instance is runningr�	CloudName�None)r1�
StopIteration�choice�KNOWN_CLOUD_NAMES)r-r.r2�responser(r(r)�attach_cloud_infogs
��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)r-r.�apport_filer=r(r(r)�attach_installer_fileszs�r@cCsx|r6t�}d�|�}|�|�}|durt�|r8tj�|�}t||d�tD]}tj�|j�}t	|||j
�q%dSdSdS)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*�formatr1r6r;r<r=rrrr>)r-r.�user_data_filer2r9r=r?r(r(r)�attach_user_data�s"�
�rCcCs�g}|�d�r|�d�|�d�r|�d�d|��vr)|d}d|vr)|�d�|�d�r3|�d	�|rT|�d
d�|d
rG|d
d7<|d
d�|�7<d
Sd
S)z$Add any appropriate tags to the bug.�CurtinError�curtin�SubiquityLog�	subiquity�
JournalErrorszBreaking ordering cyclezsystemd-ordering�UdiLogzubuntu-desktop-installer�Tags�� N)�get�append�keys�
setdefault�join)r-�new_tags�errorsr(r(r)�add_bug_tags�s"






�rTcCsJtstd��t||�t||�t||�t||�t||�t|�dS)a-This is an entry point to run cloud-init's apport functionality.

    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�RuntimeErrorr/r3r:rCr@rTr,r(r(r)�add_info�s�




rW)N)�__doc__r;�cloudinit.cmd.develr�cloudinit.cmd.devel.logsrr�apport.hookutilsrrrrrU�ImportErrorr8�
CLOUDINIT_LOG�CLOUDINIT_OUTPUT_LOG�strr*r/r3r:r@rCrTrWr(r(r(r)�<module>s*�&