%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/sources/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/__init__.cpython-312.pyc

�

���f����ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZmZmZmZddlmZmZmZmZmZmZddlmZddlmZddlmZdd	lm Z dd
l!m"Z"m#Z#ddl$m%Z%ddl&m'Z'dd
l(m)Z)ddl*m+Z+dZ,dZ-dZ.dZ/e,e-e.gZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8ejre:�Z;dd�fdd�fdd �fd!�Z<eGd"�d#e
��Z=Gd$�d%e
�Z>Gd&�d'e?�Z@Gd(�d)e?�ZAGd*�d+e?�ZBdGd,�ZCe5fd-�ZDed.gd/��ZEed0d1d2g�ZFGd3�de)ej��4�ZHd5�ZId6eeHeJffd7�ZKd8�ZL	dHd9eJd6eMfd:�ZNd;�ZOdId<�ZPGd=�d>eQ�ZRd?�ZSd@eHdAeJd6eMfdB�ZTdAeJd6eeHfdC�ZUd6eJfdD�ZVdEeJd6eJfdF�ZWy)J�N)�
namedtuple)�Enum�unique)�Any�Dict�List�Optional�Tuple�Union)�
atomic_helper�dmi�importer�	lifecycle�net�
type_utils)�	user_data)�util)�
write_json)�Distro)�
EventScope�	EventType)�launch_index)�Paths)�CloudInitPickleMixin)�events�disabled�localr�pass�
FILESYSTEM�NETWORK�
DataSourcez|EXPERIMENTAL: The structure and format of content scoped under the 'ds' key may change in subsequent releases of cloud-init.zredacted for non-root user�
cloud-name�_unset�unknownz	aws-chinac��|dk(S�N�aws���cs �</usr/lib/python3/dist-packages/cloudinit/sources/__init__.py�<lambda>r,?s
��1��:��zaws-govc��|dk(Sr&r(r)s r+r,r,@s
��Q�%�Z�r-zazure-chinac��|dk(S)N�azurer(r)s r+r,r,As
��q�G�|�r-)zcn-zus-gov-�chinac�0�eZdZdZdZdZdZdZdZde	fd�Z
y	)
�NetworkConfigSourcezb
    Represents the canonical list of network config sources that cloud-init
    knows about.
    �cmdline�ds�
