HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/uaclient/clouds/__pycache__/lxd.cpython-38.pyc
U

��Jh,
�@sdddlZddlmZmZmZmZmZmZddlm	Z	e�
e�e��Z
dZdZdZGdd�de	�ZdS)	�N)�config�
exceptions�http�log�secret_manager�util)�AutoAttachInstancez
/dev/lxd/sockz/1.0/ubuntu-proz/1.0/ubuntu-pro/tokenc@sNeZdZeed�dd��Zed�dd�Zeed�dd�Zej	e
d	�d
d�ZdS)
�LXDAutoAttachInstance)�returncCsdS)NT���selfrr�5/usr/lib/python3/dist-packages/uaclient/clouds/lxd.py�	is_viableszLXDAutoAttachInstance.is_viablecCsdS)zSYes, but only once - is_pro_license_present doesn't
        support wait_for_changeTrrrrr�should_poll_for_pro_licensesz1LXDAutoAttachInstance.should_poll_for_pro_license)�wait_for_changer
cCsh|rt���t�tdt�}|jdkrDtjdt	j
|j|jd�d�dS|j�
dd�d	krdt�d
�dSdS)NZGET��z4LXD instance API returned error for ubuntu-pro query)�code�body)�extraFZguest_attachZoffZonzNguest_attach config is not turned on. The machine will not try to auto-attach.T)rZCancelProLicensePollingr�unix_socket_request�LXD_INSTANCE_API_SOCKET_PATH�$LXD_INSTANCE_API_ENDPOINT_UBUNTU_PROr�LOG�errorrrr�	json_dict�get�info)r
r�resprrr�is_pro_license_presents&�
��z,LXDAutoAttachInstance.is_pro_license_present)�cfgr
cCszt�tdt�}|jdkr"t���n:|jdkr6t���n&|jdkr\tj|jd�	tt�|j
d��|j�dd�}t
j�|�|S)	z{
        Cloud-specific implementation of acquiring the pro token using whatever
        method suits the platform
        ZPOSTi�i�rzunix://{}{})rZurlr�guest_token�)rrr�0LXD_INSTANCE_API_ENDPOINT_UBUNTU_PRO_GUEST_TOKENrrZLXDAutoAttachNotAvailableZLXDAutoAttachNotAllowedZExternalAPIError�formatrrrrZsecretsZ
add_secret)r
r rr!rrr�acquire_pro_token1s*�




��z'LXDAutoAttachInstance.acquire_pro_tokenN)�__name__�
__module__�__qualname__�property�boolrrrrZUAConfig�strr%rrrrr	
s
r	)ZloggingZuaclientrrrrrrZuaclient.cloudsrZ	getLoggerZreplace_top_level_logger_namer&rrrr#r	rrrr�<module>s