| Server IP : 104.21.4.30 / Your IP : 104.23.197.109 Web Server : Apache System : Linux keen-cori.18-142-40-148.plesk.page 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 06:59:36 UTC 2025 x86_64 User : simottodesign.com_2tntp341vs7 ( 10011) PHP Version : 8.3.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/uaclient/clouds/__pycache__/ |
Upload File : |
U
2�dt � @ s� d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl m
Z
mZmZm
Z
mZ d dlmZ e�e�e��ZdZdZdZdZd Zd
Zddd
dd�ZG dd� de�ZdS )� N)�Any�Dict�List�Optional)�
exceptions�http�messages�system�util)�AutoAttachCloudInstancez�http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=contracts.canonical.com&format=full&licenses=TRUEzThttp://metadata.google.internal/computeMetadata/v1/instance/licenses/?recursive=truez&wait_for_change=truez&last_etag={etag}z/sys/class/dmi/id/product_namezGoogle Compute EngineZ8045211386737108299Z6022427724719891830Z599959289349842382Z2592866803419978320)ZxenialZbionicZfocalZjammyc @ s� e Zd Zdd� Zeejejdddgd�e e
ef d�dd���Zee
d�d d
��Z
eed�dd��Zee
d�d
d�Zed�dd�Zeed�dd�ZdS )�UAAutoAttachGCPInstancec C s
d | _ d S )N��etag��self� r �5/usr/lib/python3/dist-packages/uaclient/clouds/gcp.py�__init__$ s z UAAutoAttachGCPInstance.__init__g �?� )Zretry_sleeps)�returnc C s� t jtddidd�}|jdkr(d|jiS |j�d�}|r<|n|j}d }|rnd|�� krntj j
j|d �}tj j}t
j|||jd
��d S )N�Metadata-Flavor�Googler )�headersZtimeout�� �
identityTokenZerror_descriptionzservice account)Z error_msg)�msg�msg_code�code)r �readurl� TOKEN_URLr �bodyZ json_dict�get�lowerr Z"GCP_SERVICE_ACCT_NOT_ENABLED_ERRORr �format�namer �GCPProAccountError)r �responseZ
error_descr r r r r �identity_doc+ s( �
� �z$UAAutoAttachGCPInstance.identity_docc C s dS )NZgcpr r r r r �
cloud_type@ s z"UAAutoAttachGCPInstance.cloud_typec C s* t j�t�r&t�t�}t|�� kr&dS dS )z$This machine is a viable GCPInstanceTF)�os�path�exists�DMI_PRODUCT_NAMEr Z load_file�GCP_PRODUCT_NAME�strip)r Zproduct_namer r r � is_viableD s
z!UAAutoAttachGCPInstance.is_viablec C sN | j d }t�|�d�d d �}t�|�d��}|�di ��di ��dg �S ) z�Get a list of licenses from the GCP metadata.
Instance identity token (jwt) carries a list of licenses
associated with the instance itself.
Returns an empty list if licenses are not present in the metadata.
r �.r z===zutf-8ZgoogleZcompute_engineZ
license_id)r'