%PDF- %PDF-
Mini Shell

Mini Shell

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

�

���f����ddlZddlZddlZddlmZddlmZddlmZmZddd�Z	eje�Zdd�Z
d	�Zdd
�Zd�Zdd�Zd
�Zy)�N)�dmi)�net)�
url_helper�util�eth0�eth1)�public�privatec���|s!t|�}tjd|�|std��dj	tjdd�tjdd��}	|jj||�|jj|�tjd||�|S#t$rtjtd	||��wxYw)
z�Bring up NIC using an address using link-local (ip4LL) IPs.
    On DigitalOcean, the link-local domain is per-droplet routed, so there
    is no risk of collisions. However, to be more safe, the ip4LL
    address is random.
    z,selected interface '%s' for reading metadatazPunable to find interfaces to access themeta-data server. This droplet is broken.z169.254.{0}.{1}/16��r�z&brought device '%s' up with address %szRip4LL address assignment of '%s' to '%s' failed. Droplet networking will be broken)
�get_link_local_nic�LOG�debug�RuntimeError�format�random�randint�net_ops�add_addr�link_up�	Exceptionr�logexc)�distro�nic�addrs   �H/usr/lib/python3/dist-packages/cloudinit/sources/helpers/digitalocean.py�assign_ipv4_link_localrs���� ��(���	�	�@�#�F���
8�
�	
�
 �&�&����q�#�����q�#� 6��D��������T�*������s�#��	�	�:�C��F��J��������
1���	
�	��s
�,AB<�<'C#c��tj�D�cgc]}|jj|�r|��!}}|syt	|d���Scc}w)Nc�.�tj|d�S)N�ifindex)�cloudnet�read_sys_net_int)�ds r�<lambda>z$get_link_local_nic.<locals>.<lambda>@s��8�#<�#<�Q�	�#J��)�key)r#�get_devicelist�
networking�is_physical�min)r�f�nicss   rrr8sY���(�(�*��
����(�(��+�	
��D��
���t�J�K�K��s�$Ac�&�|stjd�ytjd�	|jj|�tjd|�y#t$r&}tjtd||�Yd}~yd}~wwxYw)zwRemove the ip4LL address. While this is not necessary, the ip4LL
    address is extraneous and confusing to users.
    zLno link_local address interface defined, skipping link local address cleanupNzcleaning up ipv4LL addresszremoved ip4LL addresses from %sz)failed to remove ip4LL address from '%s'.)rrr�
flush_addrrrr)rr�es   r�del_ipv4_link_localr2Csy����	�	�
$�	
�	��I�I�*�+�N����!�!�#�&��	�	�3�S�9���N����C�D�c�1�M�M��N�s�1A!�!	B�*B�Bc�*�d�}g}tj�}tjd|�|D�].}||d}tjd|�|j	d�}||vrtd|�d|����|j	|�}|j	dd	�}	tj	|	|�}
|
|k7rtjd
|	|||
�nd}tj|||�d||
d
�}g}
dD]<}|j	|d�}|s�||�}|	dk7sd|vr|d=|
j|��>|
|d<|j|�tjd|
|���1|r*tjd|�|jd|d��d|d�S)a}Convert the DigitalOcean Network description into Cloud-init's netconfig
    format.

    Example JSON:
     {'public': [
           {'mac': '04:01:58:27:7f:01',
            'ipv4': {'gateway': '45.55.32.1',
                     'netmask': '255.255.224.0',
                     'ip_address': '45.55.50.93'},
            'anchor_ipv4': {
                     'gateway': '10.17.0.1',
                     'netmask': '255.255.0.0',
                     'ip_address': '10.17.0.9'},
            'type': 'public',
            'ipv6': {'gateway': '....',
                     'ip_address': '....',
                     'cidr': 64}}
        ],
       'private': [
           {'mac': '04:01:58:27:7f:02',
            'ipv4': {'gateway': '10.132.0.1',
                     'netmask': '255.255.0.0',
                     'ip_address': '10.132.75.35'},
            'type': 'private'}
        ]
     }
    c��dd|jd�|jd�d�}d|jd�vr5dj|jd�|jd��|d	<|S|jd
�|d
<|S)N�static�auto�
ip_address�gateway)�type�control�addressr8�:z{0}/{1}�cidrr;�netmask)�getr)�pcfg�subparts  r�_get_subnet_partz7convert_network_configuration.<locals>._get_subnet_partus������x�x��-��x�x�	�*�	
���$�(�(�<�(�(�!*�!1�!1�����&�����(8�"�G�I����"&���)�!4�G�I���r'znic mapping: %srzconsidering %s�macz3Did not find network interface on system with mac 'z'. Cannot apply configuration: r9�unknownz6Found %s interface '%s' on '%s', assigned name of '%s'zfFound interface '%s' on '%s', which is not a public or private interface. Using default system naming.�physical)r9�mac_address�name)�ipv4�ipv6�anchor_ipv4�anchor_ipv6Nr	�anchorr8�subnetsznic '%s' configuration: %szadded dns servers: %s�
nameserver)r9r;r)�version�config)r#�get_interfaces_by_macrrr?r�NIC_MAP�append)rP�dns_serversrB�nic_configs�macs_to_nics�nrrF�
sysfs_name�nic_type�if_name�msg�ncfgrM�netdef�
raw_subnet�sub_parts                 r�convert_network_configurationr`Xs���:�"�K��1�1�3�L��I�I���.�
�3?���Q�i��l���	�	�"�C�(��g�g�e�n���l�*����%��
�"�%�%�k�2�
��7�7�6�9�-���+�+�h�
�3���j� ��I�I�H�����
�E�
�
�I�I�c�;�
�3��&��
����D�		%�F������.�J���'�
�3�H��8�#�x�6�'9��Y�'��N�N�8�$�		%�"��Y�����4� ��	�	�.���>�g3?�j��	�	�)�;�7����L�[�I�J��K�0�0r'c���tj||||��}|j�std|z��t	j
|jj��S)N)�timeout�sec_between�retrieszunable to read metadata at %s)r�readurl�okr�json�loads�contents�decode)�urlrbrcrd�responses     r�
read_metadatarm�sU���!�!��W�+�w��H��;�;�=��:�S�@�A�A��:�:�h�'�'�.�.�0�1�1r'c���tjd�}|dk7rytjd�}|rtjd|�d|fSd}tj	|�t|��)Nzsystem-manufacturer�DigitalOcean)FNzsystem-serial-numberz8system identified via SMBIOS as DigitalOcean Droplet: %sz�system identified via SMBIOS as a DigitalOcean Droplet, but did not provide an ID. Please file a support ticket at: https://cloud.digitalocean.com/support/tickets/newT)r�
read_dmi_datarr�criticalr)�vendor_name�
droplet_idr[s   r�read_sysinfort�sw��
�#�#�$9�:�K��n�$���"�"�#9�:�J���	�	�F��	
�
�*���
A�	�	���S���3��r')N)�ru�)rg�loggingr�	cloudinitrrr#rrrR�	getLogger�__name__rrrr2r`rmrt�r'r�<module>r|sX��
��
��%�&���
/���g����!��#�LL�N�*k1�\2�r'

Zerion Mini Shell 1.0