HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/sources/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/__init__.cpython-311.pyc
�

܍~c����
�ddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZmZm
Z
mZmZddlmZmZddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(dZ)dZ*dZ+dZ,e)e*e+gZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5ej6e7��Z8dd�fdd �fd!d"�fd#�Z9e	Gd$�d%e����Z:Gd&�d'e;��Z<Gd(�d)e;��Z=Gd*�d+e;��Z>dHd.�Z?e2fd/�Z@ed0gd1���ZAed2d3d4g��ZBGd5�de&ejC�6��ZDd7�ZEd8eeDeFffd9�ZGd:�ZH	dId<eFd8eIfd=�ZJd>�ZKdJd@�ZLGdA�dBeM��ZNdC�ZOdDeDdEeFd8eIfdF�ZPdEeFd8eeDfdG�ZQdS)K�N)�
namedtuple)�Enum�unique)�Any�Dict�List�Optional�Tuple)�dmi�importer)�log)�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��|dkS�N�aws���cs �</usr/lib/python3/dist-packages/cloudinit/sources/__init__.py�<lambda>r*?s
��1��:��zaws-govc��|dkSr$r&r's r)r*r*@s
��Q�%�Z�r+zazure-chinac��|dkS)N�azurer&r's r)r*r*As
��q�G�|�r+)zcn-zus-gov-�chinac�2�eZdZdZdZdZdZdZdZde	fd�Z
d	S)
�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__Rs
���z�r+N)�__name__�
__module__�__qualname__�__doc__�CMD_LINE�DS�
SYSTEM_CFG�FALLBACK�	INITRAMFS�strr>r&r+r)r1r1EsT��������
�H�	
�B��J��H��I��������r+r1c��eZdZdZdS)�DatasourceUnpickleUserDataErrorzERaised when userdata is unable to be unpickled due to python upgradesN�r?r@rArBr&r+r)rJrJVs������O�O�O�Or+rJc��eZdZdS)�DataSourceNotFoundExceptionN�r?r@rAr&r+r)rMrMZ��������Dr+rMc��eZdZdZdS)�InvalidMetaDataExceptionz8Raised when metadata is broken, unavailable or disabled.NrKr&r+r)rQrQ^s������B�B�B�Br+rQ�r&c��tj|��}g}g}|���D�]\}}|r	|dz|z}n|}||vs||vr|�|��t	|t
��rC|�d��r.|�|��|�dd��||<t	|t��rft|||��}	|�
|	�d����|�
|	�d����|	||<��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:rR�base64_encoded_keys�sensitive_keys)
�copy�deepcopy�items�append�
isinstancerH�
startswith�replace�dict�process_instance_metadata�extend�pop�sorted)
�metadata�key_pathrV�md_copyrU�	sens_keys�key�val�sub_key_path�
return_vals
          r)r_r_bss���m�H�%�%�G����I��N�N�$�$�&�&���S��	�#�c�>�C�/�L�L��L��.� � �L�N�$B�$B����\�*�*�*��c�3���	6�C�N�N�9�$=�$=�	6��&�&�|�4�4�4��;�;�y�"�5�5�G�C�L��c�4� � �	&�2��\�>���J�
 �&�&�z�~�~�6K�'L�'L�M�M�M����Z�^�^�,<�=�=�>�>�>�%�G�C�L��%+�,?�%@�%@�G�!�"� &�y� 1� 1�G����Nr+c�.�|�dg��s|Stj|��}|�d��D]R}|�d��}|}|D]1}t	||t
��r||dkr||}�2|||<�S|S)z�Redact any sensitive keys from to provided metadata dictionary.

    Replace any keys values listed in 'sensitive_keys' with redact_value.
    rVrT���)�getrWrX�splitr[r^)rc�redact_valuererd�
path_parts�obj�paths       r)�redact_sensitive_keysrs�s���
�<�<�(�"�-�-�����m�H�%�%�G��L�L�!1�2�2�!�!���^�^�C�(�(�
����	 �	 �D��#�d�)�T�*�*�
 �t�z�"�~�/E�/E��$�i��� ��D�	�	��Nr+�	URLParams)�max_wait_seconds�timeout_seconds�num_retries�sec_between_retries�DataSourceHostname�hostname�
is_defaultc	�f�eZdZUeZdZdZdZdZdZ	dZ
ejej
ejejfZeedfed<dZdZdZd	ZejejejejejhiZejejhiZd
e fde fdifd
dddddf	Z!eee"e#fdfed<dZ$dZ%ee"dfed<dZ&d	Z'dIde(de)fd�Z*de+ddfd�Z,d�Z-d�Z.dJd �Z/de0fd!�Z1dKd#�Z2de0fd$�Z3d%�Z4dLd&�Z5d'�Z6d(�Z7e8d)���Z9e8d*���Z:e8d+���Z;d,�Z<e8d-���Z=d.�Z>e8d/���Z?d0�Z@e8d1���ZAd2�ZBd3�ZCd4�ZDd5�ZEd6�ZFd7�ZGd8�ZHd9�ZId:�ZJe8d;���ZKe8d<���ZLd=�ZMdMd>�ZNd?�ZOd@ePefdA�ZQd@ePede0fdB�ZRdC�ZSeTdNdD���ZUe8dE���ZVe8dF���ZWdG�ZXdH�ZYdS)Orzen_US.UTF-8�_undefN.�network_config_sourcesrl�
���ec2_metadata�network_jsonrc)�userdataN)�userdata_rawN)�
vendordataN)�vendordata_rawN)�vendordata2N)�vendordata2_rawN�cached_attr_defaultsF)�
merged_cfgzsecurity-credentials�sensitive_metadata_keys�distro�pathsc�N�||_||_||_d|_i|_d|_d|_d|_d|_d|_	tj|jd|jfi��|_
|j
si|_
|s tj|j��|_dS||_dS)N�
datasource)�sys_cfgr�r�r�rcr�r�r�r�r�r�get_cfg_by_path�dsname�ds_cfg�ud�UserDataProcessor�ud_proc)r=r�r�r�r�s     r)�__init__zDataSource.__init__s�����������
���
� ��
� ���������"���#����*��L�<���5�r�
�
����{�	��D�K��	#��/��
�;�;�D�L�L�L�"�D�L�L�Lr+�ci_pkl_versionr7c�h�t|d��sd|_t|d��sd|_t|d��sd|_t|d��rZ|j�U	t|j��dS#t$r/}t�d|��t��|�d}~wwxYwdSdS)z(Perform deserialization fixes for Paths.r�Nr��skip_hotplug_detectFr�z:Unable to unpickle datasource: %s. Ignoring current cache.)
�hasattrr�r�r�r�rH�AttributeError�LOG�debugrJ)r=r��es   r)�	_unpicklezDataSource._unpickles����t�]�+�+�	$�#�D���t�.�/�/�	(�#'�D� ��t�2�3�3�	-�',�D�$��4��$�$�	?���)B�
?��D�M�"�"�"�"�"��!�
?�
?�
?��	�	�/�����
6�7�7�Q�>�����

?����	?�	?�)B�)Bs�A4�4
B-�>*B(�(B-c�*�tj|��Sr9�r�obj_namer<s r)r>zDataSource.__str__3s���"�4�(�(�(r+c�(�|���j}|���}|j}|d}diddg�d|�d|�dt	|j|j|j���d|j�d	|j�d
|dd�d
|dd�d|dd�d|j�d|����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_hostnamerz�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_metadata6s����*�*�,�,�5���*�*�,�,�� �2�� �
�+�����}�o��#�%6��$�%6���.��O�T�[�$�2D���	��d�o���d�o���'�&�/�!�,��!�'�&�/�!�"4��!�'�&�/�!�"4���D�.��"�4�#;�#;�#=�#=��!�'�(�"3���{�� �{�!�"!�'�'�"2�1�"5�#�$!�.�%�&!�.�'�(#�7�+�A�.��+�#�/�#*�:�#6�"�9�-�1���
�	
r+r&c��|jsdS|r|}n|j}|D]&\}}t||��rt|||���'|s	d|_dSdS)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��setattr)r=�
attr_defaults�attr_values�	attributer;s     r)�clear_cached_attrszDataSource.clear_cached_attrs\s���� �	��F��	4�'�K�K��3�K� +�	0�	0��I�u��t�Y�'�'�
0���i��/�/�/���	&� %�D����	&�	&r+c�l�d|_|���}|s|S|���|S)z�Datasources implement _get_data to setup metadata and userdata_raw.

        Minimally, the datasource should return a boolean True on success.
        T)r��	_get_data�persist_instance_data)r=�return_values  r)�get_datazDataSource.get_dataosA��
!����~�~�'�'���	 ����"�"�$�$�$��r+Tc�6�|rQtj�|jj��r(t||j�d����t|d��rStj	t|d����}|�dd��|�dd��d|i}nwdd|jii}t|d��r&t|d��}|tkr||dd<t|d	��r&t|d	��}|tkr||dd	<t|dd
<tj	|j��|d<d|dd
<t!j��|d
<|�|�|����	t!j|��}t+t-j|��|j���}n{#t2$r3}t4�dt9|����Yd}~dSd}~wt:$r3}t4�dt9|����Yd}~dSd}~wwxYw|j�d��}	|d�dd��}
tj� |jj!d��}t!j"|�d|
��|
�d���tj�#|��r tj�$|��}n|}t!j%|�d|
��|d���||krt!j&|��tO|	|d���|j�d��}
tO|
tQ|����dS)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_pkl�_crawled_metadataz	user-dataNzvendor-datar3�	meta_datar�r��_docr�zUMerged cloud-init system config from /etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d/r�)rVz'Error persisting instance-data.json: %sF�instance_data_sensitiver�r��nonezcloud-id�-�
T)�forcei�)�moder�))�osrr�lexistsr��
instance_link�	pkl_store�
get_ipath_curr�rWrX�getattrrarc�UNSET�EXPERIMENTAL_TEXTr�r�system_info�updater��
json_dumpsr_�json�loadsr��	TypeErrorr��warningrH�UnicodeDecodeError�get_runpathrm�join�run_dir�
write_file�exists�realpath�sym_link�del_filerrs)r=�write_cache�crawled_metadatar�r�r��content�processed_datar��json_sensitive_filer��
cloud_id_file�prev_cloud_id_file�	json_files              r)r�z DataSource.persist_instance_data{s����	A�2�7�?�?�4�:�+C�D�D�	A��d�D�J�4�4�Y�?�?�@�@�@��4�,�-�-�	G� $�}���1�2�2� � ��
� � ��d�3�3�3�� � ���5�5�5�!�#3�4�M�M�!�K���#?�@�M��t�^�,�,�
G�&�t�^�<�<���5�(�(�:F�M�$�'��7��t�^�,�,�
G�&�t�^�<�<���5�(�(�:F�M�$�'��7�&7�
�d��F�#�&*�m�D�L�&A�&A�
�l�#�
'�	�l�#�F�+�%)�$4�$6�$6�
�j�!����T�<�<�]�K�K�L�L�L�
	��o�m�4�4�G�6��
�7�#�#�#�;����N�N���	�	�	��K�K�A�3�q�6�6�J�J�J��5�5�5�5�5�����!�	�	�	��K�K�A�3�q�6�6�J�J�J��5�5�5�5�5�����	����#�j�4�4�5N�O�O�� ��&�*�*�:�v�>�>������T�Z�%7��D�D�
���=�5�5�8�5�5�(����G�G�G�
�7�>�>�-�(�(�	/�!#��!1�!1�-�!@�!@���!.���
��3�3��3�3�]�$�O�O�O�O���.�.��M�,�-�-�-��&��U�C�C�C�C��J�*�*�?�;�;�	��9�3�N�C�C�D�D�D��ts$�$<G!�!
I�+(H�
I�&(I�Ic� �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	� �|j}	t|j�d|j����}nD#t$r7tjtd|j�d��|��YnwxYw|j}	tdt|j�d|j������}nK#t$r>|j}tjtd|j�d��|��YnwxYw|j
}	t|j�d|j
����}nD#t$r7tjtd|j�d��|��YnwxYw|j}	t|j�d|j����}nD#t$r7tjtd	|j�d��|��YnwxYwt||||��S)
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'rxzAConfig sec_between_retries '%s' is not an int, using default '%s')�url_max_wait�intr�rm�
ValueErrorr�logexcr��url_timeout�max�url_retries�	Exception�url_sec_between_retriesrt)r=rrrrxs     r)�get_url_paramszDataSource.get_url_params�sM���$��	��4�;�?�?�:�t�7H�I�I�J�J�H�H���	�	�	��K��H�����
�+�+��	
�
�
�
�
�	�����"��		��!�S������D�<L�!M�!M�N�N�O�O�G�G���	�	�	��&�G��K��G�����	�*�*��	
�
�
�
�
�	�����"��	��$�+�/�/�)�T�5E�F�F�G�G�G�G���	�	�	��K��G�����	�*�*��	
�
�
�
�
�	����#�:��
	�"%�����)�4�+G���#�#����
�	�	�	��K��&����� 5�6�6�#�
�
�
�
�
�	������7�G�5H�I�I�IsF�-7�>A8�7A8�;B?�?AD�D�-E�>F�F�-F:�:>G;�:G;c��|j�1|j�|�����|_|r|�|j��S|jSr9)r�r��process�get_userdata_raw�
_filter_xdata)r=�apply_filters  r)�get_userdatazDataSource.get_userdatasS���=� � �L�0�0��1F�1F�1H�1H�I�I�D�M��	5��%�%�d�m�4�4�4��}�r+c��|j�1|j�|�����|_|jSr9)r�r�r�get_vendordata_rawr<s r)�get_vendordatazDataSource.get_vendordata
s5���?�"�"�l�2�2�4�3J�3J�3L�3L�M�M�D�O���r+c��|j�1|j�|�����|_|jSr9)r�r�r�get_vendordata2_rawr<s r)�get_vendordata2zDataSource.get_vendordata2s8����#�#�|�3�3�D�4L�4L�4N�4N�O�O�D����r+c��|j�?tj��|_|j� t�d|j��|jS)zADetermine the network interface used during local network config.Nz(Did not find a fallback interface on %s.)�_fallback_interfacer�find_fallback_nicr�r�r�r<s r)�fallback_interfacezDataSource.fallback_interfacesO���#�+�'*�'<�'>�'>�D�$��'�/����>�������'�'r+c��t|d��s|j���|_|js|j���|_|jS)N�_platform_type)r�r��lowerr!r<s r)r�zDataSource.platform_type"sU���t�-�.�.�	6�"&�+�"3�"3�"5�"5�D���"�	6�"&�+�"3�"3�"5�"5�D���"�"r+c��t|d��s|���|_|js|���|_|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)
        �_subplatform)r��_get_subplatformr$r<s r)r�zDataSource.subplatform+sR���t�^�,�,�	8� $� 5� 5� 7� 7�D��� �	8� $� 5� 5� 7� 7�D��� � r+c�V�t|d��rdt|d��zStS)z?Subclasses should implement to return a "slug (detail)" string.�metadata_addressz
