+
    =l j­  ã                   óê   € ^ RI t ^ RIt^ RIHtHt ^ RIHtHtHtH	t	H
t
 ^ RIHt RtRt]]3tRtRtR	tR
tRtRtRtRt]R,           t]P2                  ! ]
P4                  ! ]4      4      t ! R R]4      tR# )é    N)ÚAnyÚDict)Ú
exceptionsÚhttpÚsecret_managerÚsystemÚutil)ÚPublicCloudAutoAttachInstancez169.254.169.254z[fd00:ec2::254]zhttp://{}/latest/api/tokenz0http://{}/latest/dynamic/instance-identity/pkcs7z3http://{}/latest/dynamic/instance-identity/documentz/sys/hypervisor/uuidz /sys/class/dmi/id/product_serialz/sys/class/dmi/id/product_uuidÚ21600zX-aws-ec2-metadata-tokenz-ttl-secondsc                   ó¾  a € ] tR t^t o RtRtV 3R lR lt]]P                  ! ]
P                  . ROR7      V 3R lR l4       4       t]P                  ! ]
P                  . ROR7      V 3R lR l4       t]V 3R	 lR
 l4       tR t]P                  ! ]
P                  . ROR7      R 4       t]V 3R lR l4       t]V 3R lR l4       tV 3R lR ltV 3R lR ltRtV tR# )ÚAWSAutoAttachInstanceNc                ó    <€ V ^8„  d   QhRS[ /# )é   Úurl©Ústr)ÚformatÚ__classdict__s   "€Ú5/usr/lib/python3/dist-packages/uaclient/clouds/aws.pyÚ__annotate__Ú"AWSAutoAttachInstance.__annotate__   s   ø€ ÷ ñ ©#ñ ó    c                óÄ   € \         P                  ! W^R7      pVP                  ^È8X  d   VP                  # \        P
                  ! VP                  VP                  R7      h)é   )ÚheadersÚtimeout©ÚcodeÚbody)r   Úreadurlr   r   r   ÚCloudMetadataError)Úselfr   r   Úresponses   &&& r   Ú_get_imds_url_responseÚ,AWSAutoAttachInstance._get_imds_url_response   sH   € Ü—<’< ¸aÔ@ˆØ�=‰=˜CÔØ—=‘=Ð ä×/Ò/Ø—]‘]¨¯©ôð r   )Úretry_sleepsc                ó6   <€ V ^8„  d   QhRS[ S[S[3,          /# ©r   Úreturn)r   r   r   )r   r   s   "€r   r   r   ,   s   ø€ ÷ ,ñ ,™d¡3© 8�nñ ,r   c                óÊ   € V P                  4       p\        P                  V P                  4      pV P	                  W!R 7      p\
        P                  P                  V4       RV/# )©r   Úpkcs7)Ú_request_imds_v2_token_headersÚIMDS_URLr   Ú_ip_addressr$   r   ÚsecretsÚ
add_secret)r"   r   r   Úimds_url_responses   &   r   Úidentity_docÚ"AWSAutoAttachInstance.identity_doc*   s[   € ð ×5Ñ5Ó7ˆÜ�o‰o˜d×.Ñ.Ó/ˆØ ×7Ñ7¸Ð7ÓMÐÜ×Ñ×)Ñ)Ð*;Ô<ØÐ*Ð+Ð+r   c                ó    <€ V ^8„  d   QhRS[ /# r(   )r   )r   r   s   "€r   r   r   4   s   ø€ ÷ ñ ™Tñ r   c                ó&  € V P                  4       p\        P                  V P                  4      p \        P
                  ! V P                  W!R7      4      pV#   \        P                   d#   p\        P                  RT4       / u Rp?# Rp?ii ; i)zÜ
Get the instance identity doc associated with the current instance.

See
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/retrieve-iid.html
for more context.

@return: Dict containing the instance identity document.
r+   z-Error decoding instance identity document: %sN)
r-   Ú_IMDS_IID_URLr   r/   ÚjsonÚloadsr$   ÚJSONDecodeErrorÚLOGÚdebug)r"   r   r   Úii_docÚes   &    r   Ú_get_ii_docÚ!AWSAutoAttachInstance._get_ii_doc3   s   € ð ×5Ñ5Ó7ˆÜ×"Ñ" 4×#3Ñ#3Ó4ˆð	Ü—Z’ZØ×+Ñ+¨CÐ+ÓAóˆFð ˆøô ×#Ñ#ô 	Ü�I‰IÐEÀqÔIØ�Iûð	ús   ±&A ÁBÁ.BÂBÂBc                ó    <€ V ^8„  d   QhRS[ /# r(   ©Úbool)r   r   s   "€r   r   r   J   s   ø€ ÷ Iñ I™tñ Ir   c                ó¦   € V P                  4       pVP                  RR4      pVP                  RR4      p\        V4      ;'       g    \        V4      # )zÞ
Determines if the instance is likely Ubuntu Pro.

