�
�Hcf. � � � d dl mZmZmZmZ d dlmZmZmZm Z m
Z
d dlmZm
Z
d dlmZ d dlmZmZ d dlmZ ej* � Z G d� de� Zy )
� )�Any�Dict�Optional�Tuple)�api�contract�event_logger�messages�system)�CanEnableFailure�CanEnableFailureReason)�RepoEntitlement)�AnboxCloudData�anbox_cloud_credentials_file)�MessagingOperationsDictc �F � � e Zd ZdZej
Zej Zej j Zej Z
dZdZdZdZdZedefd�� Zdeeee f f� fd�Zd ej8 def� fd
�Zd ej8 f� fd�Zdee e!f d
ee defd�Z"� xZ#S )�AnboxEntitlementzanbox-cloudzubuntu-pro-anbox-cloud.gpgz{}T�Anbox�returnc �D � | j sdt j giS i S )N�post_enable)�access_onlyr
�ANBOX_RUN_INIT_CMD)�selfs �=/usr/lib/python3/dist-packages/uaclient/entitlements/anbox.py� messagingzAnboxEntitlement.messaging s$ � ����!�H�$?�$?�#@�A�A��I� c �� �� t �| � � \ }}|s||fS t j � r6| j s*dt t j t j � fS y)NF)TN)
�super�
can_enabler �is_containerr r r
�ONLY_ACCESS_ONLY_SUPPORTEDr
�!ANBOX_FAIL_TO_ENABLE_ON_CONTAINER)r �ret�reason� __class__s �r r zAnboxEntitlement.can_enable% sa �� ��g�(�*���V����;����� ��)9�)9�� �*�E�E��>�>���
� r �progressc � �� t �| � |� }|s|S | j j di � j di � }| j j
d }t
j | j � }|j |d� }t |j di � j di � j dd� |j dd� |j dd� |j d d� �
� }t j |� y)N�entitlement�
directives�machineTokenzanbox-images�url� �
resourceToken�aptURL�aptKey)�anbox_images_url�anbox_images_resource_token�anbox_cloud_apt_url�anbox_cloud_apt_tokenT)r �_perform_enable�entitlement_cfg�get�cfg�
machine_tokenr �UAContractClient�get_resource_machine_accessr r �write) r r' |