metadata (%s))r�r��METADATA_UNKNOWNr<s r)r%zDataSource._get_subplatform>s2���4�+�,�,�	G�"�W�T�3E�%F�%F�F�F��r+c��|jr|jS|jr�|j�t��r�|j�t��}t	|t
��r|���|_n�|������|_t�	dtt|����n+|������|_|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_namercrm�METADATA_CLOUD_NAME_KEYr[rHr"�_get_cloud_namer�r��type)r=r�s  r)r�zDataSource.cloud_nameDs�����	$��#�#��=�	>�T�]�.�.�/F�G�G�	>���*�*�+B�C�C�J��*�c�*�*�
�#-�#3�#3�#5�#5�� � �#'�#7�#7�#9�#9�#?�#?�#A�#A�� ��	�	�K�+���$�$����� $�3�3�5�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)r,zDataSource._get_cloud_name\s���{�r+c�D�|jsdSd|jvr
|jdSdS)Nzlaunch-index)rcr<s r)rzDataSource.launch_indexds0���}�	��4��T�]�*�*��=��0�0��tr+c��tjtj|j����g}|}|D]}|�|��}�|Sr9)r�Filterr�safe_int�apply)r=�processed_ud�filters�new_ud�fs     r)rzDataSource._filter_xdatalsP�����
�d�.?� @� @�A�A�
�����	%�	%�A��W�W�V�_�_�F�F��
r+c��dS�NFr&r<s r)�is_disconnectedzDataSource.is_disconnectedu����ur+c��|jSr9)r�r<s r)rzDataSource.get_userdata_rawys��� � r+c��|jSr9)r�r<s r)rzDataSource.get_vendordata_raw|s���"�"r+c��|jSr9)r�r<s r)rzDataSource.get_vendordata2_raws���#�#r+c��iSr9r&r<s r)�get_config_objzDataSource.get_config_obj�s���	r+c�P�t|j�d����S)Nzpublic-keys)�normalize_pubkey_datarcrmr<s r)r�zDataSource.get_public_ssh_keys�s ��$�T�]�%6�%6�}�%E�%E�F�F�Fr+c��dS)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�s���r+c��ddi}|���D]a\}}|�|��s�|D]C}d|�|t|��d���}tj�|��r|ccS�D�bdS)N�sd)�vd�xvd�vtbz/dev/)rYr\�lenr�rrr�)r=�
short_name�mappings�nfrom�tlist�nto�cands       r)�
_remap_devicezDataSource._remap_device�s����.�/��&�n�n�.�.�	 �	 �N�U�E��(�(��/�/�
���
 �
 ���&)�c�:�c�%�j�j�l�l�+C�+C�D���7�>�>�$�'�'� ��K�K�K�K�K� �
 ��tr+c��dSr9r&)r=�_names  r)�device_name_to_devicez DataSource.device_name_to_device�s	���tr+c�j�|j}	|j���}n#t$rYnwxYw|S)z<Default locale is en_US.UTF-8, but allow distros to override)�default_localer��
get_localer)r=�locales  r)rXzDataSource.get_locale�sI���$��	��[�+�+�-�-�F�F��"�	�	�	��D�	�����
s�#�
0�0c���|j�d|j�d����}|r|S|j�di���d��S)Nr�r��	placement�rcrm)r=�top_level_azs  r)r�zDataSource.availability_zone�sf���}�(�(����!2�!2�3F�!G�!G�
�
���	 ����}� � ��b�1�1�5�5�6I�J�J�Jr+c�6�|j�d��S)Nr�r\r<s r)r�zDataSource.region�s���}� � ��*�*�*r+c�Z�|jr	d|jvrdSt|jd��S)Nr�ziid-datasource)rcrHr<s r)r�zDataSource.get_instance_id�s3���}�	$�
�T�]� B� B�#�#��4�=��/�0�0�0r+c���d}d}|}d}|jr|j�d��s�|rtd|��Sg}tj��}	|	dkrd}tj|	��}
|
r<|
�d��dkr#t|
���d��}n�|	r<|	�d��dkr#t|	���d��}n�|	r|	|g}n�||g}n�|jd}tj
|��rXg}|rtj|��}|r#t|���d��}n0d	|�dd
��zg}n|�d��}t|��dkr&|d}	d�|dd���}n|d}	|r
||kr|	�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�)rcrmryrr��get_fqdn_from_hosts�findrHrnr�is_ipv4_address�
gethostbyaddrr]rKr�)r=�fqdn�
resolve_ip�
metadata_only�	defdomain�defhost�domainr{�toksrz�
hosts_fqdn�lhosts            r)r�zDataSource.get_hostname�s��&"�	������
��}�#	(�D�M�$5�$5�6F�$G�$G�#	(��
<�)�$�
�;�;�;�
�D��(�*�*�H��;�&�&�!�
��1�(�;�;�J��
,�j�o�o�c�2�2�Q�6�6��:���,�,�S�1�1����
,�h�m�m�C�0�0�1�4�4��8�}�}�*�*�3�/�/����
,� �)�,�����+����M�"2�3�E��"�5�)�)�

(����5��-�e�4�4�D��?��t�9�9�?�?�3�/�/�D�D�#�e�m�m�C��&=�&=�=�>�D�D��{�{�3�'�'���t�9�9�q�=�=��A�w�H��X�X�d�1�2�2�h�'�'�F�F��A�w�H��	4�F�i�'�'�"*�(�(�F�F�3�H�!�(�J�7�7�7r+c�8�|j�|���S)N)�data_source)r��get_package_mirror_infor<s r)rsz"DataSource.get_package_mirror_infos���{�2�2�t�2�D�D�Dr+�source_event_typesc���i}|D]f}|j���D]J\}}||vrA|�|��st��||<||�|���K�g|Sr9)�supported_update_eventsrYrm�set�add)r=rt�supported_events�event�update_scope�
update_eventss      r)�get_supported_eventszDataSource.get_supported_eventss���24��'�	>�	>�E��-�3�3�5�5�
>�
>�����M�)�)�+�/�/��=�=�?�9<���(��6�$�\�2�6�6�u�=�=�=��
>� �r+c	���|�|��}|���D]c\}}t�d|jd�d�|D������|�d|ztff���d|r,|���|���}|rdSt�d|d�d�|D������dS)	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�, c��g|]	}|j��
Sr&r:��.0rzs  r)�
<listcomp>z;DataSource.update_metadata_if_supported.<locals>.<listcomp>4s��C�C�C�5�5�;�C�C�Cr+z
_%s_configTz(Datasource %s not updated for events: %sc��g|]	}|j��
Sr&r:r�s  r)r�z;DataSource.update_metadata_if_supported.<locals>.<listcomp>Bs��C�C�C�u�u�{�C�C�Cr+F)	r}rYr�r�r;r�r�r�r�)r=rtry�scope�matched_events�results      r)�update_metadata_if_supportedz'DataSource.update_metadata_if_supported s�� �4�4�5G�H�H��%5�%;�%;�%=�%=�		F�		F�!�E�>��I�I�L����	�	�C�C�N�C�C�C�D�D�
�
�
�
�#�#�l�U�&:�E�%B�$D�E�E�E�E��	��#�#�%�%�%��]�]�_�_�F��
��t��	�	�6���I�I�C�C�0B�C�C�C�D�D�	
�	
�	
�
�ur+c��dSr9r&)r=r�s  r)�check_instance_idzDataSource.check_instance_idFr;r+c��|�t}|�t}|D],}|��||vr|cSt�d||��|cS|S)Nz%invalid dsmode '%s', using default=%s)�DSMODE_NETWORK�
VALID_DSMODESr�r�)�
candidates�default�valid�	candidates    r)�_determine_dsmodezDataSource._determine_dsmodeJst���?�$�G��=�!�E�#�		�		�I�� ���E�!�!� � � � ����;�Y����������r+c��dSr9r&r<s r)�network_configzDataSource.network_config`s���tr+c��dSr9r&r<s r)�first_instance_bootzDataSource.first_instance_bootds���r+c��dS)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.setuphs	��	�r+c��dS)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.activatess	��	�r+r9)r&�T)F)FFF)NN)Zr?r@rAr��dsmoderWr�r*r!r$rr1rCrGrErDr~r
�__annotations__rr
rrrrr�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�HOTPLUGrv�default_update_eventsr�r�rHrr�r�r��_ci_pkl_versionrrr�rr�r>r�r��boolr�r�r�rrrr�propertyrr�r�r%r�r,rrr:rrrr@r�rErRrUrXr�r�r�r�rsrr}r�r��staticmethodr�r�r�r�r�r&r+r)rr�s�������
�F�"�N��F��K��N�
�L���	�$��%��&���	?��E�"5�s�":�;�����L��K��K���	���'��N��!���	
���	���'�
���
���	���	�R����� ��!�
9��%��c�3�h��� 4�5�
�
�
��L�0��U�3��8�_���� ���O�#�#��#�u�#�#�#�#�.?��?��?�?�?�?�0)�)�)�$
�$
�$
�L&�&�&�&�&
�$�
�
�
�
�F�F�F�F�P
�4�
�
�
�
�:J�:J�:J�x�������
 � � �
�(�(��X�(��#�#��X�#��!�!��X�!�$ � � �� � ��X� �.�������X���������X��!�!�!�#�#�#�$�$�$����G�G�G������� �������K�K��X�K��+�+��X�+�1�1�1�F8�F8�F8�F8�PE�E�E� �t�I�� � � � �$�"&�y�/�$�	
�$�$�$�$�L��������\��*����X������X��	�	�	�����r+)�	metaclassc��g}|s|St|t��r|���St|ttf��rt|��St|t
��rj|���D]U\}}t|t��r|g}t|ttf��r|D]}|r|�|����V|Sr9)r[rH�
splitlines�listrwr^rYrZ)�pubkey_data�keys�_keyname�klist�pkeys     r)rBrB�s���
�D������+�s�#�#�(��%�%�'�'�'��+��c�{�+�+�!��K� � � ��+��&�&�*�!,�!2�!2�!4�!4�	*�	*��X�u��%��%�%�
 �����%�$���-�-�
*�!�*�*�D��*����D�)�)�)����Kr+r7c	��t|||��}d�|D��}t|vrdnd}	t�d|	|��t	||��D�]\}
}tjd|
�dd��zd|	�d	|
��d
|	�d|
��|���}	|5t�d
|��||||��}
|
�tj
g��r1d|	�d	|
��|_|
tj
|��fcddd��cS	ddd��n#1swxYwY��#t$rtjtd|��Y��wxYwdd�|��z}t%|���)Nc�6�g|]}tj|����Sr&r�)r�r7s  r)r�zfind_source.<locals>.<listcomp>�s#��8�8�8�1�
�#�A�&�&�8�8�8r+�networkrz#Searching for %s data source in: %sz	search-%srrRzsearching 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_sources�DEP_NETWORKr�r��zipr�ReportEventStackr]r�rr�r�rr�r
rr	r�rM)r�r�r��ds_deps�cfg_list�pkg_list�reporter�ds_list�ds_namesr�r��cls�myrep�s�msgs               r)�find_sourcer��sA���8�W�h�7�7�G�8�8��8�8�8�H�#�w�.�.�9�9�G�D��I�I�3�T�8�D�D�D���7�+�+�A�A�	��c��'��t�|�|�L�"�=�=�=�=�;?�4�4���F�F�26�$�$���=��	
�
�
��
	A��
9�
9��	�	�A�3�G�G�G��C����/�/���1�1��0�1���9�9�@D�t�t�T�T�$J�E�M��z�2�3�7�7�8�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9����	A�	A�	A��K��:�C�@�@�@�@�@�	A����A�4�9�9��D�D��C�&�c�
*�
*�*s=�D.�A+D"�D.�D.�"D&	�&D.�)D&	�*D.�.%E�Ec��g}t�d|||��|D]�}|�t��st�|��}t	j||dg��\}}|st�d|��|D]J}t	j|��}t|d��}	|	|��}
|
r|�	|
��n�K��|S)NzLLooking 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\�	DS_PREFIXr�find_module�error�
import_moduler�r`)r��dependsr��src_list�ds_name�m_locs�_looked_locs�m_loc�mod�lister�matchess           r)r�r��s���H��I�I�	8������������!�!�)�,�,�	4� )�	�7�7�3�G�'�3��X� 5�6� 
� 
�����	��I�I�$��
�
�
�
�	�	�E��(��/�/�C��S�"7�8�8�F��f�W�o�o�G��
�����(�(�(���
���Or+�system-uuid�fieldc��|sdStj|��}|sdS|���|���kSr9)r�
read_dmi_datar")r�r��	dmi_values   r)�instance_id_matches_system_uuidr��sO��
���u��!�%�(�(�I����u������)�/�/�"3�"3�3�3r+c��|st}|st}|tkr|tkr|S|St���D].\}}|\}}|�|��r||��r|cS�/|tkr|S|S)z@Lookup the canonical cloud-id for a given cloud_name and region.)r(�CLOUD_ID_REGION_PREFIX_MAPrYr\)r�r�r��prefix�
cloud_id_testr��valid_clouds       r)r�r��s����&�%�
��"�!��
�!�!�!��)�)�)�����!;�!A�!A�!C�!C�����
�"/���;����V�$�$�	���Z�)@�)@�	��O�O�O���%�%�%����Or+Tc�`�|sdSt|t��r|St|t��rtj|��St|t
��r7|dur$t
|�d��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)
r[rHr�rWrXr^�convert_vendordatarmrr-)�datar�s  r)r�r�s������t��$��������$����#��}�T�"�"�"��$����D��d�?�?�%�d�h�h�|�&<�&<�e�L�L�L�L��B�C�C�C�
�;�d�4�j�j�H�
I�
I�Ir+c��eZdZdS)�BrokenMetadataNrNr&r+r)r�r�rOr+r�c��g}t|��}|D]-\}}|t|��kr|�|���.|Sr9)rwrZ)r�r��ret_list�depsetr��depss      r)�list_from_dependsr�'sN���H�
��\�\�F��!�!���d��S��Y�Y����O�O�C� � � ���Or+rq�fnamec��	tj|��}n,#t$rtjt
d|��YdSwxYw	tj||dd���n,#t$rtjt
d|��YdSwxYwdS)z[Use pickle to serialize Datasource to a file as a cache.

    :return: True on success
    zFailed pickling datasource %sF�wb�)�omoder�z Failed pickling datasource to %sT)�pickle�dumpsr
