ó
    x[h0!  ã                   ó&  • S r SSKrSSKrSSKrSSKJr  SSKJrJr  SSK	J
r
   SSKJrJrJrJr  Sr/ S	QrSS
 jrSS jrSS jrSS jrSS\4S jjrS rS rS\\\4   4S jrS\\\4   4S jr\\S.rS\SS4S jrSS jr g! \ a    Sr N]f = f)zCloud-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ÚCloudCIXÚ
CloudSigmaÚ
CloudStackÚDigitalOceanÚE24CloudzGCE - 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)ÚOpenTelekomCloudzSamsung Cloud PlatformzSAP Converged CloudÚScalewayÚSmartOSÚUpCloudÚVMwareÚVultrÚZStackÚOutscaleÚWSLÚOtherc                 óˆ   • [        U SS05        / SQnU(       d  UR                  S5        [        U5        [        U SS5        g)zBAttach cloud-init logs and tarfile from 'cloud-init collect-logs'.zcloud-init-log-warningsz-egrep -i "warn|error" /var/log/cloud-init.log)z
cloud-initzcollect-logsz-tú/tmp/cloud-init-logs.tgzz--redactr*   zlogs.tgzN)r	   Úappendr
   r   )ÚreportÚuiÚinclude_sensitiveÚcommands       Ú2/usr/lib/python3/dist-packages/cloudinit/apport.pyÚattach_cloud_init_logsr1   I   sE   € äØà%Ø?ð	
ôò€Gö Ø�‰�zÔ"Ü˜Ô Ü�Ð2°JÕ?ó    c                 ób   • SnU(       a&  UR                  U5      (       a  [        U SS05        ggg)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?zlshw.txtÚlshwN)Úyesnor	   )r,   r-   Úprompts      r0   Úattach_hwinfor7   _   s5   € ð	0ð ö
 
