name : DataSourceCloudCIX.cpython-39.opt-1.pyc
a

'�Dg��@s�ddlZddlZddlmZddlmZmZmZmZe�	e
�ZdgZdZ
dZGdd�dej�Zed	�d
d�Zed�d
d�ZeejejffgZdd�ZdS)�N)�Optional)�dmi�sources�
url_helper�utilzhttp://169.254.169.254��CloudCIXcsleZdZdZdZdZdZ�fdd�Zdd�Ze	d�d	d
�Z
eed�dd�Z
ed
d��Zedd��Z�ZS)�DataSourceCloudCIXr��cs$tt|��|||�d|_d|_dS�N)�superr	�__init__�
_metadata_url�_net_cfg)�selfZsys_cfgZdistro�paths��	__class__��H/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudCIX.pyrszDataSourceCloudCIX.__init__c
Cs`z|��}Wn4tjy@}zt�d|�WYd}~dSd}~00|d|_t�|d�|_dS)z6
        Fetch the user data and the metadata
        z0Failed to read data from CloudCIX datasource: %sNF�	meta-data�	user-dataT)	�crawl_metadata_servicer�InvalidMetaDataException�LOG�error�metadatarZ
decode_binaryZuserdata_raw)rZcrawled_datarrrr�	_get_datas�
zDataSourceCloudCIX._get_data��returncCs,|��}|durt�d��t||���}|S)Nz Could not determine metadata URL)�determine_md_urlrr�
read_metadata�get_url_params)rZmd_url�datarrrr/s�z)DataSourceCloudCIX.crawl_metadata_servicecCs�|jr|jS|��}tjt|j|jd�\}}|s4dSttdd�D]�}t�	|d�
|�d�}ztj||jd�}Wn@tj
y�}z&t�d||�WYd}~q@WYd}~n
d}~00|��r�t�	|d�
|��|_q�q@t�d|�q@|jS)	N)Zmax_wait�timeoutr���zv{0}r)r%zURL %s raised exception %szNo metadata found at URL %s)rr#rZwait_for_url�
METADATA_URLSZmax_wait_seconds�timeout_seconds�range�METADATA_VERSION�combine_url�format�readurlZurl_timeout�UrlErrorr�debug�ok)r�
url_params�base_url�_�version�url�response�errrr!9s4�
�"
�z#DataSourceCloudCIX.determine_md_urlcCst�Sr)�is_platform_viablerrrr�	ds_detect\szDataSourceCloudCIX.ds_detectcCs(|jr|jS|jsdS|jd|_|jS)N�network)rr)rrrr�network_config`sz!DataSourceCloudCIX.network_config)�__name__�
__module__�__qualname__ZdsnameZurl_retriesZurl_timeout_secondsZurl_sec_between_retriesrr�dictrr�strr!�staticmethodr9�propertyr;�
__classcell__rrrrr	s
#
r	rcCst�d�tkS)Nzsystem-product-name)rZ
read_dmi_data�CLOUDCIX_DMI_NAMErrrrr8ksr8)r2c
Cs(i}ddtjfddtjff}|D�]\}}}z$tjt�||�|j|j|jd�}WnHtj	y�}z.t
�d|�d|�d|�d|����WYd	}~n
d	}~00|��s�t
�d
|�d|�d|�d|j
����z||j�||<Wq tjj�y }	z*t
�d
|�d|�d|	���|	�WYd	}	~	q d	}	~	00q |S)a;
    Read metadata from metadata server at base_url

    :returns: dictionary of retrieved metadata and user data containing the
              following keys: meta-data, user-data
    :param: base_url: meta data server's base URL
    :param: url_params: dictionary of URL retrieval parameters. Valid keys are
            `retries`, `sec_between` and `timeout`.
    :raises: InvalidMetadataException upon network error connecting to metadata
             URL, error response from meta data server or failure to
             decode/parse metadata and userdata payload.
    rrZuserdatar)r5ZretriesZsec_betweenr%zFailed to fetch IMDS z: �/Nz	No valid z found. URL z returned code zInvalid JSON at )rZ	load_jsonZmaybe_b64decoderr-r+Znum_retriesZsec_between_retriesr(r.rrr0�code�contents�json�decoderZJSONDecodeError)
r2r1ZmdZleaf_key_format_callbackZurl_leafZnew_keyZformat_callbackr6r�excrrrr"osR


�
�
����������r"cCst�|t�Sr)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list�srL)rHZlogging�typingrZ	cloudinitrrrrZ	getLoggerr<rr'r*rDZ
DataSourcer	�boolr8r@r"ZDEP_FILESYSTEMZDEP_NETWORKrKrLrrrr�<module>s
Z2�

© 2025 Cubjrnet7