관리-도구
편집 파일: upcloud.cpython-39.pyc
a ����'�Dg�����������������������@���sd���d�dl�Z�d�dlZd�dlmZ�d�dlmZ�d�dlmZ�e�e�Z dd��Z dd��Zddd�Zd d��Z dS�)�����N)�dmi)�net)� url_helperc�������������� ���C���s��dd��}g�}t����}t�d|��|��d�D�]�}t�d|��|�d�}||vr\td||f���|�d�}|�|�}t�d ||||�d ���d||d�}g�} |�d �D�]} || |��d��}| �|��q�| |d<�|�|��q*|��d��r t�d|��d���|�d|��d�d���d|d�S�)aC �� Convert the UpCloud network metadata description into Cloud-init's version 1 netconfig format. Example JSON: { "interfaces": [ { "index": 1, "ip_addresses": [ { "address": "94.237.105.53", "dhcp": true, "dns": [ "94.237.127.9", "94.237.40.9" ], "family": "IPv4", "floating": false, "gateway": "94.237.104.1", "network": "94.237.104.0/22" }, { "address": "94.237.105.50", "dhcp": false, "dns": [], "family": "IPv4", "floating": true, "gateway": "", "network": "94.237.105.50/32" } ], "mac": "32:d5:ba:4a:36:e7", "network_id": "031457f4-0f8c-483c-96f2-eccede02909c", "type": "public" }, { "index": 2, "ip_addresses": [ { "address": "10.6.3.27", "dhcp": true, "dns": [], "family": "IPv4", "floating": false, "gateway": "10.6.0.1", "network": "10.6.0.0/22" } ], "mac": "32:d5:ba:4a:84:cc", "network_id": "03d82553-5bea-4132-b29a-e1cf67ec2dd1", "type": "utility" }, { "index": 3, "ip_addresses": [ { "address": "2a04:3545:1000:720:38d6:baff:fe4a:63e7", "dhcp": true, "dns": [ "2a04:3540:53::1", "2a04:3544:53::1" ], "family": "IPv6", "floating": false, "gateway": "2a04:3545:1000:720::1", "network": "2a04:3545:1000:720::/64" } ], "mac": "32:d5:ba:4a:63:e7", "network_id": "03000000-0000-4000-8046-000000000000", "type": "public" }, { "index": 4, "ip_addresses": [ { "address": "172.30.1.10", "dhcp": true, "dns": [], "family": "IPv4", "floating": false, "gateway": "172.30.1.1", "network": "172.30.1.0/24" } ], "mac": "32:d5:ba:4a:8a:e1", "network_id": "035a0a4a-77b4-4de5-820d-189fc8135714", "type": "private" } ], "dns": [ "94.237.127.9", "94.237.40.9" ] } c�����������������S���s����|���d�r(d}|���d�dkr d}d|iS�d}|���d�dkr>d}|d|���d �d �}|���d�rh|���d�|d<�d|���d �v�r�|���d ��d�d�|d<�||���d�kr�|���d�r�|���d�|d<�|S�)NZdhcpZfamilyZIPv6zipv6_dhcpv6-stateless�typeZstaticZstatic6�auto�address)r���Zcontrolr���Zgateway�/�network�����netmask�dnsZdns_nameservers)�get�split)Zip_addrr���Z dhcp_typeZstatic_typeZsubpart��r����E/usr/lib/python3.9/site-packages/cloudinit/sources/helpers/upcloud.py�_get_subnet_configr���s&���� � z8convert_to_network_config_v1.<locals>._get_subnet_configzNIC mapping: %sZ interfaceszConsidering %sZmaczVDid not find network interface on system with mac '%s'. Cannot apply configuration: %sr���z4Found %s interface '%s' with address '%s' (index %d)�indexZphysical)r����name�mac_addressZip_addressesr����subnetszSetting DNS nameservers to %sZ nameserver)r���r���r ���)�version�config)�cloudnetZget_interfaces_by_mac�LOG�debugr ����RuntimeError�append)r���r���Znic_configsZmacs_to_interfacesZ raw_ifacer���Z iface_typeZ sysfs_nameZ interfacer���� ip_addressZsub_partr���r���r����convert_to_network_config_v1���sL����c �� � ��r���c�����������������C���s���t�|��S�)N)r���)r���r���r���r����convert_network_config����s����r�����������c�����������������C���s6���t�j|�|||d�}|���s&td|����t�|j����S�)N)�timeout�sec_between�retrieszunable to read metadata at %s)r���Zreadurl�okr����json�loads�contents�decode)�urlr"���r#���r$���Zresponser���r���r���� read_metadata����s�����r+���c������������������C���sP���t��d�}�|�dkrdS�t��d�}|r2t�d|��nd}t�|��t|��d|fS�)Nzsystem-manufacturerZUpCloud)FNzsystem-uuidz2system identified via SMBIOS as UpCloud server: %sz�system identified via SMBIOS as a UpCloud server, but did not provide an ID. Please contact support viahttps://hub.upcloud.com or via email with support@upcloud.comT)r���Z read_dmi_datar���r���Zcriticalr���)Zvendor_nameZserver_uuid�msgr���r���r����read_sysinfo����s���� �� r-���)r ���r ���r!���)r&���ZloggingZ cloudinitr���r���r���r���Z getLogger�__name__r���r���r���r+���r-���r���r���r���r����<module>���s��� �2