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

x[h����ddlZddlmZddlmZmZmZddlmZeje
�Z								dd�Z									d	d�Z
			d
d�Zy)�N)�MutableMapping)�net�
url_helper�util)�ec2c	����tj||�}tj|d�}tj|||||||��}	tj|	j
�}
�fd���|
�S)Nz
meta-data/all��ssl_details�timeout�retries�exception_cb�
headers_cb�headers_redactc���t|t�r*|j�D��cic]\}}|�|���c}}St|t�r|D�cgc]
}�|���c}St	j
�d|�Scc}}wcc}w)N�)�
isinstance�dict�items�listr�MetadataLeafDecoder)�d�k�v�item�_process_dict_valuess    ��B/usr/lib/python3/dist-packages/cloudinit/sources/helpers/aliyun.pyrz4get_instance_meta_data.<locals>._process_dict_valuesUsu����a���;<�7�7�9�E�4�1�a�A�+�A�.�.�E�E�
��4�
 �;<�=�4�(��.�=�=�,�3�*�*�,�R��3�3��	F��=s�A=�B)r�combine_url�read_file_or_urlr�	load_json�contents)�api_version�metadata_addressr
rrrrr
�ud_url�response�
meta_data_rawrs           @r�get_instance_meta_datar&sx����
#�
#�$4�k�
B�F�
�
#�
#�F�O�
<�F��*�*�����!��%��H�!�N�N�8�+<�+<�=�M�h4� �
�.�.�c		�L�tj||�}	tj|	|�}	d}
ddg}||vrtjd|�|
S	tj|	||||||��}|j
}
|
S#t$r tjtd||	�Y|
SwxYw)Nr'z	user-datazvendor-dataz*aliyun datasource not support the item  %sr	zFailed fetching %s from url %s)	rr�LOG�errorrr �	Exceptionr�logexc)
r!r"r
rrrrr
�	item_namer#�data�support_items_listr$s
             r�get_instance_datar0`s����
#�
#�$4�k�
B�F�
�
#�
#�F�I�
6�F��D�%�}�5���*�*��	�	�8��	
���N��.�.��#���%�!�)�
��� � ���K���N����C�9�9�f�M��K�N�s�(A:�:%B#�"B#c���did�}|stj�}|dd}|sg|j�D]\}}||k(s�ndddj�id�}|j	|�}	|	j	d	�rd|d
<||d|<|St�}
|j�D]\}}|j	|�}	|	s�||
|<� t
|
j�tj��}t|�D]`\}}|
|}
|j	|
�}	d
|dzdzi}d|dd|
j�i|d�}|	j	d	�r
d|d
<||d<||d|<�bt|d�dk(rw|dj�D]a}|d|jd�|d|jdd�|d|jdd�|d|jdd��c|S)a�Convert ecs metadata to network config version 2 data dict.

    @param: network_md: 'network' portion of ECS metadata.
    generally formed as {"interfaces": {"macs": {}} where
    'macs' is a dictionary with mac address as key:
    @param: macs_to_nics: Optional dict of mac addresses and nic names. If
    not provided, get_interfaces_by_mac is called to get it from the OS.
    @param: fallback_nic: Optionally provide the primary nic interface name.
    This nic will be guaranteed to minimally have a dhcp4 configuration.
    @param: full_network_config: Boolean set True to configure all networking
    presented by IMDS. This includes rendering secondary IPv4 and IPv6
    addresses on all NICs and rendering network config on secondary NICs.
    If False, only the primary nic will be configured and only with dhcp
    (IPv4/IPv6).

    @return A dict of network config version 2 based on the metadata and macs.
    �)�version�	ethernets�
interfaces�macsTF�
macaddress)�dhcp4�dhcp6�match�set-name�ipv6sr9r4)�keyzroute-metric��d)r8�dhcp4-overridesr9r:r;zdhcp6-overridesr@N�routeszrouting-policy)r�get_interfaces_by_macr�lower�getr�sorted�keys�natural_sort_key�	enumerate�len�pop)�
network_md�macs_to_nics�fallback_nic�full_network_config�netcfg�
macs_metadata�mac�nic_name�
dev_config�nic_metadata�nic_name_2_mac_map�orderd_nic_name_list�nic_idx�nic_mac�
dhcp_overrides               r�#convert_ecs_metadata_network_configrZ�s]��.*+��<�F���0�0�2���|�,�V�4�M��)�/�/�1�	�M�C���<�'��	���"�C�I�I�K�0� �	&
�
�%�(�(��-�����G�$�"&�J�w��(2��{��H�%��
����%�+�+�-�+�
��X�$�(�(��-����'*��8�$�	+�"����!�s�';�';���'�';�<�3����$�X�.��$�(�(��1��'�'�A�+��)<�=�
��,��"�G�M�M�O�4� �
�
����G�$�"&�J�w��,9�J�(�)�(2��{��H�%�3�$�6�+���1�$��{�+�0�0�2�	F�H��;���)�-�-�.?�@��;���)�-�-�.?��F��;���)�-�-�h��=��;���)�-�-�.>��E�		F�
�Mr')�latest�http://100.100.100.200N�r]NNN)	r[r\Nr]r]NNNN)NNT)�logging�typingr�	cloudinitrrr�cloudinit.sources.helpersr�	getLogger�__name__r)r&r0rZ�r'r�<module>res}���!�+�+�)��g����!���-��
�
����Q/�j�-��
�
�����"�N���	Nr'