관리-도구
편집 파일: DataSourceCloudCIX.cpython-39.pyc
a ����'�Dg�����������������������@���s����d�dl�Z�d�dlZd�dlmZ�d�dlmZmZmZmZ�e� e �ZdgZdZ dZG�dd��dej�Zed �d d�Zed�d d�ZeejejffgZdd��ZdS�)�����N)�Optional)�dmi�sources� url_helper�utilzhttp://169.254.169.254�����CloudCIXc�����������������������sl���e�Zd�ZdZdZdZdZ��fdd�Zdd��Ze d�d d �Z ee�d�dd�Z ed d���Zedd���Z���ZS�)�DataSourceCloudCIXr�����������c��������������������s$���t�t|���|||��d�|�_d�|�_d�S��N)�superr ����__init__� _metadata_url�_net_cfg)�selfZsys_cfgZdistro�paths�� __class__���H/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudCIX.pyr������s����zDataSourceCloudCIX.__init__c�������������� ���C���s`���z|�����}W�n4�tjy@�}�zt�d|��W�Y�d}~dS�d}~0�0�|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�metadatar���Z decode_binaryZuserdata_raw)r���Zcrawled_datar���r���r���r���� _get_data���s����� zDataSourceCloudCIX._get_data��returnc�����������������C���s,���|�����}|d�u�rt�d��t||�����}|S�)Nz Could not determine metadata URL)�determine_md_urlr���r���� read_metadata�get_url_params)r���Zmd_url�datar���r���r���r���/���s�����z)DataSourceCloudCIX.crawl_metadata_servicec�����������������C���s����|�j�r|�j�S�|����}tjt|j|jd�\}}|s4d�S�ttdd�D�]�}t� |d� |�d�}ztj||�jd�}W�n@�tj y��}�z&t�d||��W�Y�d�}~q@W�Y�d�}~n d�}~0�0�|���r�t� |d� |��|�_��q�q@t�d|��q@|�j�S�) N)Zmax_wait�timeoutr������zv{0}r���)r%���zURL %s raised exception %szNo metadata found at URL %s)r���r#���r���Zwait_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�er���r���r���r!���9���s4����� �" �z#DataSourceCloudCIX.determine_md_urlc�������������������C���s���t���S�r���)�is_platform_viabler���r���r���r���� ds_detect\���s����zDataSourceCloudCIX.ds_detectc�����������������C���s(���|�j�r|�j�S�|�jsd�S�|�jd�|�_�|�j�S�)N�network)r���r���)r���r���r���r����network_config`���s����z!DataSourceCloudCIX.network_config)�__name__� __module__�__qualname__ZdsnameZurl_retriesZurl_timeout_secondsZurl_sec_between_retriesr���r����dictr���r����strr!����staticmethodr9����propertyr;���� __classcell__r���r���r���r���r ������s��� # r ���r���c�������������������C���s���t��d�tkS�)Nzsystem-product-name)r���Z read_dmi_data�CLOUDCIX_DMI_NAMEr���r���r���r���r8���k���s����r8���)r2���c����������� ������C���s(��i�}ddt�jfddt�jff}|D��]�\}}}z$tjt�|�|�|j|j|jd�}W�nH�tj y��}�z.t �d|��d|���d|��d|�����W�Y�d }~n d }~0�0�|���s�t �d |��d|���d|��d|j �����z||j�||<�W�q �tjj�y �} �z*t �d |���d|��d| ����| �W�Y�d } ~ q d } ~ 0�0�q |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. r���r���Zuserdatar���)r5���ZretriesZsec_betweenr%���zFailed to fetch IMDS z: �/Nz No valid z found. URL z returned code zInvalid JSON at )r���Z load_jsonZmaybe_b64decoder���r-���r+���Znum_retriesZsec_between_retriesr(���r.���r���r���r0����code�contents�json�decoderZJSONDecodeError) r2���r1���ZmdZleaf_key_format_callbackZurl_leafZnew_keyZformat_callbackr6���r����excr���r���r���r"���o���sR���� � � ����������r"���c�����������������C���s���t��|�t�S�r���)r���Zlist_from_depends�datasources)Zdependsr���r���r����get_datasource_list����s����rL���)rH���Zlogging�typingr���Z cloudinitr���r���r���r���Z getLoggerr<���r���r'���r*���rD���Z DataSourcer ����boolr8���r@���r"���ZDEP_FILESYSTEMZDEP_NETWORKrK���rL���r���r���r���r����<module>���s��� Z2