%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/clouds/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/clouds/__pycache__/aws.cpython-312.pyc

�

��>f�����ddlZddlmZmZddlmZmZmZmZm	Z	ddl
mZdZdZ
ee
fZdZdZd	Zd
ZdZdZd
ZedzZej.e	j0e��ZGd�de�Zy)�N)�Any�Dict)�
exceptions�http�secret_manager�system�util)�AutoAttachCloudInstancez169.254.169.254z[fd00:ec2::254]zhttp://{}/latest/api/tokenz0http://{}/latest/dynamic/instance-identity/pkcs7z/sys/hypervisor/uuidz /sys/class/dmi/id/product_serialz/sys/class/dmi/id/product_uuid�21600zX-aws-ec2-metadata-tokenz-ttl-secondsc��eZdZdZdZd�Zeeje	jgd���deee
ffd���Zd�Zeje	jgd���d	��Zedefd
��Zedefd��Zdefd�Zd
edefd�Zy)�UAAutoAttachAWSInstanceNc��|j�}tjtj	|j
�|d��}|jdk(r|jStj|j|j���)N�)�headers�timeout����code�body)
�_request_imds_v2_token_headersr�readurl�IMDS_URL�format�_ip_addressrrr�CloudMetadataError)�selfr�responses   �5/usr/lib/python3/dist-packages/uaclient/clouds/aws.py�_get_imds_url_responsez.UAAutoAttachAWSInstance._get_imds_url_responsesl���5�5�7���<�<��O�O�D�,�,�-�w��
���=�=�C���=�=� ��/�/��]�]�����
�)g�?rr)�retry_sleeps�returnc�h�|j�}tjj|�d|iS)N�pkcs7)rr�secrets�
add_secret)r�imds_url_responses  r�identity_docz$UAAutoAttachAWSInstance.identity_doc+s4��!�7�7�9�����)�)�*;�<��*�+�+r c�,�tD]}	|j|��}||_n|j�)tjdjt����S#t$r,}tjd|t
|dd��Yd}~��d}~wwxYw)N)�
ip_addressz*Could not reach AWS IMDS at http://%s: %s
�reason�z, )�	addresses)
�IMDS_IP_ADDRESS�_get_imds_v2_token_headersr�	Exception�LOG�warning�getattrr�AWSNoValidIMDS�join)r�addressr�es    rrz6UAAutoAttachAWSInstance._request_imds_v2_token_headers2s���&�	�G�

��9�9�W�9�M��$+�� ��	����#��+�+��)�)�O�4��
�����
����A���A�x��,����
�s�A�	B�'"B�B)r��c��|jdk(ry|jrt|jiStjtj|�dttid��}|jdk(rL|j|_tjj|j�t|jiS|jdk(rd|_ytj|j|j���)N�IMDSv1�PUTr)�methodrrri�r)�
_api_token�AWS_TOKEN_PUT_HEADERrr�IMDS_V2_TOKEN_URLr�AWS_TOKEN_REQ_HEADER�AWS_TOKEN_TTL_SECONDSrrrr%r&rr)rr*rs   rr/z2UAAutoAttachAWSInstance._get_imds_v2_token_headersEs����?�?�h�&��
�_�_�(�$�/�/�:�:��<�<��$�$�Z�0��)�+@�A��	
���=�=�C��&�m�m�D�O��"�"�-�-�d�o�o�>�(�$�/�/�:�:��=�=�C��&�D�O���+�+����X�]�]�
�	
r c��y)N�aws��rs r�
cloud_typez"UAAutoAttachAWSInstance.cloud_type^���r c�.�	tjt�}d|ddk(ry	tjt�j�}tjt�j�}d|ddcxk(r|ddk(ryyy#t$rY�nwxYw)z$This machine is a viable AWSInstance�ec2r�TF)r�	load_file�SYS_HYPERVISOR_PRODUCT_UUID�FileNotFoundError�DMI_PRODUCT_UUID�lower�DMI_PRODUCT_SERIAL)r�hypervisor_uuid�dmi_uuid�
dmi_serials    r�	is_viablez!UAAutoAttachAWSInstance.is_viablebs���	�$�.�.�/J�K�O����!�,�,��-��#�#�$4�5�;�;�=���%�%�&8�9�?�?�A�
��H�Q�q�M�4�Z��!�_�4��5���!�	�
�	�s�!B�	B�Bc��y)�UnsupportedFrErFs r�should_poll_for_pro_licensez3UAAutoAttachAWSInstance.should_poll_for_pro_licensetrHr �wait_for_changec�*�tj��)N)r�InPlaceUpgradeNotSupportedError)rrYs  r�is_pro_license_presentz.UAAutoAttachAWSInstance.is_pro_license_presentxs���8�8�:�:r )�__name__�
__module__�__qualname__r>rr�propertyr	�retryrrr�strrr(rr/rG�boolrUrXr\rEr rr
r
s����J��K�
���T�Z�Z�
�-�-�K�H�,�d�3��8�n�,�I��,�
�&�T�Z�Z�
�-�-�I�F�
�G�
�0��C������4����"�T��;��;�$�;r r
)�logging�typingrr�uaclientrrrrr	�uaclient.cloudsr
�IMDS_IPV4_ADDRESS�IMDS_IPV6_ADDRESSr.r@rrMrQrOrBr?rA�	getLogger�replace_top_level_logger_namer]r1r
rEr r�<module>rls�����C�C�3�%��%��$�&7�8��0��=��4��7��3����1��+�n�<���g���:��:�:�8�D�E��`;�5�`;r 

Zerion Mini Shell 1.0