HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/aliyun.cpython-310.pyc
o

x[h��@s�ddlZddlmZddlmZmZmZddlmZe�	e
�Z								ddd	�Z									dd
d�Z
			dd
d�ZdS)�N)�MutableMapping)�net�
url_helper�util)�ec2�latest�http://100.100.100.200�c	sPt�||�}t�|d�}tj|||||||d�}	t�|	j�}
�fdd���|
�S)Nz
meta-data/all��ssl_details�timeout�retries�exception_cb�
headers_cb�headers_redactcsJt|t�r�fdd�|��D�St|t�r�fdd�|D�St��d|�S)Ncsi|]	\}}|�|��qS�r)�.0�k�v��_process_dict_valuesr�B/usr/lib/python3/dist-packages/cloudinit/sources/helpers/aliyun.py�
<dictcomp>WszHget_instance_meta_data.<locals>._process_dict_values.<locals>.<dictcomp>csg|]}�|��qSrr)r�itemrrr�
<listcomp>YszHget_instance_meta_data.<locals>._process_dict_values.<locals>.<listcomp>�)�
isinstance�dict�items�listr�MetadataLeafDecoder)�drrrrUs


z4get_instance_meta_data.<locals>._process_dict_values)r�combine_url�read_file_or_urlr�	load_json�contents)�api_version�metadata_addressrrr
rrr�ud_url�response�
meta_data_rawrrr�get_instance_meta_datas
�	4r+c	
	Cs�t�||�}	t�|	|�}	d}
ddg}||vrt�d|�|
Sztj|	||||||d�}|j}
W|
StyBt�td||	�Y|
Sw)N�z	user-datazvendor-dataz*aliyun datasource not support the item  %sr
zFailed fetching %s from url %s)	rr"�LOG�errorr#r%�	Exceptionr�logexc)
r&r'rrr
rrr�	item_namer(�data�support_items_listr)rrr�get_instance_data`s4��	��r4TcCs�did�}|st��}|dd}|sC|��D]
\}}||kr!nqddd|��i|d�}|�|�}	|	�d	�r;d|d
<||d|<|St�}
|��D]\}}|�|�}	|	sVqJ||
|<qJt|
��tjd�}t	|�D]4\}}|
|}
|�|
�}	d
|ddi}d|dd|
��i|d�}|	�d	�r�d|d
<||d<||d|<qht
|d�dkr�|d��D])}|d|�d�|d|�dd�|d|�dd�|d|�dd�q�|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�ipv6sr<r7)�keyzroute-metric��d)r;�dhcp4-overridesr<r=r>zdhcp6-overridesrCN�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_overriderrr�#convert_ecs_metadata_network_config�sb
�
�




�

�
r])rrNr	r	NNN)	rrNr	r	NNNN)NNT)�logging�typingr�	cloudinitrrr�cloudinit.sources.helpersr�	getLogger�__name__r-r+r4r]rrrr�<module>s8

�U
�'