system_cfg�fallback�	initramfs�returnc��|jS�N��value��selfs r+�__str__zNetworkConfigSource.__str__R����z�z�r-N)�__name__�
__module__�__qualname__�__doc__�CMD_LINE�DS�
SYSTEM_CFG�FALLBACK�	INITRAMFS�strr@r(r-r+r3r3Es.���
�H�	
�B��J��H��I���r-r3c�$�eZdZdZdZdZdefd�Zy)�NicOrderzRepresents ways to sort NICs�mac�nic_namer9c��|jSr;r<r>s r+r@zNicOrder.__str__\rAr-N)rBrCrDrE�MAC�NIC_NAMErKr@r(r-r+rMrMVs��&�
�C��H���r-rMc��eZdZdZy)�DatasourceUnpickleUserDataErrorzERaised when userdata is unable to be unpickled due to python upgradesN�rBrCrDrEr(r-r+rTrT`s��Or-rTc��eZdZy)�DataSourceNotFoundExceptionN�rBrCrDr(r-r+rWrWd���r-rWc��eZdZdZy)�InvalidMetaDataExceptionz8Raised when metadata is broken, unavailable or disabled.NrUr(r-r+r[r[hs��Br-r[c�x�tj|�}g}g}|j�D]�\}}|r	|dz|z}n|}|j�|vs|j�|vr|j	|�t|t�r7|jd�r&|j	|�|jdd�||<t|t�s��t|||�}	|j|	jd��|j|	jd��|	||<��t|�|d<t|�|d<|S)z�Process all instance metadata cleaning it up for persisting as json.

    Strip ci-b64 prefix and catalog any 'base64_encoded_keys' as a list

    @return Dict copy of processed metadata.
    �/zci-b64:��base64_encoded_keys�sensitive_keys)�copy�deepcopy�items�lower�append�
isinstancerK�
startswith�replace�dict�process_instance_metadata�extend�pop�sorted)
�metadata�key_pathr`�md_copyr_�	sens_keys�key�val�sub_key_path�
return_vals
          r+rjrjls/���m�m�H�%�G����I��N�N�$�&���S��#�c�>�C�/�L��L��I�I�K�>�)��!�!�#�~�5����\�*��c�3��C�N�N�9�$=��&�&�|�4��;�;�y�"�5�G�C�L��c�4� �2��\�>��J�
 �&�&�z�~�~�6K�'L�M����Z�^�^�,<�=�>�%�G�C�L�'&�(&,�,?�%@�G�!�"� &�y� 1�G����Nr-c��|jdg�s|Stj|�}|jd�D]M}|jd�}|}|D])}||vs�t	||t
�s�||dk7s�%||}�+|vs�I|||<�O|S)z�Redact any sensitive keys from to provided metadata dictionary.

    Replace any keys values listed in 'sensitive_keys' with redact_value.
    r`r]���)�getrarb�splitrfri)rn�redact_valuerpro�
path_parts�obj�paths       r+�redact_sensitive_keysr~�s����<�<�(�"�-����m�m�H�%�G��L�L�!1�2�%���^�^�C�(�
����	 �D�����s�4�y�$�/��J�r�N�*��$�i��
	 ��3�;�$�C��I�%��Nr-�	URLParams)�max_wait_seconds�timeout_seconds�num_retries�sec_between_retries�DataSourceHostname�hostname�
is_defaultc	��eZdZUeZdZdZdZdZdZ	dZ
eee
efed<ej"ej$ej&ej(fZeedfed<dZdZd	Zd
Zej8ej<ej>ej@ejBhiZ"ej8ej<hiZ#de$fde$fd
ifddddddf	Z%eeee&fdfed<dZ'dZ(eedfed<dZ)dZ*eeed<d
Z+dJde,de-fd�Z.de/ddfd�Z0d�Z1de2fd �Z3de2fd!�Z4d"�Z5d#�Z6dKd$�Z7de2fd%�Z8dLd&�Z9de2fd'�Z:d(�Z;dMd)�Z<d*�Z=d+�Z>e?d,��Z@e?d-��ZAd.�ZBe?d/��ZCd0�ZDe?d1��ZEd2�ZFd3�ZGd4�ZHd5�ZId6�ZJd7�ZKd8�ZLd9�ZMd:�ZNd;�ZOe?d<��ZPe?d=��ZQd>�ZRdNd?�ZSd@�ZTdAeUefdB�ZVdAeUede2fdC�ZWdD�ZXdE�ZYeZdOdF��Z[e?dG��Z\dH�Z]dI�Z^y)Pr!zen_US.UTF-8�_undefN�_crawled_metadata.�network_config_sourcesrw�
���ec2_metadata�network_jsonrn)�userdataN)�userdata_rawN)�
vendordataN)�vendordata_rawN)�vendordata2N)�vendordata2_rawN�cached_attr_defaultsF)
�combined_cloud_config�
merged_cfg�merged_system_cfgzsecurity-credentialsr��	user-datarr��vendor-datazds/vendor_data�sensitive_metadata_keys�extra_hotplug_udev_rules�distro�pathsc��||_||_||_d|_i|_d|_d|_d|_d|_d|_	d|_
t|_t|_
tj|jd|j fi�|_|j"si|_|s%t%j&|j�|_y||_y)N�
datasource)�sys_cfgr�r�r�rnr�r�r�r�r��metadata_address�UNSETr�r�r�get_cfg_by_path�dsname�ds_cfg�ud�UserDataProcessor�ud_proc)r?r�r�r�r�s     r+�__init__zDataSource.__init__<s�����������
�'+��
� ��
�+/���������"���#��� $���+0���!����*�*��L�L�<����5�r�
����{�{��D�K���/�/��
�
�;�D�L�"�D�Lr-�ci_pkl_versionr9c��dddtddtdddd�
}|j�D]\}}t||�r�t|||��!t|d�st|dd��t|d�r$|j�	t|j�yyy#t$r&}tjd|�t�|�d}~wwxYw)z(Perform deserialization fixes for Paths.NF)
r��_platform_type�_subplatformr�r�r�r��skip_hotplug_detectr�r��check_if_fallback_is_allowedc��y�NFr(r(r-r+r,z&DataSource._unpickle.<locals>.<lambda>i��r-r�z:Unable to unpickle datasource: %s. Ignoring current cache.)
r�rc�hasattr�setattrr�rK�AttributeError�LOG�debugrT)r?r��expected_attrsrrr=�es      r+�	_unpicklezDataSource._unpickleVs���"&�"� �!�(,� $�!�#(��#�
��)�.�.�0�	*�J�C���4��%���c�5�)�	*��t�;�<��D�8�-�H��4��$����)B�
?��D�M�M�"�*C�$��"�
?��	�	�/���
6�7�Q�>��

?�s�;B�	C�!B=�=Cc�,�tj|�Sr;)r�obj_namer>s r+r@zDataSource.__str__zs���"�"�4�(�(r-c��y)z#Check if running on this datasourceTr(r>s r+�	ds_detectzDataSource.ds_detect}���r-c��|jj�t�j�k(rtj	d|�y|j
j
dg�|jgk(rtj	d|�yy)aJOverride if either:
        - only a single datasource defined (nothing to fall back to)
        - command line argument is used (ci.ds=OpenStack)

        Note: get_cmdline() is required for the general case - when ds-identify
        does not run, _something_ needs to detect the kernel command line
        definition.
        z6Kernel command line set to use a single datasource %s.T�datasource_listz2Datasource list set to use a single datasource %s.F)r�rd�
parse_cmdliner�r�r�rxr>s r+�override_ds_detectzDataSource.override_ds_detect�st���;�;����-�/�"7�"7�"9�9��I�I�H��
��
�\�\�
�
�/��
4����
�
E��I�I�D�d�
��r-c���|j�r|j�S|j�r&tj	d|�|j�Stj	d|�y)z&Overrides runtime datasource detectionzDetected %szDid not detect %sF)r��	_get_datar�r�r�r>s r+�_check_and_get_datazDataSource._check_and_get_data�sX���"�"�$��>�>�#�#�
�^�^�
��I�I���
��>�>�#�#��I�I�)�4�0�r-c��|j�j}|j�}|j}|d}diddg�d|�d|�dt	|j
|j|j��d|j
�d	|j
�d
|dd�d
|dd�d|dd�d|j�d|j��d|d�d|�d|�d|dd�d|�d|�|dd|j|j|d|dd��iS)z2Return a dictionary of standardized metadata keys.�sys_info�v1�
_beta_keys�subplatform�availability-zone�availability_zone�cloud_idr"�
cloud_namer��distr�distro_versionr��distro_release��platform�public_ssh_keys�python_version�python�instance-id�instance_id�kernel_release�uname�local-hostname�local_hostname��variant)�machine�regionr��system_platformr�)
�get_hostnamer��get_instance_idr��canonical_cloud_idr�r��
platform_type�get_public_ssh_keysr�)r?�
instance_datar�r�r��sysinfos      r+�_get_standardized_metadataz%DataSource._get_standardized_metadata�s����*�*�,�5�5���*�*�,�� �2�2�� �
�+�����}�o��#�%6��$�%6���.��O�O�T�[�[�$�2D�2D��	��d�o�o���d�o�o���'�&�/�!�,��!�'�&�/�!�"4��!�'�&�/�!�"4���D�.�.��"�4�#;�#;�#=��!�'�(�"3���{�� �{�!�"!�'�'�"2�1�"5�#�$!�.�%�&!�.�'�(#�7�+�A�.��+�+�#�/�/�#*�:�#6�"�9�-�1�
�	
r-c��|jsy|r|}n|j}|D]\}}t||�s�t|||��!|sd|_yy)z�Reset any cached metadata attributes to datasource defaults.

        @param attr_defaults: Optional tuple of (attr, value) pairs to
           set instead of cached_attr_defaults.
        NF)�_dirty_cacher�r�r�)r?�
attr_defaults�attr_values�	attributer=s     r+�clear_cached_attrszDataSource.clear_cached_attrs�s_��� � ���'�K��3�3�K� +�	0��I�u��t�Y�'���i��/�	0�� %�D��r-c�\�d|_|j�}|s|S|j�|S)z�Datasources implement _get_data to setup metadata and userdata_raw.

        Minimally, the datasource should return a boolean True on success.
        T)r�r��persist_instance_data)r?�return_values  r+�get_datazDataSource.get_data�s7��
!����/�/�1������"�"�$��r-c���|rXtjj|jj�r%t||jj
d��|j�Htj|j�}|jdd�|jdd�d|i}nZdd|jii}|jtk7r|j|dd<|jtk7r|j|dd<t|dd	<tj|j �|d
<d|d
d	<tj|d
�|d<d
|dd	<t#j$�|d<|j'|j)|��	t+j,|�}t/t1j2|�|j4��}|jjAd�}|djCdd�}tjjE|jjFd�}	t#jH|	�d|��|�d��d}
|	�d|��}tjjK|	�rtjjM|	�}
t#jN||	d��|
r|
|k7rt#jP|
�tS||d��|jjAd�}tS|tU|��y#t6$r)}t8j;dt=|��Yd}~yd}~wt>$r)}t8j;dt=|��Yd}~yd}~wwxYw)aPProcess and write INSTANCE_JSON_FILE with all instance metadata.

        Replace any hyphens with underscores in key names for use in template
        processing.

        :param write_cache: boolean set True to persist obj.pkl when
            instance_link exists.

        @return True on successful write, False otherwise.
        �obj_pklNr�r�r5�	meta_datar�r��_docr�z<DEPRECATED: Use merged_system_cfg. Will be dropped from 24.1r�zUMerged cloud-init system config from /etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d/r�)r`z'Error persisting instance-data.json: %sF�instance_data_sensitiver�r��nonezcloud-id�-�
T)�forcei�)�moder�)+�osr}�lexistsr��
instance_link�	pkl_store�
get_ipath_curr�rarbrlrnr�r�r��EXPERIMENTAL_TEXTr�r�system_info�updater�r�
json_dumpsrj�json�loadsr��	TypeErrorr��warningrK�UnicodeDecodeError�get_runpathrx�join�run_dir�
write_file�exists�realpath�sym_link�del_filerr~)
r?�write_cache�crawled_metadatar��content�processed_datar��json_sensitive_filer��
cloud_id_file�prev_cloud_id_file�new_cloud_id_file�	json_files
             r+r�z DataSource.persist_instance_data�s���2�7�7�?�?�4�:�:�+C�+C�D��d�D�J�J�4�4�Y�?�@��!�!�-� $�}�}�T�-C�-C�D��� � ��d�3�� � ���5�!�#3�4�M�!�K����#?�@�M�� � �E�)�6:�6G�6G�
�d�#�N�3�� � �E�)�6:�6G�6G�
�d�#�N�3�&7�
�d��F�#�&*�m�m�D�L�L�&A�
�l�#�
K�	�l�#��	
�.2�]�]��,�'�.
�
�)�*�
'�	�)�*�6�2�%)�$4�$4�$6�
�j�!����T�<�<�]�K�L�
	�#�.�.�}�=�G�6��
�
�7�#�#�;�;��N�#�j�j�4�4�5N�O�� ��&�*�*�:�v�>�������T�Z�Z�%7�%7��D�
����=�/��8�*�5�(��2��G�!��,�o�Q�x�j�9��
�7�7�>�>�-�(�!#���!1�!1�-�!@���
�
�'��d�C��"4�8I�"I��M�M�,�-��&��U�C��J�J�*�*�?�;�	��9�3�N�C�D���1�	��K�K�A�3�q�6�J���!�	��K�K�A�3�q�6�J���	�s$�?L�	M7�M�M7�M2�2M7c��td��)z@Walk metadata sources, process crawled data and save attributes.zlSubclasses of DataSource must implement _get_data which sets self.metadata, vendordata_raw and userdata_raw.)�NotImplementedErrorr>s r+r�zDataSource._get_data<s��!�
D�
�	
r-c	�R�|j}	t|jjd|j��}|j}	tdt|jjd|j���}|j}	t|jjd|j��}|j}	t|jjd|j��}t||||�S#t$r9tjtd|jjd�|�Y��
wxYw#t$rE|j}tjtd|jjd�|�Y��wxYw#t$r9tjtd|jjd�|�Y��!wxYw#t$r9tjtd	|jjd�|�Y��*wxYw)
z�Return the Datasource's preferred url_read parameters.

        Subclasses may override url_max_wait, url_timeout, url_retries.

        @return: A URLParams object with max_wait_seconds, timeout_seconds,
            num_retries.
        �max_waitz6Config max_wait '%s' is not an int, using default '%s'r�timeoutz5Config timeout '%s' is not an int, using default '%s'�retriesz5Config retries '%s' is not an int, using default '%s'r�zAConfig sec_between_retries '%s' is not an int, using default '%s')�url_max_wait�intr�rx�
ValueErrorr�logexcr��url_timeout�max�url_retries�	Exception�url_sec_between_retriesr)r?r#r$r%r�s     r+�get_url_paramszDataSource.get_url_paramsCs����$�$��	��4�;�;�?�?�:�t�7H�7H�I�J�H��"�"��		��!�S�������D�<L�<L�!M�N�O�G��"�"��	��$�+�+�/�/�)�T�5E�5E�F�G�G�#�:�:��
	�"%������)�4�+G�+G��#����7�G�5H�I�I��_�	��K�K��H������
�+��	
�	���	��&�&�G��K�K��G������	�*��	
�	���	��K�K��G������	�*��	
�	���	��K�K��&������ 5�6�#�
�	�sH�/D	�
9E�/F�/G$�	>E�
E�A
F�F�>G!� G!�$>H&�%H&c���|j�.|jj|j��|_|r|j	|j�S|jSr;)r�r��process�get_userdata_raw�
_filter_xdata)r?�apply_filters  r+�get_userdatazDataSource.get_userdatasM���=�=� � �L�L�0�0��1F�1F�1H�I�D�M���%�%�d�m�m�4�4��}�}�r-c��|j�.|jj|j��|_|jSr;)r�r�r1�get_vendordata_rawr>s r+�get_vendordatazDataSource.get_vendordata�s5���?�?�"�"�l�l�2�2�4�3J�3J�3L�M�D�O����r-c��|j�.|jj|j��|_|jSr;)r�r�r1�get_vendordata2_rawr>s r+�get_vendordata2zDataSource.get_vendordata2�s:�����#�#�|�|�3�3�D�4L�4L�4N�O�D�����r-c�p�|js|jj�|_|jSr;)r�r�rdr>s r+r�zDataSource.platform_type�s,���"�"�"&�+�+�"3�"3�"5�D���"�"�"r-c�\�|js|j�|_|jS)a�Return a string representing subplatform details for the datasource.

        This should be guidance for where the metadata is sourced.
        Examples of this on different clouds:
            ec2:       metadata (http://169.254.169.254)
            openstack: configdrive (/dev/path)
            openstack: metadata (http://169.254.169.254)
            nocloud:   seed-dir (/seed/dir/path)
            lxd:   nocloud (/seed/dir/path)
        )r��_get_subplatformr>s r+r�zDataSource.subplatform�s*��� � � $� 5� 5� 7�D��� � � r-c�F�|jrd|j�d�StS)z?Subclasses should implement to return a "slug (detail)" string.z
