Current File : //usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/lxd.cpython-312.pyc
�

��g,
���ddlZddlmZmZmZmZmZmZddlm	Z	ejeje��Z
dZdZdZGd�de	�Zy)	�N)�config�
exceptions�http�log�secret_manager�util)�AutoAttachInstancez
/dev/lxd/sockz/1.0/ubuntu-proz/1.0/ubuntu-pro/tokenc�b�eZdZedefd��Zdefd�Zdedefd�Zdejde
fd�Zy)	�LXDAutoAttachInstance�returnc��y)NT���selfs �5/usr/lib/python3/dist-packages/uaclient/clouds/lxd.py�	is_viablezLXDAutoAttachInstance.is_viables���c��y)zSYes, but only once - is_pro_license_present doesn't
        support wait_for_changeTrrs r�should_poll_for_pro_licensez1LXDAutoAttachInstance.should_poll_for_pro_licenses��r�wait_for_changec�x�|rtj��tjtdt
�}|jdk7rAtjdtj|j|j����y|jjdd�d	k7rtjd
�yy)N�GET��z4LXD instance API returned error for ubuntu-pro query)�code�body)�extraF�guest_attach�off�onzNguest_attach config is not turned on. The machine will not try to auto-attach.T)r�CancelProLicensePollingr�unix_socket_request�LXD_INSTANCE_API_SOCKET_PATH�$LXD_INSTANCE_API_ENDPOINT_UBUNTU_PROr�LOG�errorrrr�	json_dict�get�info)rr�resps   r�is_pro_license_presentz,LXDAutoAttachInstance.is_pro_license_presents�����4�4�6�6��'�'�(��0�
��
�9�9����I�I�F��i�i�T�Y�Y�T�Y�Y�?�
�
���>�>���n�e�4��<��H�H�`�
��r�cfgc���tjtdt�}|jdk(rtj��|jdk(rtj��|jdk7rDtj|jdjtt�|j���|jjdd�}tjj|�|S)	z{
        Cloud-specific implementation of acquiring the pro token using whatever
        method suits the platform
        �POSTi�i�rzunix://{}{})r�urlr�guest_token�)rr!r"�0LXD_INSTANCE_API_ENDPOINT_UBUNTU_PRO_GUEST_TOKENrr�LXDAutoAttachNotAvailable�LXDAutoAttachNotAllowed�ExternalAPIError�formatrr&r'r�secrets�
add_secret)rr+r)r/s    r�acquire_pro_tokenz'LXDAutoAttachInstance.acquire_pro_token1s���
�'�'�(��<�
��
�9�9����6�6�8�8�
�Y�Y�#�
��4�4�6�6�
�Y�Y�#�
��-�-��Y�Y�!�(�(�0�D���Y�Y�
�
��n�n�(�(���;�����)�)�+�6��rN)�__name__�
__module__�__qualname__�property�boolrrr*r�UAConfig�strr8rrrrr
sQ��
��4�����T��
���$��4�V�_�_���rr)�logging�uaclientrrrrrr�uaclient.cloudsr	�	getLogger�replace_top_level_logger_namer9r$r"r#r1rrrr�<module>rEsP���H�H�.��g���:��:�:�8�D�E��.��'8�$�3J�0�=�.�=r