/usr/lib/python3/dist-packages/uaclient/clouds/__pycache__
Edit: /usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/gcp.cpython-310.pyc (4542B)
o
Ki( @ s d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl m
Z
mZmZm
Z
mZ d dlmZ eeeZdZdZdZdZd Zd
Zdgdd
gddgddgddgdZG dd deZdS ) N)AnyDictListOptional)
exceptionshttpsecret_managersystemutil)PublicCloudAutoAttachInstancezhttp://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=contracts.canonical.com&format=full&licenses=TRUEzThttp://metadata.google.internal/computeMetadata/v1/instance/licenses/?recursive=truez&wait_for_change=truez&last_etag={etag}z/sys/class/dmi/id/product_namezGoogle Compute Engine8045211386737108299602242772471989183074270702111529466285999592893498423827818678586103571931259286680341997832016008405569084766221760544822697860254168323874790319525)xenialbionicfocaljammynoblec @ s e Zd Zdd Zeejejg ddde e
ef fddZede
fdd Z
edefd
dZdee
fdd
ZdefddZdedefddZdS )GCPAutoAttachInstancec C s
d | _ d S )Netagself r 5/usr/lib/python3/dist-packages/uaclient/clouds/gcp.py__init__% s
zGCPAutoAttachInstance.__init__)g ? r" )retry_sleepsreturnc C st t jtddidd}|jdkrtj|j d|jiS |j d}|r1d|
v r1tj|j|d tj
|j|jd
)NMetadata-FlavorGoogler" )headerstimeout
identityTokenerror_descriptionzservice account)status_code error_msg)codebody)r readurl TOKEN_URLr. r secrets
add_secretr/ json_dictgetlowerr GCPServiceAccountErrorCloudMetadataError)r response
error_descr r r identity_doc, s
z"GCPAutoAttachInstance.identity_docc C s dS )Ngcpr r r r r
cloud_type? s z GCPAutoAttachInstance.cloud_typec C s* t jtrtt}t| krdS dS )z$This machine is a viable GCPInstanceTF)ospathexistsDMI_PRODUCT_NAMEr load_fileGCP_PRODUCT_NAMEstrip)r product_namer r r is_viableC s
zGCPAutoAttachInstance.is_viablec C sN | j d }t|dd d }t|d}|di di dg S ) zGet a list of licenses from the GCP metadata.
Instance identity token (jwt) carries a list of licenses
associated with the instance itself.
Returns an empty list if licenses are not present in the metadata.
r* .r" z===zutf-8googlecompute_engine
license_id)r; base64urlsafe_b64decodesplitjsonloadsdecoder5 )r tokenidentity
identity_dictr r r get_licenses_from_identityM s
z0GCPAutoAttachInstance.get_licenses_from_identityc C s$ t j}|tvrtd dS dS )Nz0This series isn't supported for GCP auto-attach.FT)r get_release_infoseriesGCP_LICENSESLOGinfo)r rV r r r should_poll_for_pro_license^ s
z1GCPAutoAttachInstance.should_poll_for_pro_licensewait_for_changec C s t }|r|t7 }| jr|tj| jd7 }tj|ddid}|jdkrHdd |jD }|j
d| _t j
}t
|g D ] }||v rE d S q