%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/distros/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/distros/__pycache__/networking.cpython-312.pyc

�

�f+����ddlZddlZddlZddlmZmZmZddlmZeje
�ZeZ
eZGd�dej ��ZGd�de�ZGd	�d
e�ZGd�de�Zy)
�N)�net�subp�util)�ifconfigc��eZdZdZdefd�Zdd�deddfd�Zejde
ddfd	��Zd
efd�Z
d
efd�Zde
defd
�Zd�Zdd�defd�Zdefd�Zdefd�Zd
edefd�Zd
efd�Zdefd�Zdefd�Zd
efd�Zdd�d
ededefd�Zd
edefd�Zd
edefd�Zejd
edefd ��Zd
edefd!�Zd
edefd"�Zd
edefd#�Z d
edefd$�Z!ejdd%�d*d&��Z"d'd�de
deddfd(�Z#ejd
edefd)��Z$y)+�
NetworkingaThe root of the Networking hierarchy in cloud-init.

    This is part of an ongoing refactor in the cloud-init codebase, for more
    details see "``cloudinit.net`` -> ``cloudinit.distros.networking``
    Hierarchy" in CONTRIBUTING.rst for full details.
    �returnc�*�tj�S�N)r�_get_current_rename_info��selfs �>/usr/lib/python3/dist-packages/cloudinit/distros/networking.pyrz#Networking._get_current_rename_infos���+�+�-�-�N��current_info�renamesc�0�tj||��S)Nr)r�_rename_interfaces)rrrs   rrzNetworking._rename_interfacess���%�%�g�L�I�Ir�netcfgc��y)z7Read the network config and rename devices accordingly.N��rrs  r�apply_network_config_namesz%Networking.apply_network_config_names��r�devnamec�,�tj|�Sr)r�device_devid�rrs  rrzNetworking.device_devid#s������(�(rc�,�tj|�Sr)r�
device_driverrs  rr!zNetworking.device_driver&s��� � ��)�)rc�,�tj|�Sr)r�extract_physdevsrs  rr#zNetworking.extract_physdevs)s���#�#�F�+�+rc�*�tj�Sr)r�find_fallback_nicr
s rr%zNetworking.find_fallback_nic,s���$�$�&�&rF��
config_driverr'c�.�tj|��S)Nr&)r�generate_fallback_config)rr's  rr)z#Networking.generate_fallback_config/s���+�+�-�H�Hrc�*�tj�Sr)r�get_devicelistr
s rr+zNetworking.get_devicelist2����!�!�#�#rc�*�tj�Sr)r�get_ib_hwaddrs_by_interfacer
s rr.z&Networking.get_ib_hwaddrs_by_interface5s���.�.�0�0r�ethernet_formatc�.�tj||�Sr)r�get_ib_interface_hwaddr)rrr/s   rr1z"Networking.get_ib_interface_hwaddr8s���*�*�7�O�D�Drc�,�tj|�Sr)r�get_interface_macrs  rr3zNetworking.get_interface_mac=����$�$�W�-�-rc�*�tj�Sr)r�get_interfacesr
s rr6zNetworking.get_interfaces@r,rc�*�tj�Sr)r�get_interfaces_by_macr
s rr8z Networking.get_interfaces_by_macCs���(�(�*�*rc�,�tj|�Sr)r�
get_masterrs  rr:zNetworking.get_masterF����~�~�g�&�&r��strictr=c�0�tj||��S)Nr<)r�interface_has_own_mac)rrr=s   rr?z Networking.interface_has_own_macIs���(�(���@�@rc�,�tj|�Sr)r�is_bondrs  rrAzNetworking.is_bondN����{�{�7�#�#rc�,�tj|�Sr)r�	is_bridgers  rrDzNetworking.is_bridgeQs���}�}�W�%�%rc��y)z�
        Is ``devname`` a physical network device?

        Examples of non-physical network devices: bonds, bridges, tunnels,
        loopback devices.
        Nrrs  r�is_physicalzNetworking.is_physicalTrrc�,�tj|�Sr)r�
is_renamedrs  rrHzNetworking.is_renamed]r;rc�,�tj|�Sr)r�is_uprs  rrJzNetworking.is_up`s���y�y��!�!rc�,�tj|�Sr)r�is_vlanrs  rrLzNetworking.is_vlancrBrc�,�tj|�Sr)r�master_is_bridge_or_bondrs  rrNz#Networking.master_is_bridge_or_bondfs���+�+�G�4�4r��existsc��y)a�Wait for device population in the system to complete.

        :param exists:
            An optional optimisation.  If given, only perform as much of the
            settle process as is required for the given DeviceName to be
            present in the system.  (This may include skipping the settle
            process entirely, if the device already exists.)
        :type exists: Optional[DeviceName]
        Nr�rrPs  r�settlezNetworking.settleirrTc	���|j|�}t|D�cgc]}|d|df��c}�}t|j��}|j	�j�}td�D]�}|j
|�rtjd�y|j|�}	tjd|	�|	D]K}
||
}dj|�}tjtj||jd|i�	��M|j	�j�}��d
	z}tj|�|rt|��ycc}w)a�Wait for all the physical devices in `netcfg` to exist on the system

        Specifically, this will call `self.settle` 5 times, and check after
        each one if the physical devices are now present in the system.

        :param netcfg:
            The NetworkConfig from which to extract physical devices to wait
            for.
        :param strict:
            Raise a `RuntimeError` if any physical devices are not present
            after waiting.
        r��z*net: all expected physical devices presentNz)net: waiting for expected net devices: %szWaiting for settle or {} existsrP)�func�kwargsz-Not all expected physical devices present: %s)r#�dict�set�keysr8�range�issubset�LOG�debug�
difference�formatr�log_timerS�warning�RuntimeError)
rrr=�physdevs�iface�expected_ifaces�
expected_macs�present_macs�_�missing�macr�msgs
             r�wait_for_physdevszNetworking.wait_for_physdevsusO���(�(��0���(�K���q��5��8� 4�K�L���O�0�0�2�3�
��1�1�3�8�8�:���q��	?�A��%�%�l�3��	�	�F�G��#�.�.�|�<�G��I�I�A�7�K��	
��)�#�.��7�>�>�w�G���
�
��I�I�����$�g�.�	�		
� �5�5�7�<�<�>�L�'	?�*>��G�����C����s�#�#���C Ls�Ec��y)z=Try setting the link to up explicitly and return if it is up.Nrrs  r�try_set_link_upzNetworking.try_set_link_up�rr�r	N)%�__name__�
__module__�__qualname__�__doc__rYr�listr�abc�abstractmethod�
NetworkConfigr�
DeviceNamerr!r#r%�boolr)r+r.r1r3r6r8r:r?rArDrFrHrJrLrNrSrnrprrrrrs-���.�$�.�AE�J�$�J��J�	���F��F�4�F��F�)�J�)�*�Z�*�,�}�,��,�'�AF�I��I�$��$�1�T�1�E�!�E�48�E�
.��.�$��$�+�t�+�'�*�'�6;�A�!�A�.2�A�	
�A�
$�z�$�d�$�&��&��&�	����:��$����'�*�'��'�"�Z�"�D�"�$�z�$�d�$�5�
�5�t�5�	���#�	��	�8<�4$�#�4$�04�4$�	
�4$�l	���L�z�L�d�L��Lrr)�	metaclassc���eZdZdZ�fd�Zd�Zdeddfd�Zdede	fd	�Z
dede	fd
�Zdede	fd�Zdede	fd�Z
dede	fd
�Zdd�dd�Zdede	fd�Z�xZS)�
BSDNetworkingz>Implementation of networking functionality shared across BSDs.c���tj�|_i|_|j	�t
�|��yr)r�Ifconfig�ifc�ifs�_update_ifs�super�__init__)r�	__class__s �rr�zBSDNetworking.__init__�s1����$�$�&����������
���rc��tjddg�}|dr$|jj|d�|_yy)Nrz-ar)rr��parser�)r�ifconfs  rr�zBSDNetworking._update_ifs�s;�����J��-�.���!�9��x�x�~�~�f�Q�i�0�D�H�rrr	Nc�.�tjd�y)Nz Cannot rename network interface.)r^r_rs  rrz(BSDNetworking.apply_network_config_names�s���	�	�4�5rrc�4�|j|jSr)r�rFrs  rrFzBSDNetworking.is_physical�s���x�x�� �,�,�,rc�4�|j|jSr)r�rArs  rrAzBSDNetworking.is_bond�����x�x�� �(�(�(rc�4�|j|jSr)r�rDrs  rrDzBSDNetworking.is_bridge�s���x�x�� �*�*�*rc�4�|j|jSr)r�rLrs  rrLzBSDNetworking.is_vlan�r�rc�4�|j|jSr)r��uprs  rrJzBSDNetworking.is_up�s���x�x�� �#�#�#rrOc��y)z0BSD has no equivalent to `udevadm settle`; noop.NrrRs  rrSzBSDNetworking.settle�rrc�T�tjd|dg�|j|�S)��Try setting the link to up explicitly and return if it is up.
        Not guaranteed to bring the interface up. The caller is expected to
        add wait times before retrying.rr��rrJrs  rrpzBSDNetworking.try_set_link_up�s&��	
�	�	�:�w��-�.��z�z�'�"�"rrq)rrrsrtrur�r�ryrrzr{rFrArDrLrJrSrp�
__classcell__)r�s@rr~r~�s����H��1�6��6�4�6�-�:�-�$�-�)�z�)�d�)�+��+��+�)�z�)�d�)�$�Z�$�D�$� $�?�#�z�#�d�#rr~c�,�eZdZdeddfd�Zdedefd�Zy)�FreeBSDNetworkingrr	Nc��yrrrs  rrz,FreeBSDNetworking.apply_network_config_names�s��
	
rrc��|j|jsytjdd|gddg��\}}|dj|�k(ryy)	NF�devinfoz-prrU)�rcszdevinfo: {}: Not found
T)r�rFrra)rrrj�errs    rrHzFreeBSDNetworking.is_renamed�sT���x�x�� �,�,�����I�t�W�5�A�q�6�B���3��,�3�3�G�<�<��r)rrrsrtryrrzr{rHrrrr�r��s(��
��
�4�
��*���rr�c��eZdZdZdeddfd�Zdedefd�Zdede	fd�Z
dede	fd	�Zdede	fd
�Zdede	fd�Z
dede	fd�Zdede	fd
�Zdd�dd�Zdede	fd�Zy)�LinuxNetworkingzCImplementation of networking functionality common to Linux distros.rr	Nc��	|j|j|��y#t$r}td|z�|�d}~wwxYw)z�Read the network config and rename devices accordingly.

        Renames are only attempted for interfaces of type 'physical'. It is
        expected that the network system will create other devices with the
        correct name in place.
        z(Failed to apply network config names: %sN)rr#rd)rr�es   rrz*LinuxNetworking.apply_network_config_namessH��	��#�#�D�$9�$9�&�$A�B���	��:�Q�>���
��	�s� #�	A�;�Arc�,�tj|�Sr)r�get_dev_featuresrs  rr�z LinuxNetworking.get_dev_featuress���#�#�G�,�,rc�,�tj|�Sr)r�has_netfail_standby_featurers  rr�z+LinuxNetworking.has_netfail_standby_features���.�.�w�7�7rc�,�tj|�Sr)r�is_netfailoverrs  rr�zLinuxNetworking.is_netfailovers���!�!�'�*�*rc�,�tj|�Sr)r�is_netfail_masterrs  rr�z!LinuxNetworking.is_netfail_masterr4rc�,�tj|�Sr)r�is_netfail_primaryrs  rr�z"LinuxNetworking.is_netfail_primary����%�%�g�.�.rc�,�tj|�Sr)r�is_netfail_standbyrs  rr�z"LinuxNetworking.is_netfail_standbyr�rc�h�tjjtj|d��S)N�device)�os�pathrPr�sys_dev_pathrs  rrFzLinuxNetworking.is_physical"s"���w�w�~�~�c�.�.�w��A�B�BrrOc�^�|�tj|�}tj|��y)NrO)rr�r�udevadm_settlerRs  rrSzLinuxNetworking.settle%s&�����%�%�f�-�F����6�*rc�X�tjddd|dg�|j|�S)r��ip�linkrZr�r�rs  rrpzLinuxNetworking.try_set_link_up*s*��	
�	�	�4�����6�7��z�z�'�"�"rrq)rrrsrtruryrrz�strr�r{r�r�r�r�r�rFrSrprrrr�r��s���M�
��
�4�
�-�
�-�s�-�8�:�8�$�8�+�j�+�T�+�.��.��.�/�*�/��/�/�*�/��/�C�:�C�$�C� $�+�
#�z�#�d�#rr�)rw�loggingr��	cloudinitrrr�cloudinit.distros.parsersr�	getLoggerrrr^r�rzrYry�ABCMetarr~r�r�rrr�<module>r�sp��
��	�%�%�.��g����!��
�
��
�\L�3�;�;�\L�~*#�J�*#�Z�
��B1#�j�1#r

Zerion Mini Shell 1.0