![]() Server : Apache/2.4.52 (Ubuntu) System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 User : www-data ( 33) PHP Version : 8.1.2-1ubuntu2.21 Disable Function : NONE Directory : /lib/python3/dist-packages/uaclient/clouds/__pycache__/ |
o ��pfF � @ s� d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dl m Z mZmZm Z mZ d dlmZ e�e�e��ZdZdZdZdZd Zd Zddd ddd�ZG dd� de�ZdS )� N)�Any�Dict�List�Optional)� exceptions�http�secret_manager�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 Engine�8045211386737108299�6022427724719891830�599959289349842382�2592866803419978320�2176054482269786025)�xenial�bionic�focal�jammy�noblec @ s� e Zd Zdd� Zeejejg d�d�de e ef fdd���Zede fdd ��Z edefd d��Zdee fdd �Zdefdd�Zdedefdd�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 �?� r )�retry_sleeps�returnc C st t jtddidd�}|jdkrtj�|j� d|jiS |j� d�}|r1d|� � v r1tj|j|d ��tj |j|jd ��)N�Metadata-Flavor�Googler )�headers�timeout�� � identityToken�error_descriptionzservice account)�status_code� error_msg)�code�body)r �readurl� TOKEN_URLr* r �secrets� add_secretr+ � json_dict�get�lowerr �GCPServiceAccountError�CloudMetadataError)r �response� error_descr r r �identity_doc, s � ��z$UAAutoAttachGCPInstance.identity_docc C s dS )N�gcpr r r r r � cloud_type? s z"UAAutoAttachGCPInstance.cloud_typec C s* t j�t�rt�t�}t|�� krdS dS )z$This machine is a viable GCPInstanceTF)�os�path�exists�DMI_PRODUCT_NAMEr � load_file�GCP_PRODUCT_NAME�strip)r �product_namer r r � is_viableC 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&