%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__/gcp.cpython-312.pyc

�

��>fF����ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
mZmZm
Z
mZddlmZej"ej$e��ZdZdZdZdZd	Zd
Zddd
ddd�ZGd�de�Zy)�N)�Any�Dict�List�Optional)�
exceptions�http�secret_manager�system�util)�AutoAttachCloudInstancez�http://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 Engine�8045211386737108299�6022427724719891830�599959289349842382�2592866803419978320�2176054482269786025)�xenial�bionic�focal�jammy�noblec���eZdZd�Zeejejgd���de	e
effd���Zede
fd��Z
edefd��Zdee
fd�Zdefd	�Zd
edefd�Zy)
�UAAutoAttachGCPInstancec��d|_y)N��etag��selfs �5/usr/lib/python3/dist-packages/uaclient/clouds/gcp.py�__init__z UAAutoAttachGCPInstance.__init__%s����	�)g�?�r!)�retry_sleeps�returnc��tjtddid��}|jdk(r7tj
j
|j�d|jiS|jjd�}|r3d|j�vr!tj|j|�	��tj|j|j�
��)N�Metadata-Flavor�Googler!)�headers�timeout���
identityToken�error_descriptionzservice account)�status_code�	error_msg)�code�body)r�readurl�	TOKEN_URLr.r	�secrets�
add_secretr/�	json_dict�get�lowerr�GCPServiceAccountError�CloudMetadataError)r�response�
error_descs   r�identity_docz$UAAutoAttachGCPInstance.identity_doc,s����<�<�� 1�8�<�a�
���=�=�C���"�"�-�-�h�m�m�<�#�X�]�]�3�3��'�'�+�+�,?�@�
��+�z�/?�/?�/A�A��3�3�$�M�M�Z��
��+�+����X�]�]�
�	
r c��y)N�gcp�rs r�
cloud_typez"UAAutoAttachGCPInstance.cloud_type?s��r c��tjjt�r1t	j
t�}t|j�k(ryy)z$This machine is a viable GCPInstanceTF)�os�path�exists�DMI_PRODUCT_NAMEr
�	load_file�GCP_PRODUCT_NAME�strip)r�product_names  r�	is_viablez!UAAutoAttachGCPInstance.is_viableCs=���7�7�>�>�*�+�!�+�+�,<�=�L��<�#5�#5�#7�7��r c� �|jd}tj|jd�ddz�}t	j
|j
d��}|jdi�jdi�jdg�S)	z�Get 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-8�google�compute_engine�
license_id)r;�base64�urlsafe_b64decode�split�json�loads�decoder5)r�token�identity�
identity_dicts    r�get_licenses_from_identityz2UAAutoAttachGCPInstance.get_licenses_from_identityMs|���!�!�/�2���+�+�E�K�K��,<�Q�,?�%�,G�H���
�
�8�?�?�7�#;�<�
����h��+�
�S�!�2�
&�
�S��r�
"�	
r c�|�tj�j}|tvrtjd�yy)Nz0This series isn't supported for GCP auto-attach.FT)r
�get_release_info�series�GCP_LICENSES�LOG�info)rr[s  r�should_poll_for_pro_licensez3UAAutoAttachGCPInstance.should_poll_for_pro_license^s1���(�(�*�1�1����%��H�H�G�H��r �wait_for_changec�j�t}|r8|tz
}|jr#|tj	|j��z
}tj|ddi��}|jdk(rq|jD�cgc]}|d��	}}|jjd�|_tj�j}tj|�|vStj!|j"�|jdk(rt%j&��t%j(��cc}w)	Nrr%r&)r'r)�idri�)�LICENSES_URL�WAIT_FOR_CHANGEr�	LAST_ETAG�formatrr0r.�	json_listr'r5r
rZr[r\r]�errorr/r�CancelProLicensePolling�DelayProLicensePolling)rr`�urlr9�license�license_idsr[s       r�is_pro_license_presentz.UAAutoAttachGCPInstance.is_pro_license_presentes�������?�"�C��y�y��y�'�'�T�Y�Y�'�7�7���<�<��.?��-J�K���=�=�C��8@�8J�8J�K�W�7�4�=�K�K�K� �(�(�,�,�V�4�D�I��,�,�.�5�5�F��#�#�F�+�{�:�:��	�	�(�-�-� ��=�=�C���4�4�6�6��3�3�5�5��Ls�7D0N)�__name__�
__module__�__qualname__r�propertyr�retryrr8r�strrr;r?�boolrIrrXr_rnr>r rrr$s������T�Z�Z�
�-�-�K�H�
�d�3��8�n�
�I��
�"��C������4����
�D��I�
�"�T��6��6�$�6r r)rOrR�loggingrA�typingrrrr�uaclientrrr	r
r�uaclient.cloudsr�	getLogger�replace_top_level_logger_nameror]r1rcrdrerDrFr\rr>r r�<module>r|s���
���	�,�,�C�C�3��g���:��:�:�8�D�E�� �
��
�*���	�3��*��$�#�
!�
"�
"���T6�5�T6r 

Zerion Mini Shell 1.0