metadata (�))r��METADATA_UNKNOWNr>s r+r>zDataSource._get_subplatform�s'��� � ��� 5� 5�6�a�8�8��r-c�,�|jr|jS|jr�|jjt�r�|jjt�}t	|t
�r!|j
�|_|jS|j�j
�|_tjdtt|��|jS|j�j
�|_|jS)z�Return lowercase cloud name as determined by the datasource.

        Datasource can determine or define its own cloud product name in
        metadata.
        z5Ignoring metadata provided key %s: non-string type %s)�_cloud_namernrx�METADATA_CLOUD_NAME_KEYrfrKrd�_get_cloud_namer�r��type)r?r�s  r+r�zDataSource.cloud_name�s�������#�#�#��=�=�T�]�]�.�.�/F�G����*�*�+B�C�J��*�c�*�#-�#3�#3�#5�� �����$(�#7�#7�#9�#?�#?�#A�� ��	�	�K�+���$������ $�3�3�5�;�;�=�D�����r-c��|jS)z�Return the datasource name as it frequently matches cloud name.

        Should be overridden in subclasses which can run on multiple
        cloud names, such as DatasourceEc2.
        )r�r>s r+rEzDataSource._get_cloud_name�s���{�{�r-c�X�|jsyd|jvr|jdSy)Nzlaunch-index)rnr>s r+rzDataSource.launch_index�s*���}�}���T�]�]�*��=�=��0�0�r-c��tjtj|j��g}|}|D]}|j	|�}�|Sr;)r�Filterr�safe_int�apply)r?�processed_ud�filters�new_ud�fs     r+r3zDataSource._filter_xdata�sN������
�
�d�.?�.?� @�A�
�����	%�A��W�W�V�_�F�	%��
r-c��|jSr;)r�r>s r+r2zDataSource.get_userdata_raw�s��� � � r-c��|jSr;)r�r>s r+r7zDataSource.get_vendordata_raw�s���"�"�"r-c��|jSr;)r�r>s r+r:zDataSource.get_vendordata2_raw�s���#�#�#r-c��iSr;r(r>s r+�get_config_objzDataSource.get_config_obj�s���	r-c�J�t|jjd��S)Nzpublic-keys)�normalize_pubkey_datarnrxr>s r+r�zDataSource.get_public_ssh_keys�s��$�T�]�]�%6�%6�}�%E�F�Fr-c��y)a5Publish the public SSH host keys (found in /etc/ssh/*.pub).

        @param hostkeys: List of host key tuples (key_type, key_value),
            where key_type is the first field in the public key file
            (e.g. 'ssh-rsa') and key_value is the key itself
            (e.g. 'AAAAB3NzaC1y...').
        Nr()r?�hostkeyss  r+�publish_host_keyszDataSource.publish_host_keys�r�r-c���ddi}|j�D]V\}}|j|�s�|D]:}d|�|t|�d��}tjj|�s�6|ccS�Xy)N�sd)�vd�xvd�vtbz/dev/)rcrg�lenrr}r)r?�
short_name�mappings�nfrom�tlist�nto�cands       r+�
_remap_devicezDataSource._remap_device�sx���.�/��$�N�N�,�	 �L�E�5��(�(��/���
 ��&)�:�c�%�j�l�+C�D���7�7�>�>�$�'��K�
 �	 �r-c��yr;r()r?�_names  r+�device_name_to_devicez DataSource.device_name_to_devices��r-c�t�|j}	|jj�}|S#t$rY|SwxYw)z<Default locale is en_US.UTF-8, but allow distros to override)�default_localer��
get_localer!)r?�locales  r+rmzDataSource.get_localesD���$�$��	��[�[�+�+�-�F��
��#�	���
�	�s�*�	7�7c���|jjd|jjd��}|r|S|jjdi�jd�S)Nr�r��	placement�rnrx)r?�top_level_azs  r+r�zDataSource.availability_zonesY���}�}�(�(�����!2�!2�3F�!G�
������}�}� � ��b�1�5�5�6I�J�Jr-c�8�|jjd�S)Nr�rqr>s r+r�zDataSource.region"s���}�}� � ��*�*r-c�h�|jrd|jvryt|jd�S)Nr�ziid-datasource)rnrKr>s r+r�zDataSource.get_instance_id&s+���}�}�
�T�]�]� B�#��4�=�=��/�0�0r-c�N�d}d}|}d}|jr|jjd�s�|rtd|�Sg}tj�}	|	dk(rd}tj
|	�}
|
r/|
j
d�dkDrt|
�jd�}n�|	r/|	j
d�dkDrt|	�jd�}n�|	r|	|g}n�||g}n�|jd}tj|�rMg}|rtj|�}|rt|�jd�}n(d	|jdd
�zg}n|jd�}t|�dkDr|d}	dj|dd�}n|d}	|r||k7r|	�d|��}	t|	|�S)a�Get hostname or fqdn from the datasource. Look it up if desired.

        @param fqdn: Boolean, set True to return hostname with domain.
        @param resolve_ip: Boolean, set True to attempt to resolve an ipv4
            address provided in local-hostname meta-data.
        @param metadata_only: Boolean, set True to avoid looking up hostname
            if meta-data doesn't have local-hostname present.

        @return: a DataSourceHostname namedtuple
            <hostname or qualified hostname>, <is_default> (str, bool).
            is_default is a bool and
            it's true only if hostname is localhost and was
            returned by util.get_hostname() as a default.
            This is used to differentiate with a user-defined
            localhost hostname.
            Optionally return (None, False) when
            metadata_only is True and local-hostname data is not available.
        �localdomain�	localhostFr�NT�.rzip-%sr�r�)rnrxr�rr��get_fqdn_from_hosts�findrKryr�is_ipv4_address�
gethostbyaddrrhr`r)r?�fqdn�
resolve_ip�
metadata_only�	defdomain�defhost�domainr��toksr��
hosts_fqdn�lhosts            r+r�zDataSource.get_hostname,s���&"�	������
��}�}�D�M�M�$5�$5�6F�$G��)�$�
�;�;�
�D��(�(�*�H��;�&�!�
��1�1�(�;�J��j�o�o�c�2�Q�6��:��,�,�S�1���h�m�m�C�0�1�4��8�}�*�*�3�/��� �)�,����+���M�M�"2�3�E��"�"�5�)�����-�-�e�4�D���t�9�?�?�3�/�D�#�e�m�m�C��&=�=�>�D��{�{�3�'���t�9�q�=��A�w�H��X�X�d�1�2�h�'�F��A�w�H��F�i�'�"*�F�3�H�!�(�J�7�7r-c�:�|jj|��S)N)�data_source)r��get_package_mirror_infor>s r+r�z"DataSource.get_package_mirror_infots���{�{�2�2�t�2�D�Dr-�source_event_typesc���i}|D][}|jj�D]<\}}||vs�|j|�s
t�||<||j	|��>�]|Sr;)�supported_update_eventsrcrx�set�add)r?r��supported_events�event�update_scope�
update_eventss      r+�get_supported_eventszDataSource.get_supported_eventsws~��24��'�	>�E��-�-�3�3�5�
>�����M�)�+�/�/��=�9<��(��6�$�\�2�6�6�u�=�
>�	>� �r-c��|j|�}|j�D]h\}}tjd|jdj|D�cgc]}|j��c}��|j
d|ztff��j|r#|j
�|j�}|rytjd|dj|D�cgc]}|j��c}��ycc}wcc}w)a�Refresh cached metadata if the datasource supports this event.

        The datasource has a list of supported_update_events which
        trigger refreshing all cached metadata as well as refreshing the
        network configuration.

        @param source_event_types: List of EventTypes which may trigger a
            metadata update.

        @return True if the datasource did successfully update cached metadata
            due to source_event_type.
        z:Update datasource metadata and %s config due to events: %s�, z
_%s_configTz(Datasource %s not updated for events: %sF)	r�rcr�r�r=rr�r�r�)r?r�r��scope�matched_eventsr��results       r+�update_metadata_if_supportedz'DataSource.update_metadata_if_supported�s��� �4�4�5G�H��%5�%;�%;�%=�		F�!�E�>��I�I�L�����	�	�N�C�5�5�;�;�C�D�
�
�#�#�l�U�&:�E�%B�$D�E�		F���#�#�%��]�]�_�F����	�	�6���I�I�0B�C�u�u�{�{�C�D�	
�
��!D��Ds�C1�C6c��yr�r()r?r�s  r+�check_instance_idzDataSource.check_instance_id�s��r-c��y)acheck_if_fallback_is_allowed()
        Checks if a cached ds is allowed to be restored when no valid ds is
        found in local mode by checking instance-id and searching valid data
        through ds list.

        @return True if a ds allows fallback, False otherwise.
        Fr(r>s r+r�z'DataSource.check_if_fallback_is_allowed�s��r-c�~�|�t}|�t}|D]'}|��||vr|cStjd||�|cS|S)Nz%invalid dsmode '%s', using default=%s)�DSMODE_NETWORK�
VALID_DSMODESr�r
)�
candidates�default�valid�	candidates    r+�_determine_dsmodezDataSource._determine_dsmode�s_���?�$�G��=�!�E�#�		�I�� ���E�!� � ����;�Y�����		��r-c��yr;r(r>s r+�network_configzDataSource.network_config�r�r-c��y)a(setup(is_new_instance)

        This is called before user-data and vendor-data have been processed.

        Unless the datasource has set mode to 'local', then networking
        per 'fallback' or per 'network_config' will have been written and
        brought up the OS at this point.
        Nr()r?�is_new_instances  r+�setupzDataSource.setup�s��	r-c��y)a�activate(cfg, is_new_instance)

        This is called before the init_modules will be called but after
        the user-data and vendor-data have been fully processed.

        The cfg is fully up to date config, it contains a merged view of
           system config, datasource config, user config, vendor config.
        It should be used rather than the sys_cfg passed to __init__.

        is_new_instance is a boolean indicating if this is a new instance.
        Nr()r?�cfgr�s   r+�activatezDataSource.activate�s��	r-r;)r(�T)F)FFF)NN)_rBrCrDr��dsmoderlr�rCr�r�r�r	rrrK�__annotations__r3rFrJrHrGr�r
r&r*r,r.rr r�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�HOTPLUGr��default_update_eventsr�r�rr�r�r�r��_ci_pkl_versionrrr�r'r�r@�boolr�r�r�r�r�r�r�r�r/r5r8r;�propertyr�r�r>r�rErr3r2r7r:rUr�rZrgrjrmr�r�r�r�r�rr�r�r�r��staticmethodr�r�r�r�r(r-r+r!r!�s5��
�F�"�N��F��K��N�
�L�48��x��d�C�i� 0�1�8�	�$�$��%�%��&�&����	?��E�"5�s�":�;���L��K��K���@	����'�'��N�N��!�!����	
���	����'�'�
���
���	���	�R����� ��!�
9��%��c�3�h��� 4�5�
��L�
0��U�3��8�_�
�" ��/3��h�s�m�2��O�#��#�u�#�4"?��"?��"?�H)��4���D��,�$
�L&�&�$��$J�X
�4�
�:J�x��
 �
�#��#�
�
!��
!� �� �� �.������!�#�$��G��� ���K��K��+��+�1�F8�PE� �t�I�� �$�"&�y�/�$�	
�$�L������*����	�r-)�	metaclassc�n�g}|s|St|t�r|j�St|ttf�rt|�St|t
�r]|j
�D]J\}}t|t�r|g}t|ttf�s�0|D]}|s�|j|���L|Sr;)rfrK�
splitlines�listr�rircre)�pubkey_data�keys�_keyname�klist�pkeys     r+rWrW�s���
�D�����+�s�#��%�%�'�'��+��c�{�+��K� � ��+��&�*�0�0�2�	*�O�H�e��%��%�����%�$���-�!�*�D�����D�)�	*�	*��Kr-r9c	���t|||�}|D�cgc]}tj|���}	}t|vrdnd}
tjd|
|	�t
|	|�D]�\}}tjd|jdd�zd|
�d|��d	|
�d
|��|��}
	|
5tjd|�||||�}|jtjg�r/d
|
�d|��|
_
|tj|�fcddd�cS	ddd���ddj#|	�z}t%|��cc}w#1swY�/xYw#t$rtj td|�Y��wxYw)N�networkrz#Searching for %s data source in: %sz	search-%sr!r^zsearching for z data from zno z data found from )�name�description�message�parentz%Seeing if we can get any data from %szfound zGetting data from %s failedz4Did not find any data source, searched classes: (%s)r�)�list_sourcesrr��DEP_NETWORKr�r��zipr�ReportEventStackrhr�rr�r�r-rr)rrW)r�r�r��ds_deps�cfg_list�pkg_list�reporter�ds_listrP�ds_namesrr��cls�myrep�s�msgs                r+�find_sourcer�	sz���8�W�h�7�G�07�8�1�
�#�#�A�&�8�H�8�#�w�.�9�G�D��I�I�3�T�8�D���7�+�A�	��c��'�'��t�|�|�L�"�=�=�;?��F�26��=��	
��
	A��
9��	�	�A�3�G�����/���1�1��0�0�1��@D�T�$J�E�M��z�2�2�3�7�8�
9�
9��
9��A�&A�4�9�9��D��C�&�c�
*�*��59�
9�
9���	A��K�K��:�C�@�	A�s6�D:�E� A$D?�	E�E�?E	�E�$E3�2E3c�b�g}tjd|||�|D]�}tj|�}tj||dg�\}}|stjd|�|D]@}tj|�}	t|	d�}
|
|�}|s�/|j|�����|S)z�Return a list of classes that have the same depends as 'depends'
    iterate through cfg_list, loading "DataSource*" modules
    and calling their "get_datasource_list".
    Return an ordered list of classes that match (if any)
    zLLooking for data source in: %s, via packages %s that matches dependencies %s�get_datasource_listzDCould not import %s. Does the DataSource exist and is it importable?)	r�r�r�"match_case_insensitive_module_name�find_module�error�
import_module�getattrrk)r��dependsr��src_listr5�ds_name�m_locs�_looked_locs�m_loc�mod�lister�matchess            r+r�r�*s����H��I�I�	8���������=�=�b�A��'�3�3��X� 5�6� 
������I�I�$��
�
�	�E��(�(��/�C��S�"7�8�F��W�o�G������(��
	��$�Or-�fieldc�z�|sytj|�}|sy|j�|j�k(Sr�)r
�
read_dmi_datard)r�r��	dmi_values   r+�instance_id_matches_system_uuidr�Ns;��
���!�!�%�(�I�������)�/�/�"3�3�3r-c���|st}|st}|tk(r
|tk7r|S|Stj�D](\}}|\}}|j|�s�||�s�&|cS|tk7r|S|S)z@Lookup the canonical cloud-id for a given cloud_name and region.)rA�CLOUD_ID_REGION_PREFIX_MAPrcrg)r�r�r��prefix�
cloud_id_testr��valid_clouds       r+r�r�\s����%�
��!��
�!�!��)�)�����!;�!A�!A�!C����
�"/���;����V�$��Z�)@��O���%�%����Or-c��|syt|t�r|St|t�rtj|�St|t
�r+|durt
|jd�d��Std��tdt|�z��)aLdata: a loaded object (strings, arrays, dicts).
    return something suitable for cloudinit vendordata_raw.

    if data is:
       None: return None
       string: return string
       list: return data
             the list is then processed in UserDataProcessor
       dict: return convert_vendordata(data.get('cloud-init'))
    NTz
cloud-initF)�recursez'vendordata['cloud-init'] cannot be dictz$Unknown data type for vendordata: %s)
rfrKr�rarbri�convert_vendordatarxr(rF)�datar�s  r+r�r�osz�����$������$����}�}�T�"�"��$����d�?�%�d�h�h�|�&<�e�L�L��B�C�C�
�;�d�4�j�H�
I�Ir-c��eZdZy)�BrokenMetadataNrXr(r-r+r�r��rYr-r�c�t�g}t|�}|D]%\}}|t|�k(s�|j|��'|Sr;)r�re)r�r��ret_list�depsetr��depss      r+�list_from_dependsr��sB���H�
��\�F��!�	��T��S��Y���O�O�C� �!��Or-r|�fnamec��	tj|�}	tj||dd��y#t$rtjt
d|�YywxYw#t$rtjt
d|�YywxYw)z[Use pickle to serialize Datasource to a file as a cache.

    :return: True on success
    zFailed pickling datasource %sF�wb�)�omoderz Failed pickling datasource to %sT)�pickle�dumpsr-rr)r�r)r|r��pk_contentss   r+rr�sz��
��l�l�3�'�������{�$�U�C��������C�8�#�>����
�����C�;�U�C���s �2�A�$A�A�$B�Bc�d�d}	tj|�}|sy	tj|�S#t$r@}tjj|�rtjd||�Yd}~�]d}~wwxYw#t$rYyt$rtjtd|�YywxYw)zBUse pickle to deserialize a instance Datasource from a cache file.Nzfailed loading pickle in %s: %sz#Failed loading pickled blob from %s)r�load_binary_filer-rr}�isfiler�r
rrrTr))r��pickle_contentsr�s   r+�pkl_loadr�s����O�E��/�/��6������|�|�O�,�,���E�
�7�7�>�>�%� ��K�K�9�5�!�D���E��+��������C�>��F���s+�2�A>�	A;�6A6�6A;�>	B/�	#B/�.B/c�<�ttj��S)z�Check if command line argument for this datasource was passed
    Passing by command line overrides runtime datasource detection
    )�parse_cmdline_or_dmir�get_cmdliner(r-r+r�r��s�� �� 0� 0� 2�3�3r-�inputc�v�tjd|�}tjd|�}tjd|�}|xs|xs|}|xs|}|rA|jd�j�}t	j
d|�d|��dd|�d	��
�|r"|jd�r|jd�Sy)Nz(?:^|\s)ds=([^\s;]+)z(?:^|\s)ci\.ds=([^\s;]+)z (?:^|\s)ci\.datasource=([^\s;]+)r�z8Defining the datasource on the command line using ci.ds=z or ci.datasource=z23.2zUse ds=z instead)�
deprecated�deprecated_version�
extra_messager^)�re�search�group�stripr�	deprecate)r�
ds_parse_0�
ds_parse_1�
ds_parse_2r5r
r�s       r+r	r	�s������2�E�:�J����6��>�J����>��F�J�	�	/�z�	/�Z�B��)�z�J���!�!�!�$�*�*�,��������!!�!'��*� &�#�F�8�8�4�	
�
�b�h�h�q�k��x�x��{��
r-)r^r()zsystem-uuidr�)X�abcrar
�loggingrrr�collectionsr�enumrr�typingrrrr	r
r�	cloudinitrr
rrrrrr�r�cloudinit.atomic_helperr�cloudinit.distrosr�cloudinit.eventrr�cloudinit.filtersr�cloudinit.helpersr�cloudinit.persistencer�cloudinit.reportingr�DSMODE_DISABLED�DSMODE_LOCALr��DSMODE_PASSr��DEP_FILESYSTEMr��	DS_PREFIXr�REDACT_SENSITIVE_VALUErDr�rA�	getLoggerrBr�r�r3rMr-rTrWr[rjr~rr��ABCMetar!rWrKr�r�r�r�r�r��IOErrorr�r�rrr�r	r(r-r+�<module>r.s������	�
�	�"��:�:�N�N�%��.�$�1�*�#�6�&��������� �,��?�
������	�<��6��'�������g����!��

�-�.��/�0��3�
4����
�$�
��
� �t��P�i�P�	�)�	�C�y�C� �F2H��:
���
�	� �������m�%����m�`�:+�
�:�s�?��+�B!�J,�4��4�	�4��&J�0	�W�	���:��c��d��$�C��H�Z�0��*4�s�4�����r-

Zerion Mini Shell 1.0