Criteria: if any billing-product or marketplace-product-code is
present, then is likely a Pro instance.

@return: Boolean indicating if the instance is likely pro or not.
ÚbillingProductsNÚmarketplaceProductCodes)r?   ÚgetrC   )r"   r=   Úbilling_productsÚmarketplace_product_codess   &   r   Úis_likely_proÚ#AWSAutoAttachInstance.is_likely_proI   sP   € ð ×!Ñ!Ó#ˆØ!Ÿ:™:Ð&7¸Ó>ÐØ$*§J¡JÐ/HÈ$Ó$OÐ!ÜÐ$Ó%×HÐH¬Ð.GÓ)HÐHr   c                ó8  € \          F  p V P                  VR 7      pWn         M	  V P                  f+   \        P                  ! RP                  \         4      R7      hX#   \         d.   p\        P                  RT\        TRR4      4        Rp?K�  Rp?ii ; i))Ú
ip_addressz*Could not reach AWS IMDS at http://%s: %s
ÚreasonÚ Nz, )Ú	addresses)
ÚIMDS_IP_ADDRESSÚ_get_imds_v2_token_headersr/   Ú	Exceptionr;   ÚwarningÚgetattrr   ÚAWSNoValidIMDSÚjoin)r"   Úaddressr   r>   s   &   r   r-   Ú4AWSAutoAttachInstance._request_imds_v2_token_headersX   s˜   € ß&ˆGð
Ø×9Ñ9ÀWÐ9ÓM�ð $+Ô Ùñ 'ð ×ÑÒ#Ü×+Ò+ØŸ)™)¤OÓ4ôð ð ˆøô ô Ü—‘ØAØÜ˜A˜x¨Ó,÷ò ûðús   ‹A!Á!BÁ,"BÂBc                ó$  € V P                   R 8X  d   R# V P                   '       d   \        V P                   /# \        P                  ! \        P                  V4      R\        \        /^R7      pVP                  ^È8X  dM   VP                  V n         \        P                  P                  V P                   4       \        V P                   /# VP                  R8X  d
   R V n         R# \        P                  ! VP                  VP                  R7      h)ÚIMDSv1NÚPUT)Úmethodr   r   i”  r   )Ú
