관리-도구
편집 파일: apport.cpython-39.pyc
a ����'�Dg!����������������������@���s$��d�Z�ddlZddlZddlZddlmZ�ddlmZmZ�ddl m Z �z ddlmZm Z mZmZ�dZW�n�eyz���dZY�n0�g�d �Zd#d d�Zd$dd �Zd%dd�Zd&dd�Zd'ed�dd�Zdd��Zdd��Zeeef�d�dd�Zeeef�d�dd�Zeed�Zedd�dd �Zdd�d!d"�Z dS�)(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)%ZAliYunZAltCloudZAkamaizAmazon - Ec2ZAzureZBigstepZ BrightboxZCloudCIXZ CloudSigmaZ CloudStackZDigitalOceanZE24CloudzGCE - Google Compute EnginezHuawei CloudZExoscalez Hetzner CloudZNWCSz IBM - (aka SoftLayer or BlueMix)ZLXDZMAASZNoCloudZ OpenNebulaZ OpenStackZOracleZOVFz'RbxCloud - (HyperOne, Rootbox, Rubikon)ZOpenTelekomCloudzSAP Converged CloudZScalewayZSmartOSZUpCloudZVMwareZVultrZZStackZOutscaleZWSLZOtherc�����������������C���s<���t�|�ddi��g�d�}|s$|�d��t|��t|�dd��dS�)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-initzcollect-logsz-t�/tmp/cloud-init-logs.tgzz--redactr ���zlogs.tgzN)r����appendr ���r���)�report�ui�include_sensitiveZcommand��r����4/usr/lib/python3.9/site-packages/cloudinit/apport.py�attach_cloud_init_logsH���s������ r���c�����������������C���s$���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���)r���r ����promptr���r���r���� attach_hwinfo^���s�����r���c�����������������C���sT���t�D�] }tj�|j�}t|�||j��q|rPtD�] }tj�|j�}t|�||j��q.dS�)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���Zlabelr���)r���r ���r���Zapport_filer���r���r���r����attach_installer_filesi���s����r���c�����������������C���sZ���t�j�d�}t|�|��t�j�|�rV|��dd��|�d�rF|�d��d7��<�|�d��d7��<�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)r���r ���r���r���r���r����attach_ubuntu_pro_infoz���s���� r���)�returnc�����������������C���s&���|sdS�d}|��|�}|du�r"t�|S�)z(Optionally provide user-data if desired.FaQ��Your 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?N)r���� StopIteration)r���r ���r���Zresponser���r���r����can_attach_sensitive����s����� r!���c�����������������C���s����g�}|���d�r|�d��|���d�r,|�d��d|����v�rR|�d�}d|v�rR|�d��|���d�rf|�d ��|r�|��d d��|�d �r�|�d ��d7��<�|�d ��d�|�7��<�d S�)z$Add any appropriate tags to the bug.ZCurtinErrorZcurtinZSubiquityLogZ subiquityZ JournalErrorszBreaking ordering cyclezsystemd-orderingZUdiLogzubuntu-desktop-installerr���r���r���N)�getr����keysr����join)r���Znew_tags�errorsr���r���r����add_bug_tags����s ���� r&���c�����������������C���sN���t�std��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�RuntimeErrorr!���r���r���r���r���r&���)r���r ���r���r���r���r����add_info����s����� r)���c�����������������C���sX���|���di����di����d�}|s"i�S�dddddd �}i�}|���D�]\}}||�||<�q>|S�) NZ meta_dataZimds�computeZImagePublisherZ ImageOfferZImageSKUZImageVersionZVMSize)Z publisherZofferZsku�versionZvmSize�r"����items)�ds_datar*���Zname_to_report_mapZ azure_dataZsrc_keyZreport_key_namer���r���r����_get_azure_data����s�����r/���c��������������������s@���|���di����di����d�}|s"i�S�h�d�����fdd�|���D��S�)NZdynamiczinstance-identity�document>����regionZimageIdZbillingProductsZarchitectureZinstanceTypec��������������������s���i�|�]\}}|��v�r||�qS�r���r���)�.0�key�value�Zwanted_keysr���r���� <dictcomp>����s���z!_get_ec2_data.<locals>.<dictcomp>r,���)r.���r0���r���r5���r���� _get_ec2_data����s����� �r7���)ZazureZec2)�platformr���c�����������������C���sJ���t��|�}|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_INFOr"���r-���� capitalize)r���r8���r.���Z platform_infoZretrieved_datar3���r4���r���r���r����add_datasource_specific_info����s���� r;���c�����������������C���s����zDt���sW�dS�tdd��}t�|�}W�d����n1�s80����Y��W�n"�tyf���t����d��Y�dS�0�|�d�}|s�t����dt |� �����dS�ddd d ddd ����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.�v1z8instance-data.json lacks 'v1' metadata. Present keys: %sZCloudIDZ CloudNameZCloudArchitectureZ CloudPlatformZCloudRegionZCloudSubPlatform)Zcloud_idZ cloud_name�machiner8���r1���Zsubplatformr8���Zds) r����open�json�load�FileNotFoundError�loggingZ getLoggerZwarningr"����sortedr#���r-���r;���)r����_ZfopenZ instance_datar=���r3���Z report_keyr4���r���r���r����general_add_info����s<����,� �� �rF���)NF)N)NF)N)N)!�__doc__r@���rC���r����typingr���Zcloudinit.cmd.devel.logsr���r���Zcloudinit.cmd.statusr���Zapport.hookutilsr���r���r���r ���r'����ImportErrorZKNOWN_CLOUD_NAMESr���r���r���r����boolr!���r&���r)����strr/���r7���r9���r;���rF���r���r���r���r����<module>���s0��� )