%PDF- %PDF-
Direktori : /lib/python3/dist-packages/uaclient/clouds/__pycache__/ |
Current File : //lib/python3/dist-packages/uaclient/clouds/__pycache__/aws.cpython-312.pyc |
� ��>f� � �� � d dl Z d dlmZmZ d dlmZmZmZmZm Z d dl mZ dZdZ ee fZdZdZd Zd ZdZdZd Zedz Z e j. e j0 e� � Z G d� 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 � � e Zd ZdZdZd� Ze ej e j g d��� deee f fd�� � Zd� Z ej e j g d��� d � � Zedefd �� Zedefd�� Zdefd�Zd edefd�Zy)�UAAutoAttachAWSInstanceNc � � | j � }t j t j | j � |d�� }|j dk( r|j S t j |j |j �� �)N� )�headers�timeout�� ��code�body) �_request_imds_v2_token_headersr �readurl�IMDS_URL�format�_ip_addressr r r �CloudMetadataError)�selfr �responses �5/usr/lib/python3/dist-packages/uaclient/clouds/aws.py�_get_imds_url_responsez.UAAutoAttachAWSInstance._get_imds_url_response sl � ��5�5�7���<�<��O�O�D�,�,�-�w�� �� �=�=�C���=�=� ��/�/��]�]����� � )g �?r r )�retry_sleeps�returnc �h � | j � }t j j |� d|iS )N�pkcs7)r r �secrets� add_secret)r �imds_url_responses r �identity_docz$UAAutoAttachAWSInstance.identity_doc+ s4 � � !�7�7�9�����)�)�*;�<��*�+�+r c �, � t D ] } | j |�� }|| _ n | j �)t j dj t � �� �S # t $ r,}t j d|t |dd� � Y d }~��d }~ww xY w)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 r r z6UAAutoAttachAWSInstance._request_imds_v2_token_headers2 s� � �&� �G� ��9�9�W�9�M�� $+�� �� � ���#��+�+��)�)�O�4�� � ��� � ����A���A�x��,�� �� �s �A� B�'"B�B)r � � c � � | j dk( ry | j rt | j iS t j t j |� dt t id�� }|j dk( rL|j | _ t j j | j � t | j iS |j dk( rd| _ y t j |j |j �� �)N�IMDSv1�PUTr )�methodr r r i� r )� _api_token�AWS_TOKEN_PUT_HEADERr r �IMDS_V2_TOKEN_URLr �AWS_TOKEN_REQ_HEADER�AWS_TOKEN_TTL_SECONDSr r r r% r&