Current File : //usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/lxd.cpython-312.pyc |
�
��g,
� � � d dl Z d dlmZmZmZmZmZmZ d dlm Z e j ej e� � Z
dZdZdZ G d� de � Zy) � N)�config�
exceptions�http�log�secret_manager�util)�AutoAttachInstancez
/dev/lxd/sockz/1.0/ubuntu-proz/1.0/ubuntu-pro/tokenc �b � e Zd Zedefd�� Zdefd�Zdedefd�Zdej de
fd�Zy) �LXDAutoAttachInstance�returnc � � y)NT� ��selfs �5/usr/lib/python3/dist-packages/uaclient/clouds/lxd.py� is_viablezLXDAutoAttachInstance.is_viable s � �� c � � y)zSYes, but only once - is_pro_license_present doesn't
support wait_for_changeTr r s r �should_poll_for_pro_licensez1LXDAutoAttachInstance.should_poll_for_pro_license s � � r �wait_for_changec �x � |rt j � �t j t dt
� }|j dk7 rAt j dt j |j |j �� �� y|j j dd� d k7 rt j d
� 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�errorr r r � json_dict�get�info)r r �resps r �is_pro_license_presentz,LXDAutoAttachInstance.is_pro_license_present s� � ���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 �� � t j t dt � }|j dk( rt j � �|j dk( rt j � �|j dk7 rDt j |j dj t t � |j �� �|j j dd� }t j j |� |S ) z{
Cloud-specific implementation of acquiring the pro token using whatever
method suits the platform
�POSTi� i� r zunix://{}{})r �urlr �guest_token� )r r! r"