AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/uaclient/clouds/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/uaclient/clouds/__pycache__/gcp.cpython-310.pyc
o

F��ct�@s�ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
ddlmZm
Z
mZmZddlmZe�d�ZdZdZd	Zd
ZdZdZd
dddd�ZGdd�de�ZdS)�N)�Any�Dict�List�Optional)�	HTTPError)�
exceptions�messages�system�util)�AutoAttachCloudInstancezpro.clouds.gcpz�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)�xenial�bionic�focal�jammyc@s�eZdZdd�Zeejejgd�d�de	e
effdd���Zede
fdd	��Z
edefd
d��Zdee
fdd
�Zdefdd�Zdedefdd�ZdS)�UAAutoAttachGCPInstancecCs
d|_dS)N��etag��self�r�5/usr/lib/python3/dist-packages/uaclient/clouds/gcp.py�__init__%s
z UAAutoAttachGCPInstance.__init__)g�?�r)�retry_sleeps�returnc
Cs�zddi}tjt|dd�\}}Wd
|iStyp}zQt|dd�}d}|rCz
tj|tjd�}Wnty:d}Ynw|rC|�	dd�}|rG|n|j
}d}	|r`d|��vr`tj
jj|d	�}tj
j}	tj||	t|d
d�d��d}~ww)N�Metadata-Flavor�Googler)�headers�timeout�body)�cls�error_descriptionzservice account)�	error_msg�coder)�msg�msg_coder'�
identityToken)r
�readurl�	TOKEN_URLr�getattr�json�loads�DatetimeAwareJSONDecoder�
ValueError�get�reason�lowerr�"GCP_SERVICE_ACCT_NOT_ENABLED_ERRORr(�format�namer�GCPProAccountError)
rr!�url_response�_headers�er#�
error_desc�
error_detailsr(r)rrr�identity_doc,s>��
������z$UAAutoAttachGCPInstance.identity_doccCsdS)N�gcprrrrr�
cloud_typeLsz"UAAutoAttachGCPInstance.cloud_typecCs*tj�t�rt�t�}t|��krdSdS)z$This machine is a viable GCPInstanceTF)�os�path�exists�DMI_PRODUCT_NAMEr	�	load_file�GCP_PRODUCT_NAME�strip)r�product_namerrr�	is_viablePs

z!UAAutoAttachGCPInstance.is_viablecCsN|jd}t�|�d�dd�}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*�.rz===zutf-8�google�compute_engine�
license_id)r>�base64�urlsafe_b64decode�splitr.r/�decoder2)r�token�identity�
identity_dictrrr�get_licenses_from_identityZs

�z2UAAutoAttachGCPInstance.get_licenses_from_identitycCs&t��d}|tvrt�d�dSdS)N�seriesz0This series isn't supported for GCP auto-attach.FT)r	�get_platform_info�GCP_LICENSES�LOG�info)rrVrrr�should_poll_for_pro_licenseks

z3UAAutoAttachGCPInstance.should_poll_for_pro_license�wait_for_changec
Cs�t}|r|t7}|jr|tj|jd�7}z
tj|ddid�\}}Wnty?}zt�	|�|j
dkr7t���t�
��d}~wwdd�|D�}|�dd�|_t��d	}t�|�|vS)
Nrrr )r!i�cSsg|]}|d�qS)�idr)�.0�licenserrr�
<listcomp>�szBUAAutoAttachGCPInstance.is_pro_license_present.<locals>.<listcomp>�ETagrV)�LICENSES_URL�WAIT_FOR_CHANGEr�	LAST_ETAGr6r
r+rrY�errorr'r�CancelProLicensePolling�DelayProLicensePollingr2r	rWrX)rr\�url�licensesr!r;�license_idsrVrrr�is_pro_license_presentrs(�

��z.UAAutoAttachGCPInstance.is_pro_license_presentN)�__name__�
__module__�__qualname__r�propertyr
�retryrr8r�strrr>r@�boolrIrrUr[rkrrrrr$s	r)rNr.�loggingrA�typingrrrr�urllib.errorr�uaclientrrr	r
�uaclient.cloudsr�	getLoggerrYr,rbrcrdrDrFrXrrrrr�<module>s.
���

Anon7 - 2022
AnonSec Team