Current File : //usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/aws.cpython-312.pyc |
�
��g� � �� � d dl Z d dlZd dlmZmZ d dlmZmZmZm Z m
Z
d dlmZ dZ
dZe
efZdZdZd Zd
ZdZdZd
ZdZedz Z ej2 e
j4 e� � Z G d� de� Zy)� N)�Any�Dict)�
exceptions�http�secret_manager�system�util)�PublicCloudAutoAttachInstancez169.254.169.254z[fd00:ec2::254]zhttp://{}/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�21600zX-aws-ec2-metadata-tokenz-ttl-secondsc � � e Zd ZdZdZdefd�Ze ej e
j g d��� deee
f fd�� � Z ej e
j g d��� defd�� Zedefd �� Zd
� Z ej e
j g d��� d� � Zedefd
�� Zedefd�� Zdefd�Zdedefd�Zy)�AWSAutoAttachInstanceN�urlc � � t j ||d�� }|j dk( r|j S t j
|j |j �� �)N� )�headers�timeout�� ��code�body)r �readurlr r r �CloudMetadataError)�selfr r �responses �5/usr/lib/python3/dist-packages/uaclient/clouds/aws.py�_get_imds_url_responsez,AWSAutoAttachInstance._get_imds_url_response sJ � ��<�<��W�a�@���=�=�C���=�=� ��/�/��]�]�����
� )g �?r r )�retry_sleeps�returnc �� � | j � }t j | j � }| j ||�� }t
j j |� d|iS )N�r �pkcs7)�_request_imds_v2_token_headers�IMDS_URL�format�_ip_addressr r �secrets�
add_secret)r r r �imds_url_responses r �identity_docz"AWSAutoAttachInstance.identity_doc* s] � � �5�5�7���o�o�d�.�.�/�� �7�7��W�7�M�����)�)�*;�<��*�+�+r c �" � | j � }t j | j � } t j
| j
||�� � }|S # t j $ r"}t j d|� i cY d}~S d}~ww xY w)a
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&