_api_tokenÚAWS_TOKEN_PUT_HEADERr   r    ÚIMDS_V2_TOKEN_URLr   ÚAWS_TOKEN_REQ_HEADERÚAWS_TOKEN_TTL_SECONDSr   r   r   r0   r1   r   r!   )r"   rM   r#   s   && r   rR   Ú0AWSAutoAttachInstance._get_imds_v2_token_headersk   sÊ   € à�?‰?˜hÔ&ÙØ�_�_ˆ_Ü(¨$¯/©/Ð:Ð:ä—<’<Ü×$Ñ$ ZÓ0ØÜ)Ô+@ÐAØô	
ˆð �=‰=˜CÔØ&Ÿm™mˆDŒOÜ×"Ñ"×-Ñ-¨d¯o©oÔ>Ü(¨$¯/©/Ð:Ð:Ø�=‰=˜CÔØ&ˆDŒOÙä×+Ò+Ø—‘ X§]¡]ô
ð 	
r   c                ó    <€ V ^8„  d   QhRS[ /# r(   r   )r   r   s   "€r   r   r   …   s   ø€ ÷ ñ ™Cñ r   c                ó   € R # )Úaws© ©r"   s   &r   Ú
cloud_typeÚ AWSAutoAttachInstance.cloud_type„   ó   € ár   c                ó    <€ V ^8„  d   QhRS[ /# r(   rB   )r   r   s   "€r   r   r   ‰   s   ø€ ÷ ñ ™4ñ r   c                óf  €  \         P                  ! \        4      pRVR,          8X  d   R#  \         P                  ! \        4      P                  4       p\         P                  ! \        4      P                  4       pRVR,          u;8X  d   VR,          8X  d    R#  R# R#   \         d     L‚i ; i)z$This machine is a viable AWSInstanceÚec2:r   é   NTF)r   Ú	load_fileÚSYS_HYPERVISOR_PRODUCT_UUIDÚFileNotFoundErrorÚDMI_PRODUCT_UUIDÚlowerÚDMI_PRODUCT_SERIAL)r"   Úhypervisor_uuidÚdmi_uuidÚ
dmi_serials   &   r   Ú	is_viableÚAWSAutoAttachInstance.is_viableˆ   s™   € ð	Ü$×.Ò.Ô/JÓKˆOØ˜¨Õ,Ô,Ùð -ô ×#Ò#Ô$4Ó5×;Ñ;Ó=ˆÜ×%Ò%Ô&8Ó9×?Ñ?ÓAˆ
Ø�H˜S•MÖ4 Z°¥_Õ4Ùð 5ãøô !ô 	ñ ð	ús   ‚(B" Â"B0Â/B0c                ó    <€ V ^8„  d   QhRS[ /# r(   rB   )r   r   s   "€r   r   r   š   s   ø€ ÷ ñ ©Tñ r   c                ó   € R# )ÚUnsupportedFrg   rh   s   &r   Úshould_poll_for_pro_licenseÚ1AWSAutoAttachInstance.should_poll_for_pro_licenseš   rk   r   c                ó&   <€ V ^8„  d   QhRS[ RS[ /# )r   Úwait_for_changer)   rB   )r   r   s   "€r   r   r   ž   s   ø€ ÷ ;ñ ;¹ð ;Á$ñ ;r   c               ó,   € \         P                  ! 4       h)N)r   ÚInPlaceUpgradeNotSupportedError)r"   r�   s   &$r   Úis_pro_license_presentÚ,AWSAutoAttachInstance.is_pro_license_presentž   s   € Ü×8Ò8Ó:Ð:r   )r^   r/   )g      à?r   r   )r   r   é   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r^   r/   r$   Úpropertyr	   Úretryr   r!   r3   r?   rJ   r-   rR   ri   ry   r~   r„   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      sê   ø‡ € Ø€JØ€K÷ð ð Ø	‡Z‚Z�
×-Ñ-ºKÔH÷,ó Ió ð,ð 
‡Z‚Z�
×-Ñ-ºKÔH÷ó Iðð* ÷Ió ðIòð& 
‡Z‚Z�
×-Ñ-ºIÔFñ
ó Gð
ð0 ÷ó ðð ÷ó ð÷"ð ÷;ö ;r   r   )r8   ÚloggingÚtypingr   r   Úuaclientr   r   r   r   r	   Úuaclient.cloudsr
   ÚIMDS_IPV4_ADDRESSÚIMDS_IPV6_ADDRESSrQ   r`   r.   r7   rq   ru   rs   rb   r_   ra   Ú	getLoggerÚreplace_top_level_logger_namer‡   r;   r   rg   r   r   Ú<module>r—      s‘   ðÛ Û ß ç CÕ CÝ 9à%Ð Ø%Ð à$Ð&7Ð8€Ø0Ð Ø=€ØE€à4Ð Ø7Ð Ø3Ð àÐ Ø1Ð Ø+¨nÕ<Ð à×Ò˜×:Ò:¸8ÓDÓE€ôD;Ð9ö D;r   