rr	r�r�)rqr��pk_contentss   r)r�r�0s���
��l�3�'�'����������C�8�#�>�>�>��u�u���������{�$�U�C�C�C�C�C��������C�;�U�C�C�C��u�u������4s ��%A�A�A�%B�Bc�|�d}	tj|d���}nR#t$rE}tj�|��rt�d||��Yd}~nd}~wwxYw|sdS	tj	|��S#t$rYdSt$rtjtd|��YdSwxYw)zBUse pickle to deserialize a instance Datasource from a cache file.NF)�decodezfailed loading pickle in %s: %sz#Failed loading pickled blob from %s)r�	load_filer
r�rr�isfiler�r�r�r�rJr	)r��pickle_contentsr�s   r)�pkl_loadr�Bs����O�E��.��u�=�=�=�����E�E�E�
�7�>�>�%� � �	E��K�K�9�5�!�D�D�D����������E����
���t���|�O�,�,�,��*�����t�t�������C�>��F�F�F��t�t����s,��
A*�;A%�%A*�2B�
B;�$B;�:B;)rRr&)r�r�)R�abcrWr�r�r��collectionsr�enumrr�typingrrrr	r
�	cloudinitrrr
�loggingrrrr�r�cloudinit.atomic_helperr�cloudinit.distrosr�cloudinit.eventrr�cloudinit.filtersr�cloudinit.helpersr�cloudinit.persistencer�cloudinit.reportingr�DSMODE_DISABLED�DSMODE_LOCALr��DSMODE_PASSr��DEP_FILESYSTEMr�r�r��REDACT_SENSITIVE_VALUEr+r�r(�	getLoggerr?r�r�r1r
rJrMrQr_rsrtry�ABCMetarrBrHr�r�r�r�r�r��IOErrorr�r�r�r�r&r+r)�<module>rs����
�
�
���������	�	�	�	�
�
�
�
�"�"�"�"�"�"���������3�3�3�3�3�3�3�3�3�3�3�3�3�3�#�#�#�#�#�#�#�#�$�$�$�$�$�$�%�%�%�%�%�%�%�%�%�%�%�%�%�%�������.�.�.�.�.�.�$�$�$�$�$�$�1�1�1�1�1�1�1�1�*�*�*�*�*�*�#�#�#�#�#�#�6�6�6�6�6�6�&�&�&�&�&�&��������� �,��?�
������	�<��6��'�������g���!�!��

�-�-�.��/�/�0��3�3�
4�����
�
�
�
�
�$�
�
���
� P�P�P�P�P�i�P�P�P�	�	�	�	�	�)�	�	�	�C�C�C�C�C�y�C�C�C�����@2H�����$
�J�����
�
�	� �Z��������[�[�[�[�[�%���[�[�[�[�|���:+�
�:�s�?��+�+�+�+�J���@,�4�4��4�	�4�4�4�4����&J�J�J�J�0	�	�	�	�	�W�	�	�	�����:��c��d�����$�C��H�Z�0������r+