HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceExoscale.cpython-38.pyc
U

Ӈg~"�@s^ddlZddlmZmZmZmZmZmZddlm	Z	e�
e�ZdZ
dZdZdZdZd	ZGd
d�dej�ZeejejffgZdd
�Ze
eeeefdd�Ze
eeeefdd�Zedk�rZddlZejdd�Zejddde
d�ejddded�ejddeded�ejd ded!ed�ejd"d#ed$ed�e� �Z!ee!j"e!j#e!j$e!j%e!j&d%�Z'e(e�)e'��dS)&�N)�
atomic_helper�dmi�helpers�sources�
url_helper�util)�ec2zhttp://169.254.169.254z1.0i��
��ExoscalecsXeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
edd��Z�Z
S)�DataSourceExoscaler�xcs|tt|��|||�t�d�|j�dt�|_|j�dt	�|_
t|j�dt��|_
|j�dt�|_|j�dt�|_i|_dS)Nz$Initializing the Exoscale datasource�metadata_url�api_version�password_server_port�timeout�retries)�superr�__init__�LOG�debugZds_cfg�get�METADATA_URLr�API_VERSIONr�int�PASSWORD_SERVER_PORTr�URL_TIMEOUT�url_timeout�URL_RETRIES�url_retries�extra_config)�selfZsys_cfgZdistro�paths��	__class__��F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceExoscale.pyrs
�zDataSourceExoscale.__init__cCs8d}|j�d�}t�|�}|�d|d�r4t�d�dS)z<Adjust set_passwords module to run 'always' during each bootZ
set_passwordsZsemZconfig_Nz5Overriding module set_passwords with frequency always)r"Z
get_ipath_currZFileSemaphores�clearrr)r!ZcfgZis_new_instance�modZsem_pathZ
sem_helperr%r%r&�activate*s
	
zDataSourceExoscale.activatecCs6d�|j|j�}tj|g|j|jtjd�\}}t	|�S)z.Wait for the metadata service to be reachable.z{}/{}/meta-data/instance-id)ZurlsZmax_waitrZ	status_cb)
�formatrrrZwait_for_url�url_max_waitrrZcritical�bool)r!rZurlZ	_responser%r%r&�wait_for_metadata_service9s��
z,DataSourceExoscale.wait_for_metadata_servicecCs4|��}|st�d�iSt|j|j|j|j|j�S)zw
        Crawl the metadata service when available.

        @returns: Dictionary of crawled metadata content.
        z,Unable to get response from metadata service)	r-r�error�
read_metadatarrrrr)r!Zmetadata_readyr%r%r&�crawl_metadataIs
�z!DataSourceExoscale.crawl_metadatacCs\|��}|sdS|d|_|d|_|�d�}i}|rFd|ddid�}t�|j|g�|_dS)z�Fetch the user data, the metadata and the VM password
        from the metadata service.

        Please refer to the datasource documentation for details on how the
        metadata server and password server are crawled.
        F�	user-data�	meta-data�passwordTZexpire)Z
ssh_pwauthr3Zchpasswd)r0Zuserdata_rawZmetadatarrZ
mergemanydictr )r!�datar3Zpassword_configr%r%r&�	_get_data]s$


��	�zDataSourceExoscale._get_datacCs|jS�N)r )r!r%r%r&�get_config_obj�sz!DataSourceExoscale.get_config_objcCst�d��t�S)Nzsystem-product-name)rZ
read_dmi_data�
startswith�EXOSCALE_DMI_NAMEr%r%r%r&�	ds_detect�s
�zDataSourceExoscale.ds_detect)�__name__�
__module__�__qualname__Zdsnamer+rr)r-r0r5r7�staticmethodr:�
__classcell__r%r%r#r&rs
'rcCst�|t�Sr6)rZlist_from_depends�datasources)Zdependsr%r%r&�get_datasource_list�srAcCsZd�|||�}tj|dddi||d�}|j�d�}|dkr>dStj|dddi||d�|S)	z�Obtain the VM's password if set.

    Once fetched the password is marked saved. Future calls to this method may
    return empty string or 'saved_password'.z	{}:{}/{}/NZDomU_RequestZsend_my_password)Zssl_detailsZheadersrrzutf-8)��saved_passwordrC)r*rZread_file_or_url�contents�decode)rrrrrZpassword_urlZresponser3r%r%r&�get_password�s.���rFc
Cs�i}||d<z0tj||||d�|d<tj||||d�|d<Wn:tk
rv}zt�td||�iWY�Sd}~XYnXzt|||||d�|d<Wn4tk
r�}zt�td	|||�W5d}~XYnX|S)
z8Query the metadata server and return the retrieved data.Z_metadata_api_version)rrr1r2z(failed reading from metadata url %s (%s)N)rrrrrr3z2failed to read from password server url %s:%s (%s))rZget_instance_userdataZget_instance_metadata�	ExceptionrZlogexcrrF)rrrrrZcrawled_metadata�er%r%r&r/�sP�
����r/�__main__zQuery Exoscale Metadata)Zdescriptionz
--endpointZURLz The url of the metadata service.)�metavar�help�defaultz	--versionZVERSIONz.The version of the metadata endpoint to query.z	--retriesZNUMz,The number of retries querying the endpoint.)rJ�typerKrLz	--timeoutz.The time in seconds to wait before timing out.z--password-portZPORTz/The port on which the password endpoint listens)rrrrr)*ZloggingZ	cloudinitrrrrrrZcloudinit.sources.helpersrZ	getLoggerr;rrrrrrr9Z
DataSourcerZDEP_FILESYSTEMZDEP_NETWORKr@rArFr/�argparse�ArgumentParser�parser�add_argumentr�
parse_args�argsZendpoint�versionZ
password_portrrr4�printZ
json_dumpsr%r%r%r&�<module>s� 
y��
'�
+
������