ˆb�h‰h�v×ÑÜ# F¨Z¸Ð,@ÕAð €rr2   c                 óD  • [          HB  n[        R                  R                  UR                  5      n[	        XUR
                  5        MD     U(       aM  [         HB  n[        R                  R                  UR                  5      n[	        XUR
                  5        MD     gg)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        r0   Úattach_installer_filesr>   j   sv   € ÷ .ˆÜ—7‘7×#Ñ# K×$4Ñ$4Ó5ˆÜ˜f°×0AÑ0AÖBñ .ö ß;ˆKÜ—w‘w×'Ñ'¨×(8Ñ(8Ó9ˆHÜ! &°K×4EÑ4EÖFò <ð r2   c                 ó  • [         R                  R                  S5      n[        X5        [         R                  R	                  U5      (       a7  U R                  SS5        U S   (       a  U S==   S-  ss'   U S==   S-  ss'   gg)z<Attach ubuntu pro logs and tag if keys present in user-data.z/var/log/ubuntu-advantage.logÚTagsÚ Ú z
ubuntu-proN)r9   r:   r;   r   ÚexistsÚ
setdefault)r,   r-   r;   s      r0   Úattach_ubuntu_pro_inforE   {   sj   € ä�w‰w×ÑÐ ?Ó@€HÜ˜&Ô+Ü	‡w�w‡~�~�h×ÑØ×Ñ˜& "Ô%Ø�&�>Ø�6‹N˜cÑ!‹NØˆv‹˜,Ñ&Œð	  r2   Úreturnc                 óN   • U(       d  gSnUR                  U5      nUc  [        eU$ )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?)r5   ÚStopIteration)r,   r-   r6   Úresponses       r0   Úcan_attach_sensitiverJ   †   s3   € æØð	/ð ð �x‰x˜Ó€HØÑÜÐØ€Or2   c                 óì  • / nU R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        SU R                  5       ;   a  U S   nSU;   a  UR                  S5        U R                  S5      (       a  UR                  S	5        U(       aF  U R                  S
S5        U S
   (       a  U S
==   S-  ss'   U S
==   SR	                  U5      -  ss'   gg)z$Add any appropriate tags to the bug.ÚCurtinErrorÚcurtinÚSubiquityLogÚ	subiquityÚJournalErrorszBreaking ordering cyclezsystemd-orderingÚUdiLogzubuntu-desktop-installerr@   rA   rB   N)Úgetr+   ÚkeysrD   Újoin)r,   Únew_tagsÚerrorss      r0   Úadd_bug_tagsrW   ˜   sÊ   € à€HØ‡z�z�-× Ñ Ø�‰˜Ô!Ø‡z�z�.×!Ñ!Ø�‰˜Ô$Ø˜&Ÿ+™+›-Ó'Ø˜Ñ(ˆØ$¨Ó.Ø�O‰OÐ.Ô/Ø‡z�z�(×ÑØ�‰Ð2Ô3ÞØ×Ñ˜& "Ô%Ø�&�>Ø�6‹N˜cÑ!‹NØˆv‹˜#Ÿ(™( 8Ó,Ñ,Œð	 r2   c                 ó¸   • [         (       d  [        S5      e[        X5      n[        XU5        [	        X5        [        XU5        [        X5        [        U 5        g)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ÚRuntimeErrorrJ   r1   r7   r>   rE   rW   )r,   r-   r.   s      r0   Úadd_infor[   ¬   sW   € ÷ Š:ÜØIó
ð 	
ô -¨VÓ8ÐÜ˜6Ð'8Ô9Ü�&ÔÜ˜6Ð'8Ô9Ü˜6Ô&Ü�ÔØr2   c                 óÌ   • U R                  S0 5      R                  S0 5      R                  S5      nU(       d  0 $ SSSSSS	.n0 nUR                  5        H  u  pEX   X5'   M     U$ )
NÚ	meta_dataÚimdsÚcomputeÚImagePublisherÚ
ImageOfferÚImageSKUÚImageVersionÚVMSize)Ú	publisherÚofferÚskuÚversionÚvmSize©rR   Úitems)Úds_datar_   Úname_to_report_mapÚ
azure_dataÚsrc_keyÚreport_key_names         r0   Ú_get_azure_datarq   À   sw   € Ø�k‰k˜+ rÓ*×.Ñ.¨v°rÓ:×>Ñ>¸yÓI€GÞØˆ	à%ØØØ!ØñÐð €JØ$6×$<Ñ$<Ö$>Ñ ˆØ&-Ñ&6ˆ
Ó#ñ %?àÐr2   c                 óâ   • U R                  S0 5      R                  S0 5      R                  S5      nU(       d  0 $ 1 SknUR                  5        VVs0 s H  u  p4X2;   d  M  X4_M     snn$ s  snnf )NÚdynamiczinstance-identityÚdocument>   ÚregionÚimageIdÚarchitectureÚinstanceTypeÚbillingProductsrj   )rl   rt   Úwanted_keysÚkeyÚvalues        r0   Ú_get_ec2_datar}   Ñ   su   € à�‰�I˜rÓ"×&Ñ&Ð':¸BÓ?×CÑCÀJÓOð ö Øˆ	ò€Kð &.§^¡^Ô%5ôÚ%5‘z�s¸Ñ9K‹
ˆŠ
Ñ%5òð ùó s   ÁA+Á!A+)ÚazureÚec2Úplatformc                 óØ   • [         R                  U5      nU(       d  gU" U5      nUR                  5        H1  u  pVU(       d  M  X`UR                  5       UR                  5       -   '   M3     g)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_INFOrR   rk   Ú
capitalize)r,   r€   rl   Úplatform_infoÚretrieved_datar{   r|   s          r0   Úadd_datasource_specific_infor†   æ   s\   € ô +×.Ñ.¨xÓ8€MÞØÙ" 7Ó+€NØ$×*Ñ*Ö,‰
ˆÞÙØ;@ˆx×"Ñ"Ó$ s§~¡~Ó'7Ñ7Ó8ò -r2   c                 óh  •  [        5       (       d  g[        SS5       n[        R                  " U5      nSSS5        WR                  S5      nU(       d=  [
        R                  " 5       R                  S[        UR                  5       5      5        gSSS	S
SSS.R                  5        H#  u  pVUR                  U5      nU(       d  M  XpU'   M%     [        XS   UR                  S5      5        g! , (       d  f       NÀ= f! [         a'    [
        R                  " 5       R                  S5         gf = f)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Úmachiner€   ru   Úsubplatformr€   Úds)r   ÚopenÚjsonÚloadÚFileNotFoundErrorÚloggingÚ	getLoggerÚwarningrR   ÚsortedrS   rk   r†   )r,   Ú_ÚfopenÚinstance_datar‰   r{   Ú
report_keyr|   s           r0   Úgeneral_add_infor¡   ö   s  € ð
Ü$×&Ñ&ØÜÐ6¸Ô<ÀÜ ŸIšI eÓ,ˆM÷ =ð 
×	Ñ	˜4Ó	 €BÞÜ×ÒÓ×#Ñ#ØFÜ�=×%Ñ%Ó'Ó(ô	
ð 	ð Ø!Ø&Ø#ØØ)ñ÷ �eƒgò‰ˆð —‘�s“ˆßˆ5Ø!&�:Óñô !Ø�:‘ × 1Ñ 1°$Ó 7õ÷; =Õ<ûäó Ü×ÒÓ×#Ñ#ð1ô	
ñ 	ðús2   ‚D  ’D  žC/µD  Ã/
C=Ã9D  Ã=D  Ä .D1Ä0D1)NF)N)rF   N)!Ú__doc__r–   r™   r9   Útypingr   Úcloudinit.cmd.devel.logsr   r   Úcloudinit.cmd.statusr   Úapport.hookutilsr   r   r	   r
   rY   ÚImportErrorÚKNOWN_CLOUD_NAMESr1   r7   r>   rE   ÚboolrJ   rW   r[   Ústrrq   r}   r‚   r†   r¡   © r2   r0   Ú<module>r¬      sÓ   ðñ
 "ã Û Û 	Ý ÷õ 7ð
÷ó ð €Jò
'Ð ôT@ô,BôGô"'ñ¨Tõ ò$-ò(ð(  S¨# X¡ô ð"˜d 3¨ 8™nô ð$ $3¸=ÑIÐ ðA°3ð AÀDô Aõ *øðw ó Ø‚Jðús   ¤B ÂBÂB