Current File : //usr/lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceCloudCIX.cpython-312.pyc
�

Ӈg�����ddlZddlZddlmZddlmZmZmZmZeje
�ZdgZdZ
dZGd�dej�Zd	efd
�Zdefd�Zeej*ej,ffgZd
�Zy)�N)�Optional)�dmi�sources�
url_helper�utilzhttp://169.254.169.254��CloudCIXc�r��eZdZdZdZdZdZ�fd�Zd�Zde	fd�Z
deefd�Z
ed	��Zed
��Z�xZS)�DataSourceCloudCIXr	��c�L��tt|�|||�d|_d|_y�N)�superr�__init__�
_metadata_url�_net_cfg)�self�sys_cfg�distro�paths�	__class__s    ��F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceCloudCIX.pyrzDataSourceCloudCIX.__init__s&���
� �$�0��&�%�H�!�����
�c���	|j�}|d|_t
j|d�|_y#tj$r }tj	d|�Yd}~yd}~wwxYw)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�metadatar�
decode_binary�userdata_raw)r�crawled_datar!s   r�	_get_datazDataSourceCloudCIX._get_datasl��	��6�6�8�L�%�[�1��
� �.�.�|�K�/H�I������/�/�	��I�I�B�E�
���		�s�:�A-�
A(�(A-�returnc��|j�}|�tjd��t||j	��}|S)Nz Could not determine metadata URL)�determine_md_urlrr�
read_metadata�get_url_params)r�md_url�datas   rrz)DataSourceCloudCIX.crawl_metadata_service/sG���&�&�(���>��2�2�2��
��V�T�%8�%8�%:�;���rc��|jr|jS|j�}tjt|j
|j��\}}|syttdd�D]�}tj|dj|�d�}	tj||j��}|j!�r7tj|dj|��|_|jStjd|���|jS#tj$r!}tjd||�Yd}~��d}~wwxYw)	N)�max_wait�timeoutr���zv{0}r")r0zURL %s raised exception %szNo metadata found at URL %s)rr+r�wait_for_url�
METADATA_URLS�max_wait_seconds�timeout_seconds�range�METADATA_VERSION�combine_url�format�readurl�url_timeout�UrlErrorr �debug�ok)r�
url_params�base_url�_�version�url�response�es        rr)z#DataSourceCloudCIX.determine_md_url9s:������%�%�%��(�(�*�
� �-�-���0�0��.�.�
���!�
���-�q�"�5�	>�G��(�(��&�-�-��0�*��C�
�%�-�-�c�4�;K�;K�L��
�{�{�}�%/�%;�%;��f�m�m�G�4�&��"���!�!�!��	�	�7��=�!	>�$�!�!�!���&�&�
��	�	�6��Q�?���
�s�!D&�&E�9E�Ec��t�Sr)�is_platform_viable�rr�	ds_detectzDataSourceCloudCIX.ds_detect\s��!�#�#rc��|jr|jS|jsy|jd|_|jS)N�network)rr")rs r�network_configz!DataSourceCloudCIX.network_config`s7���=�=��=�=� ��}�}���
�
�i�0��
��}�}�r)�__name__�
__module__�__qualname__�dsname�url_retries�url_timeout_seconds�url_sec_between_retriesrr&�dictrr�strr)�staticmethodrI�propertyrL�
__classcell__)rs@rrrsh���
�F��K������
�"���!"�(�3�-�!"�F�$��$����rrr'c�:�tjd�tk(S)Nzsystem-product-name)r�
read_dmi_data�CLOUDCIX_DMI_NAMErHrrrGrGks�����2�3�7H�H�Hrr@c��i}ddtjfddtjff}|D]�\}}}	tjtj
||�|j|j|j��}|j�s+tjd
|�d|�d|�d|j����	||j�||<��|S#tj$r&}tjd|�d|�d|�d|����d	}~wwxYw#tj j"$r$}	tjd
|�d|�d|	���|	�d	}	~	wwxYw)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.
    r"r�userdatar)rC�retries�sec_betweenr0zFailed to fetch IMDS z: �/Nz	No valid z found. URL z returned code zInvalid JSON at )r�	load_json�maybe_b64decoderr:r8�num_retries�sec_between_retriesr5r<rrr>�code�contents�json�decoder�JSONDecodeError)
r@r?�md�leaf_key_format_callback�url_leaf�new_key�format_callbackrDr!�excs
          rr*r*os~��
�B�	�[�$�.�.�1�	�[�$�"6�"6�7� ��
/G��*��'�?�	�!�)�)��*�*�8�X�>�"�.�.�&�:�:�"�2�2�	�H��{�{�}��2�2��H�:�&��j��(��?�8�=�=�/�K��
�
	�)�(�*;�*;�<�B�w�K�+�4�I��%�"�"�	��2�2�'��z���*�A�h�Z�r�%��2��
��	���|�|�+�+�	��2�2�"�8�*�A�h�Z�r�#��?���
��	�s0�AC�:D�D�&!D�D�E�,E�Ec�6�tj|t�Sr)r�list_from_depends�datasources)�dependss r�get_datasource_listrt�s���$�$�W�k�:�:r)rg�logging�typingr�	cloudinitrrrr�	getLoggerrMr r3r7r[�
DataSourcer�boolrGrUr*�DEP_FILESYSTEM�DEP_NETWORKrrrtrHrr�<module>r}s������4�4��g����!��)�*�
�����W��+�+�W�tI�D�I�-�C�-�d�'�0�0�'�2E�2E�F�G���;r