| Current Path : /usr/lib/python3/dist-packages/uaclient/__pycache__/ |
| Current File : //usr/lib/python3/dist-packages/uaclient/__pycache__/contract.cpython-38.pyc |
U
8�-d�m � @ s� d dl Z d dlZd dlmZmZmZmZmZ d dlm Z m
Z
mZmZm
Z
mZmZ d dlmZ d dlmZ d dlmZ dZdZd Zd
ZdZdZd
ZdZdddd�Ze
�� Z G dd� de
j!�Z"d4eee#ef ee#ef e$e$dd�dd�Z%d5eee#ef ee#ef e$e$eee$f d�dd�Z&ej'ej(d�dd�Z)d6ee# d �d!d"�Z*eee d#�d$d%�Z+ee#ee#ef d&�d'd(�Z,ee$d#�d)d*�Z-ee#e#f ee#e#f e.d+�d,d-�Z/ee#ef e#e#ee.ee#ef f d.�d/d0�Z0d7ee#ef ee# dd1�d2d3�Z1dS )8� N)�Any�Dict�List�Optional�Tuple)�clouds�event_logger�
exceptions�messages�
serviceclient�system�util)�UAConfig)�ATTACH_FAIL_DATE_FORMAT)�UserFacingStatusz/v1/context/machines/tokenz3/v1/contracts/{contract}/context/machines/{machine}z
/v1/resourcesz3/v1/resources/{resource}/context/machines/{machine}z/v1/clouds/{cloud_type}/tokenz3/v1/contracts/{contract}/machine-activity/{machine}z/v1/contractz/v1/magic-attach� � � )�series_overrides�series�cloudc @ s� e Zd ZdZejZeje j
dddgd�d/dd��Zee
ef d�d d
�Ze
ee
ef d�dd
�Zeje j
dddgd�ejd�dd��Zd0e
e
ee
ee
ef d�dd�Zd1e
e
ee
ed�dd�Zdd� Ze
ee
ef d�dd�Zee
ef d�dd�Ze
d�dd �Zd2e
e
ee
ee
ef d�d!d"�Zd3e
e
ee
ed�d#d$�Zee
ef d%�d&d'�Zd(d)� Zd*d+� Zd4ee
d,�d-d.�Z dS )5�UAContractClientZcontract_urlr r )Zretry_sleepsNc C s~ | � � }|�dd�|�i� | �|�}| jt||d�\}}| jj�|� t j
�� |�di ��d|�d��}| j�
d|� |S )a} Requests machine attach to the provided machine_id.
@param contract_token: Token string providing authentication to
ContractBearer service endpoint.
@param machine_id: Optional unique system machine id. When absent,
contents of /etc/machine-id will be used.
@return: Dict of the JSON response containing the machine-token.
�
Authorization� Bearer {})�data�headers�machineTokenInfo� machineId�
machine-id)r �update�format�_get_platform_data�request_url�API_V1_CONTEXT_MACHINE_TOKEN�cfg�machine_token_file�writer �get_machine_id�cache_clear�get�write_cache)�self�contract_token�
machine_idr r �
machine_token�_headers� r0 �3/usr/lib/python3/dist-packages/uaclient/contract.py�request_contract_machine_attach* s
�
�z0UAContractClient.request_contract_machine_attach)�returnc C s | j t| �� d�\}}|S )z=Requests list of entitlements available to this machine type.)�query_params)r"