/usr/lib/python3/dist-packages/uaclient/clouds/__pycache__
Edit: /usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/aws.cpython-310.pyc (5377B)
o
Ki @ s d dl Z d dlZd dlmZmZ d dlmZmZmZm Z m
Z
d dlmZ dZ
dZe
efZdZdZd Zd
ZdZdZd
ZdZed Zee
eZG dd deZdS ) N)AnyDict)
exceptionshttpsecret_managersystemutil)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_uuid21600zX-aws-ec2-metadata-tokenz-ttl-secondsc @ s e Zd ZdZdZdefddZeej e
jg dddeee
f fdd Zej e
jg dddefd
dZedefdd
Zdd Zej e
jg dddd ZedefddZedefddZdefddZdedefddZdS )AWSAutoAttachInstanceNurlc C s2 t j||dd}|jdkr|jS tj|j|jd)N )headerstimeout codebody)r readurlr r r CloudMetadataError)selfr r response r 5/usr/lib/python3/dist-packages/uaclient/clouds/aws.py_get_imds_url_response s
z,AWSAutoAttachInstance._get_imds_url_response)g ?r
r
)retry_sleepsreturnc C s6 | }t| j}| j||d}tj| d|iS )Nr pkcs7)_request_imds_v2_token_headersIMDS_URLformat_ip_addressr r secrets
add_secret)r r r imds_url_responser r r identity_doc* s
z"AWSAutoAttachInstance.identity_docc
C sf | }t| j}z
t| j||d}W |S tjy2 } zt d| i W Y d}~S d}~ww )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" jsonloadsr JSONDecodeErrorLOGdebug)r r r ii_docer r r _get_ii_doc3 s z!AWSAutoAttachInstance._get_ii_docc C s0 | }|dd}|dd}t|pt|S )a
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.
billingProductsNmarketplaceProductCodes)r/ getbool)r r- billing_productsmarketplace_product_codesr r r
is_likely_proI s
z#AWSAutoAttachInstance.is_likely_proc C s| t D ]+}z| j|d}W n ty) } ztd|t|dd W Y d }~qd }~ww || _ | jd u r