403Webshell
Server IP : 178.105.222.151  /  Your IP : 216.73.216.38
Web Server : nginx/1.28.3
System : Linux MNK 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Wed Apr 22 16:06:43 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.5.4
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/self/root/lib/python3/dist-packages/cloudinit/net/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/lib/python3/dist-packages/cloudinit/net/__pycache__/__init__.cpython-314.pyc
+
��im�����^RIt^RIt^RIt^RIt^RIt^RIt^RIHtHtH	t	H
t
Ht^RIH
t
Ht^RIHt]P"!]4tRtRt.RrOt.RsOt]P0!R43RltR	tRtR
ltRuRltRvRltR
tRtRt Rt!Rt"Rt#Rt$Rt%]PL!RR7RRl4t']PL!RR7RRl4t(RRlt)RvRlt*Rt+Rt,RvRR llt-RvR!lt.RvR"lt/R#t0R$t1R%t2R&t3R't4!R(R)]54t6R*t7R+R,lt8R-R.lt9R/R0lt:R1R2lt;R3R4lt<R5R6lt=R7R8lt>R9R:lt?RvR;R<llt@R=tARwR>ltBRxR?ltCRyR@ltDRAtERBtFRCRDltGRERFltHRGRHltIRIRJltJRKRLltKRMRNltLRzRORPlltMRQRRltNRStORTRUltPRVRWltQRXRYltRRZR[ltSR\R]ltTR^R_ltUR`RaltVRbRcltWRdReltXRfRgltYRhRiltZRjRklt[RlRmlt\RnRolt]!RpRq]^4t_R#){�N)�Callable�Dict�List�Optional�Tuple)�subp�util)�Iproute2z/sys/class/net/�eth0z([0-9]+)c��\P!W4Uu.uF4pVP4'd\V4MVP	4NK6	up#uupi)a0Sorting for Humans: natural sort order. Can be use as the key to sort
functions.
This will sort ['eth0', 'ens3', 'ens10', 'ens12', 'ens8', 'ens0'] as
['ens0', 'ens3', 'ens8', 'ens10', 'ens12', 'eth0'] instead of the simple
python way which will produce ['ens0', 'ens10', 'ens12', 'ens3', 'ens8',
'eth0'].)�re�split�isdigit�int�lower)�s�_nsre�texts&& �8/usr/lib/python3/dist-packages/cloudinit/net/__init__.py�natural_sort_keyr+sK���H�H�U�&��&�D��\�\�^�^��D�	�����5�&����s
�A�Ac��\#)z3Simple function to return the global SYS_CLASS_NET.)�
SYS_CLASS_NET��r�get_sys_class_pathr8s���rc�@�\4V,R,V,#)�/)r��devname�paths&&r�sys_dev_pathr!=s����'�)�C�/�$�6�6rc��\W4p\P!V4pTP4pTfT#Y',# \\3dqp\TRR4p	T	\P\P39dTeT!T4uRp?#T	\P39dTeT!T4uRp?#hRp?ii;i \d/pTeT!T4uRp?#\PRTT4hRp?ii;i)�errnoNz5Found unexpected (not translatable) value '%s' in '%s)r!r	�load_text_file�OSError�IOError�getattrr#�ENOENT�ENOTDIR�EINVAL�strip�KeyError�LOG�debug)
rr �	translate�	on_enoent�on_keyerror�	on_einval�dev_path�contents�e�e_errnos
&&&&&&    r�read_sys_netr7As����G�*�H�
��&�&�x�0���~�~��H�������"�"��
�W����!�W�d�+���u�|�|�U�]�]�3�3��$� ��|�#��u�|�|�o�%��$� ��|�#�
�����	��"��q�>�!��I�I�G���
�

��	�sR�A�C�C�=B>�C�!B>�7C�=B>�>C�C?�C:�C?�"C:�:C?c	�*�Rp\VVVVVVR7#)c��R#�Fr)r5s&r�
on_excp_false�(read_sys_net_safe.<locals>.on_excp_falsegs��r)r1r0r2r/)r7)�iface�fieldr/r;s&&& r�read_sys_net_safer?fs(����
�
�!����
�rc�d�\W4pVRJdR#\V4# \dR#i;i)FN)r?r�
ValueError)r=r>�vals&& r�read_sys_net_intrCts6��
�E�
)�C�
�e�|����3�x�������s�
 �/�/c�.�RRRRRR/p\VRVR7#)�upT�unknown�downF�	operstate)r/�r?)rr/s& r�is_uprJ~s%���t�Y��f�e�<�I��W�k�Y�G�Grc�T�\PP\VR44#)�bridge��osr �existsr!�rs&r�	is_bridgerQ�s��
�7�7�>�>�,�w��9�:�:rc�T�\PP\VR44#)�bondingrMrPs&r�is_bondrT�s��
�7�7�>�>�,�w�	�:�;�;rc�n�\VRR7p\PPV4'dV#R#)z8Return the master path for devname, or None if no master�master�r N)r!rNr rOrs& r�
get_masterrX�s)����h�/�D�	�w�w�~�~�d�����rc�0�\V4pVfR#\PPVR4p\PPVR4p\PP	V4;'g \PP	V4#)z@Return a bool indicating if devname's master is a bridge or bondFrSrL)rXrNr �joinrO)r�master_path�bonding_path�bridge_paths&   r�master_is_bridge_or_bondr^�se���W�%�K�����7�7�<�<��Y�7�L��'�'�,�,�{�H�5�K�
�7�7�>�>�,�'�F�F�2�7�7�>�>�+�+F�Frc�|�\V4pVfR#\VRR7p\PP	V4#)z;Return a bool indicating if devname's master is openvswitchFzupper_ovs-systemrW)rXr!rNr rO)rr[�ovs_paths&  r�master_is_openvswitchra�s5���W�%�K�����G�*<�=�H�
�7�7�>�>�(�#�#rc� �\VR4R8H#)�type�32rIrPs&r�is_ib_interfacere�s���W�f�-��5�5r)�maxsizec�$�V^8�dQhR\/#���return��bool)�formats"r�__annotate__rn�s����$�rc�~�\\P!R44pV'g\P	R4V#)zDReturn a bool indicating if Open vSwitch is installed in the system.�	ovs-vsctlz<ovs-vsctl not in PATH; not detecting Open vSwitch interfaces)rlr�whichr-r.)�rets r�openvswitch_is_installedrs�s0���t�z�z�+�&�
'�C���	�	�J�	
��Jrc�$�V^8�dQhR\/#rh)�list)rms"rrnrn�s�� � �T� rc���\P!\4wrVP4# \Pd4pRTP9d\
P
R4.uRp?#hRp?ii;i)z�Return a list of the names of OVS internal interfaces on the system.

These will all be strings, and are used to exclude OVS-specific interface
from cloud-init's network configuration handling.
zdatabase connection failedzJOpen vSwitch is not yet up; no interfaces will be detected as OVS-internalN)r�!OVS_INTERNAL_INTERFACE_LOOKUP_CMD�
splitlines�ProcessExecutionError�stderrr-�info)�out�_err�excs   r�get_ovs_internal_interfacesr�sf�� ��I�I�?�@�	���~�~�����%�%��'�3�:�:�5��H�H� �
��I�
���s!�.�A6�'A1�*A6�0A1�1A6c�0�V^8�dQhR\R\/#)rirrj��strrl)rms"rrnrn�s����s��t�rc�z�\4'gR#\4pW9d\PRV4R#R#)zxReturns True if this is an OVS internal interface.

If OVS is not installed or not yet running, this will return False.
FzDetected %s as an OVS interfaceT)rsrr-r.)r�ovs_bridgess& r�!is_openvswitch_internal_interfacer��s3��
$�%�%��-�/�K����	�	�3�W�=��rc�l�Vf\V4p\W4'g\W4'dR#R#)z�netfailover driver uses 3 nics, master, primary and standby.
this returns True if the device is either the primary or standby
as these devices are to be ignored.
TF)�
device_driver�is_netfail_primary�is_netfail_standby�r�drivers&&r�is_netfailoverr��s6��
�~��w�'���'�*�*�.@��/�/��rc�H�Rp\VR4pV# \dT#i;i)zDReturns a str from reading /sys/class/net/<devname>/device/features.�zdevice/features)r7�	Exception�r�featuress& r�get_dev_featuresr��s9���H�
���):�;���O���
���O�
�s��!�!c�d�\V4pV'd\V4^@8dR#V^>,R8H#)z�Return True if VIRTIO_NET_F_STANDBY bit (62) is set.

https://github.com/torvalds/linux/blob/         089cf7f6ecb266b6a4164919a2e69bd2f938374a/         include/uapi/linux/virtio_net.h#L60
F�1)r��lenr�s& r�has_netfail_standby_featurer��s.�� ��(�H��s�8�}�r�)���B�<�3��rc�$�V^8�dQhR\/#rhrk)rms"rrnrns����t�rc�z�\V4eR#Vf\V4pVR8wdR#\V4'gR#R#)z�A device is a "netfail master" device if:

- The device does NOT have the 'master' sysfs attribute
- The device driver is 'virtio_net'
- The device has the standby feature bit set

Return True if all of the above is True.
F�
virtio_netT�rXr�r�r�s&&r�is_netfail_masterr�s=���'��&��
�~��w�'��
����&�w�/�/��rc�h�\VRR7p\PPV4'gR#Vf\	V4pVR8XdR#\PP\PP
V44p\	V4pVR8wdR#\V4pV'gR#R#)aA device is a "netfail primary" device if:

- the device has a 'master' sysfs file
- the device driver is not 'virtio_net'
- the 'master' sysfs file points to device with virtio_net driver
- the 'master' device has the 'standby' feature bit set

Return True if all of the above is True.
rVrWFr�T)r!rNr rOr��basename�realpathr�)rr��master_sysfs_path�master_devname�
master_driver�master_has_standbys&&    rr�r�s���%�W�8�<��
�7�7�>�>�+�,�,��
�~��w�'��
�����W�W�%�%�b�g�g�&6�&6�7H�&I�J�N�!�.�1�M���$��4�^�D����rc�z�\V4fR#Vf\V4pVR8wdR#\V4'gR#R#)z�A device is a "netfail standby" device if:

- The device has a 'master' sysfs attribute
- The device driver is 'virtio_net'
- The device has the standby feature bit set

Return True if all of the above is True.
Fr�Tr�r�s&&rr�r�9s=���'��"��
�~��w�'��
����&�w�/�/��rc�@�\VR4pV'd
VR9dR#R#)a�
/* interface name assignment types (sysfs name_assign_type attribute) */
#define NET_NAME_UNKNOWN      0  /* unknown origin (not exposed to user) */
#define NET_NAME_ENUM         1  /* enumerated by kernel */
#define NET_NAME_PREDICTABLE  2  /* predictably named by the kernel */
#define NET_NAME_USER         3  /* provided by user-space */
#define NET_NAME_RENAMED      4  /* renamed by user-space */
�name_assign_typeTF)�3�4rI)rr�s& r�
is_renamedr�Qs#��)��2D�E���,�
�:��rc�R�\\VR44pRVP49#)�ueventzDEVTYPE=vlan)r�r?rx)rr�s& r�is_vlanr�`s(��
�"�7�H�5�
6�F��V�.�.�0�0�0rc���Rp\VR4p\PPV4'd4\PP	\P
!V44pV#)z8Return the device driver for net device named 'devname'.Nz
device/driver)r!rNr �islinkr��readlink)rr��driver_paths&  rr�r�esH��
�F��w��8�K�	�w�w�~�~�k�"�"����!�!�"�+�+�k�":�;���Mrc�.�\VR4pVRJdR#V#)z;Return the device id string for net device named 'devname'.z
device/deviceFNrI)r�dev_ids& r�device_devidr�ps��
�w��
8�F�
�����Mrc�h�\P!4'g\P!4'd"\\	4P44#\P!\44pV# \d.pTP\P8Xd	.pRp?T#hRp?ii;i�N)r	�
is_FreeBSD�is_DragonFlyBSDru�get_interfaces_by_mac�valuesrN�listdirrr%r#r()�devsr5s  r�get_devicelistr�ys��������D�0�0�2�2��)�+�2�2�4�5�5���z�z�,�.�/���K�����7�7�e�l�l�"��D��K�
��	�s�A9�9B1�!B,�+B,�,B1c��]tRtRtRtRtR#)�ParserErrori�z6Raised when a parser has issue parsing a file/content.rN)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__rrrr�r��s��@rr�c�j�V'd\V\4'gR#VPR4R8H#)F�config�disabled)�
isinstance�dict�get)�cfgs&r�is_disabled_cfgr��s(���j��d�+�+���7�7�8��
�*�*rc�:�V^8�dQhR\\,/#rh�rr�)rms"rrnrn�s��
.�
.�T�#�Y�
.rc��\P!4'g\P!4'd\4#\P!4'g\P
!4'd\
4#\4#)ziGet the list of network interfaces viable for networking.

@return List of interfaces, sorted naturally.
)r	r�r��find_candidate_nics_on_freebsd�	is_NetBSD�
is_OpenBSD�(find_candidate_nics_on_netbsd_or_openbsd�find_candidate_nics_on_linuxrrr�find_candidate_nicsr��sS��
�����D�0�0�2�2�-�/�/�	
���	�	�T�_�_�.�.�7�9�9�+�-�-rc�:�V^8�dQhR\\,/#rh�rr�)rms"rrnrn�s��,�,�8�C�=�,rc��\P!4'g\P!4'd\4#\P!4'g\P
!4'd\
4#\4#)z.Get the name of the 'fallback' network device.)r	r�r��find_fallback_nic_on_freebsdr�r��&find_fallback_nic_on_netbsd_or_openbsd�find_fallback_nic_on_linuxrrr�find_fallback_nicr��sQ�������D�0�0�2�2�+�-�-�	
���	�	�T�_�_�.�.�5�7�7�)�+�+rc�:�V^8�dQhR\\,/#rhr�)rms"rrnrn�s��J�J�$�s�)�Jrc�P�\\4P4\R7#)zeGet the names of the candidate network devices on NetBSD/OpenBSD.

@return list of sorted interfaces
��key)�sortedr�r�rrrrr�r��s��
�'�)�0�0�2�8H�I�Irc�:�V^8�dQhR\\,/#rhr�)rms"rrnrn�s��	�	���
�	rc�<�\4pV'd
V^,#R#)z^Get the 'fallback' network device name on NetBSD/OpenBSD.

@return default interface, or None
N)r���namess rr�r��s��

5�6�E���Q�x��rc�:�V^8�dQhR\\,/#rhr�)rms"rrnrn�s��J�J��S�	�Jrc��\P!.RO4wrVP4pV'dV#\\4P	4\
R7#)z_Get the names of the candidate network devices on FreeBSD.

@return List of sorted interfaces.
r�)�ifconfigz-lz-u�ether)rrr�r�r�r)�stdout�_stderrr�s   rr�r��sE��
�i�i� A�B�O�F�
�\�\�^�F�
��
��'�)�0�0�2�8H�I�Irc�:�V^8�dQhR\\,/#rhr�)rms"rrnrn�s��	�	�h�s�m�	rc�<�\4pV'd
V^,#R#)zWGet the 'fallback' network device name on FreeBSD.

@return List of sorted interfaces.
N)r�r�s rr�r��s��

+�,�E���Q�x��rc�:�V^8�dQhR\\,/#rhr�)rms"rrnrn�s��O�O�d�3�i�Orc	���R\P!49d\PR4Mr\	4Uu.uF!pVR8wgK\V4'dKVNK#	pp\
V4'd-\PRV4\P!4.p.p\RRRRRRR	7F�wppVR8XdKVP!R
4'd\PRV4K@\#VR4pV'dVP%V4Kg\PR
V4\#VR4pV'dVP%V4K�\'VR4p	V	R9dVP%V4K�\PRV4K�	.p
W43FRp\)V\*R7p\,V9d,VP/\,4VP1^\,4W�,
p
KT	V
#uupi \PdMp\PRTPTPTPTP4Rp?EL�Rp?ii;i)z]Get the names of the candidate network devices on Linux.

@return List of sorted interfaces.
z
net.ifnames=0z9Stable ifnames disabled by net.ifnames=0 in /proc/cmdline�loz4Found unstable nic names: %s; calling udevadm settlezAudevadm failed to settle: cmd=%r stderr=%r stdout=%r exit_code=%sNFT)�filter_openvswitch_internal�2filter_slave_if_master_not_bridge_bond_openvswitch�filter_vlan�filter_without_own_mac�filter_zero_mac�log_filtered_reasons�vethzIgnoring veth interface: %s�carrierzInterface has no carrier: %s�dormantrHzInterface ignored: %sr�)r�rG�lowerlayerdownrF)r	�get_cmdliner-r.r�r�r��udevadm_settlerry�warning�cmdrzr��	exit_code�get_interfaces�
startswithrC�appendr?r�r�DEFAULT_PRIMARY_INTERFACE�remove�insert)�device�unstable�error�	connected�possibly_connected�	interface�_r�r�rH�sorted_interfaces�
interfacess            rr�r��s$��
�$�*�*�,�,��	�	�M�N�)�*�
�*����~�
�&0��&8�
�F�*�	�
�
�x�=�=��I�I�F��
�

��#�#�%��I���,�$)�;@��$��!�
��	�1�a����������'�'��I�I�3�Y�?��"�9�i�8������Y�'���	�	�0�)�<�#�9�i�8����%�%�i�0��%�i��=�	��H�H��%�%�i�0���	�	�)�9�5�=�J�� �5�
��J�,<�=�
�$�
�2����7�8����a�!:�;��'��6����O
���-�-�
����>��I�I��L�L��L�L��O�O�
���
�s*�	G9�G9�G9�G>�>I�AI�Ic�:�V^8�dQhR\\,/#rhr�)rms"rrnrn)s��	�	�H�S�M�	rc�<�\4pV'd
V^,#R#)zUGet the 'fallback' network device name on Linux.

@return List of sorted interfaces.
N)r�r�s rr�r�)s��

)�*�E���Q�x��rc�:�V^8�dQhR\\,/#rh)rr�)rms"rrnrn5s����H�T�N�rc���\4pV'gR#\V4'dRV/pMR\VR4P4/pV'd\	V4pV'dW2R&RRRRR	VR
V/pRW/R^/pV#)
zBGenerate network cfg v2 for dhcp on the NIC most likely connected.N�name�
macaddress�addressr��dhcp4T�dhcp6�set-name�match�	ethernets�version)r�r�r?rr�)�
config_driver�target_namerr�r��nconfs&     r�generate_fallback_configr5s���$�%�K�����%�%���%��
�+�K��C�I�I�K�
����{�+���$�(�O������K���	�C��;�,�i��;�E��Lrc��RpRpVPR4pV^8Xd	V!V4#V^8Xd	V!V4#\RV,4h)c��.pVPR/4F�pVPR4R8wdKVPR4pV'gK6VPR4pVPR/4PR4pVPR/4PR4pV'g\V4pV'g\V4pVPW4WV.4K�	V#)r�rc�physical�mac_addressr�paramsr��	device_id)r�r�r�r)�netcfg�physdevs�ent�macrr�r$s&      r�
_version_1�$extract_physdevs.<locals>._version_1Ss������:�:�h��+�C��w�w�v��*�,���'�'�-�(�C����7�7�6�?�D��W�W�X�r�*�.�.�x�8�F�����"�-�1�1�+�>�I��&�t�,���(��.�	��O�O�S��:�;�,��rc���.pVPR/4P4F�pVPR4pV'gKVPR/4PR4pV'gKIVPR/4PR4pVPR/4PR4pV'g\V4pV'g\V4pVP	WCWV.4K�	V#)rrrrr�r$)r�r�r�r�r)r%r&r'rr(r�r$s&      r�
_version_2�$extract_physdevs.<locals>._version_2es������:�:�k�2�.�5�5�7�C��7�7�:�&�D����'�'�'�2�&�*�*�<�8�C����W�W�W�b�)�-�-�h�7�F������,�0�0��=�I��&�t�,���(��.�	��O�O�S��:�;�8� �rrz"Unknown network config version: %s)r��RuntimeError)r%r)r,rs&   r�extract_physdevsr/RsQ���$�(�j�j��#�G��!�|��&�!�!�	�A���&�!�!�
�;�g�E�
F�Frc�V�\VR4pVfV'd\R4hR#VR9#)a�return True if the provided interface has its own address.

Based on addr_assign_type in /sys.  Return true for any interface
that does not have a 'stolen' address. Examples of such devices
are bonds or vlans that inherit their mac from another device.
Possible values are:
  0: permanent address    2: stolen from another device
1: randomly generated   3: set using dev_set_mac_address�addr_assign_typez%s had no addr_assign_type.T)r��)rCrA)�ifname�strict�assign_types&& r�interface_has_own_macr7�s6��#�6�+=�>�K�����:�;�;���)�#�#rc��/p\4F-wr#rERRRVRVRVP4RVR\V4/W&K/	V'd�\P!R4p\
P
!.ROR	R
7wrx\
P
!.R
OR	R
7wr�\
4p
Wy3F#pV
PVPV44K%	VP4F%pVR,RJ;'g
VR,V
9VR&K'	V#)a�Collect information necessary for rename_interfaces.

returns a dictionary by mac address like:
   {name:
     {
      'downable': None or boolean indicating that the
                  device has only automatically assigned ip addrs.
      'device_id': Device id value (if it has one)
      'driver': Device driver (if it has one)
      'mac': mac address (in lower case)
      'name': name
      'up': boolean: is_up(name)
     }}
�downableNr$r�r(rrEz[0-9]+:\s+(\w+)[@:]T)�captureF)�ipz-6�addr�show�	permanent�scope�global)r;z-4r<r=)
r�rrJr
�compiler�set�update�findallr�)
�check_downable�cur_inforr(r�r$�nmatch�ipv6r}�ipv4�nics_with_addresses�	bytes_out�ds
&            r�_get_current_rename_inforM�s����H�(6�(8�$��6������f��3�9�9�;��D��%��+�

���)9�����2�3���Y�Y�H��
�
���Y�Y�;�T�J�
��!�e����I��&�&�v�~�~�i�'@�A�&����"�A��$��5� �H�H�A�f�I�5H�$H�
�j�M�#�
�Orc
�Faa�\V4'g\PR4R#Vf\4p/oVP	4FOwrEVP4pVP
R4'dVR,P4VR&WFR&VSV&KQ	\PRS4Rp.p.p	.p
V!S4pRpRp
RoVV3RlpVEFwppppV'dVP4p.pV!VVV4pV'g%V'dV	PR	V:R
V:R24KYVP
R4pVV8XdKsV'g%V'dV	PR	V:R
V:R24K�VR,'dhR
pVR,'g&V'dV	PVVVV3,4K�RVR&VPRVVV334V
PRVVV334VV9d�VV,pVR,'dNRpVR,'g'V'dV	PVVVV3,4EKkVPRVVV334RpVeVV9dV
^,
p
W�,pKVPRVVVV334VVR&V!S4pVR,'dV
PRVVV334VPRVVVR,V334VVR&V!S4pVV,
pEK!	R\PR\PR\P/pV'gIV
'gA\V	4'd\PRVV	4MV\PRV4M?\PRWV
,4W�,FwppppVV,!V!K	\V	4'd\RP!V	44hR# \d0pT	PRT:T:RT:RT:RT:2	4Rp?K|Rp?ii;i)zno interfaces to renameNr(rzDetected interfaces %sc�B�\RVP444#)c3�6"�TFqR,V3x�K	R#5i)rNr)�.0�datas& r�	<genexpr>�<_rename_interfaces.<locals>.update_byname.<locals>.<genexpr>�s���D�^�T�&�\�4�(�^�s�)r�r�)�bymacs&r�
update_byname�)_rename_interfaces.<locals>.update_byname�s���D�U�\�\�^�D�D�Drz
cirename%dc�&�V'dEV'd=V'd5VR,V8H;'d!VR,V8H;'d
VR,V8H#V'd)V'd!VR,V8H;'d
VR,V8H#V'd
VR,V8H#R#)zmatch if set and in datar(r�r$Fr)rRr(r�r$s&&&&r�entry_match�'_rename_interfaces.<locals>.entry_match�s����6�i��U��s�"�3�3���N�f�,�3�3���%��2�
�
�V���;�#�%�B�B�$�x�.�F�*B�B�
���;�#�%�%�rc	�<�SP4Uu.uFpS!W0W4'gKVNK	pp\V4'd8\V4^8�dRV:RV:RV:RV:R2	p\V4hV^,#R#uupi)r2z2Failed to match a single device. Matched devices "z" with search values "(mac:z driver:z device_id:z)"N)r�r�rA)r(r�r$rRr�msgrFrYs&&&   ��r�
find_entry�&_rename_interfaces.<locals>.find_entry�s����!���)�
�)���4�f�8�
�D�)�	�
�
�u�:�:��5�z�A�~��c�6�9�6��
!��o�%���8�O���
s
�A<�A<z$[nic not present] Cannot rename mac=z to z, not available.rEz*[busy] Error renaming mac=%s from %s to %sr9FrGz2[busy-target] Error renaming mac=%s from %s to %s.�renamez1Unable to rename interfaces: %s due to errors: %sz$no work necessary for renaming of %szRenamed %s with ops %sznknown] Error performing z for z, z: �
���)r�r-r.rM�items�copyr�rrr
�link_rename�	link_down�link_upr�r�r.rZ)�renames�strict_present�strict_busy�current_inforrR�currV�ops�errors�ups�
cur_byname�tmpname_fmt�tmpir]r(�new_namer�r$�cur_ops�cur_namer\�target�tmp_name�opmap�opr#r5rFrYs&&&&                        @@r�_rename_interfacesry�s�����w�<�<��	�	�+�,����/�1���H�"�(�(�*�
���i�i�k���7�7�5�>�>��U��)�)�+�C��J��F������+��I�I�&��1�E�
�C�
�F�
�C��x�(�J��K�
�D�
��$-4�(��X�v�y���)�)�+�C�����f�i�0�����
�
�*-�x�9��
��7�7�6�?���x������
�
�*-�x�9��
��t�9�9�>�C��z�?�?���M�M�#��h��(A�"A�B���C��I��N�N�F�C��H�;�?�@��J�J��c�8�h�[�9�:��z�!���)�F��d�|�|�J���j�)�)�"��
�
�c�S�(�H�,E�&E�F���N�N�F�C��H�;�#G�H�&*�H��"�h�*�&<���	��&�-���N�N�H�c�8�h��5I�J�K�%�F�6�N�&�x�0�J��d�|�|��
�
�D�#�x�(��=�>�����#�x�#�f�+�x�1H�I�J���F��"�8�,�
��w���{-4�@	�(�&�&���"�"��h���"�E�
�#��v�;�;��K�K�C���
�
�I�I�<�g�F��	�	�*�G�3�Y�?�),���%�B��X�v�
��b�	�6�"�*3��6�{�{��4�9�9�V�,�-�-���
�
��
�
��6�3��!�5����
�s�(
O&�&P �1$P�P c�~�Rp\PP\VR44'dRp\	W4#)z6Returns the string value of an interface's MAC Addressr�
bonding_slavezbonding_slave/perm_hwaddr)rNr �isdirr!r?)r4r s& r�get_interface_macr}bs3���D�	�w�w�}�}�\�&�/�:�;�;�+���V�*�*rc��\VR4R8Xd1\V4pV'dV'dV^$RVR,,pV#R#)z�Returns the string value of an Infiniband interface's hardware
address. If ethernet_format is True, an Ethernet MAC-style 6 byte
representation of the address will be returned.
rcrd:�3NNNi�)r?r})r4�ethernet_formatr(s&& r�get_ib_interface_hwaddrr�ls@�����(�D�0���'���?��b��+��C��(�C��
�1rc�$�V^8�dQhR\/#rh�r�)rms"rrnrnzs��0�0�t�0rc�*�\P!4'g\P!4'd\4#\P!4'd\4#\P!4'd\4#\4#r�)	r	r�r�� get_interfaces_by_mac_on_freebsdr��get_interfaces_by_mac_on_netbsdr�� get_interfaces_by_mac_on_openbsd�get_interfaces_by_mac_on_linuxrrrr�r�zs[�������D�0�0�2�2�/�1�1�	
���	�	�.�0�0�	
���	�	�/�1�1�-�/�/rc�F�V^8�dQhR\R\\,/#)rir(rj)r�r)rms"rrnrn�s����c��h�s�m�rc��\4P4F,wrVP4VP48XgK*Vu#	R#r�)r�rbr)r(�
interface_mac�interface_names&  r�find_interface_name_from_macr��s>��)>�)@�)F�)F�)H�%�
��9�9�;�-�-�-�/�/�!�!�*I�rc�$�V^8�dQhR\/#rhr�)rms"rrnrn�s����$�rc��\P!.RO4wrRpRpV!V!V44UUu/uFwrEWEbK		pppV#uuppi)r�c3�"�RpVPR4F2pVPR4'dW,
pK$V'dVx�TpK4	Vx�R#5i)r�r`�	N)rr)r|�
curr_block�lines&  r�flatten�1get_interfaces_by_mac_on_freebsd.<locals>.flatten�sI����
��I�I�d�O�D����t�$�$��"�
��$�$�!�
�
$���s�?A�Ac3�"�VFHp\P!RV4pV'gK$VPR4VPR43x�KJ	R#5i)z2^(?P<ifname>\S*): .*ether\s(?P<mac>[\da-f:]{17}).*r(r4N)r
�search�group)�	flat_list�block�ms&  r�find_mac�2get_interfaces_by_mac_on_freebsd.<locals>.find_mac�sE����E��	�	�E�u��A��q��w�w�u�~�q�w�w�x�'8�9�9��s
�"A�*A)r��-ar�)r)r|rr�r�r(r4�resultss       rr�r��sM���y�y�4�5�H�S�	�:�/7�w�s�|�.D�E�.D�{�s�s�{�.D�G�E��N��Fs�
Ac�$�V^8�dQhR\/#rhr�)rms"rrnrn�s��
�
��
rc�$�/pRp\P!RR.4wr#\P!RRV4P4pVFEp\P!W4pV'gK#VP4pVR,WR,&KG	V#)zE(?P<ifname>\w+).*address:\s(?P<mac>([\da-f]{2}[:-]){5}([\da-f]{2})).*r�r��\n\s+� r4r(�rr
�subrxr�	groupdict�rr�re_field_matchr|r�if_linesr�r��fieldss        rr�r�����
�C�	6���y�y�*�d�+�,�H�S��v�v�h��S�)�4�4�6�H����H�H�^�*���1��[�[�]�F�!'��!1�C�u�
��	�
�Jrc�$�V^8�dQhR\/#rhr�)rms"rrnrn�s��
�
�$�
rc�$�/pRp\P!RR.4wr#\P!RRV4P4pVFEp\P!W4pV'gK#VP4pVR,WR,&KG	V#)zC(?P<ifname>\w+).*lladdr\s(?P<mac>([\da-f]{2}[:-]){5}([\da-f]{2})).*r�r�r�r�r4r(r�r�s        rr�r��r�rc�$�V^8�dQhR\/#rhr�)rms"rrnrn�s��D�D��Drc�T�/p\4F�wrr4W 9dHVR9d!\PRVW,V4K3RV:RW,:RV:R2p\V4hWV&\	VR4pV'gKmW`9dWV&Ky\PRVW,V4K�	V#)	ziBuild a dictionary of tuples {mac: name}.

Bridges and any devices that have a 'stolen' mac are excluded.z>Ignoring duplicate macs from '%s' and '%s' due to driver '%s'.�duplicate mac found! both '�' and '�' have mac 'z'.Tz^Ethernet and InfiniBand interfaces have the same address both '%s' and '%s' have address '%s'.)�	fsl_enetc�
mscc_felix�qmi_wwan)r�r-r.r.r�r�)rrrr(r��_devidr\�ib_macs       rr�r��s����C�%3�%5�!��6��:��@�@��	�	�#���H����A�������C�
�s�#�#��C��
)��t�4���6�*� �"�F�����=���K���o&6�|�Jrc�x�V^8�dQhR\R\R\R\R\R\R\R\/#)	ri�filter_hyperv_vf_with_syntheticr�r�r�r�r�r�rj)rlru)rms"rrnrnsX��:�:�%)�:�!%�:�9=�:��	:�
!�:��
:��:�
�:rc	�V�V'd\PMRp.p\4p	RPR
4p
V	EFVp\	V4'dV!RV4K V'd\V4'dK;\
V4'dV!RV4KWV'd\V4'gV!RV4K{V'd2\V4e%\V4'g\V4'gK�\V4'dV!RV4K�\V4pV'gV!RV4K�V'dVR	8wdW�R\V48XdEKV'd\V4'dEK.\V4p
VP!W�V
\#V434EKY	V'd\%Wx4V#)z~Return list of interface tuples (name, mac, driver, device_id)

Bridges and any devices that have a 'stolen' mac are excluded.c��R#r�r)�argss*r�<lambda>� get_interfaces.<locals>.<lambda>s��4r�:zIgnoring bridge interface: %szIgnoring bond interface: %sz)Ignoring interface with inherited MAC: %sNzIgnoring failover interface: %sz"Ignoring interface without mac: %sr�)�00r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)r-r.r�rZrQr�rTr7rXr^rar�r}r�r�r�rr��)filter_hyperv_vf_with_synthetic_interface)r�r�r�r�r�r�r��filtered_loggerrrr��zero_macrr(r�s&&&&&&&       rr�r�sT��$8�c�i�i�=O�O�
�C���D��x�x��%�H����T�?�?��;�T�B���7�4�=�=���4�=�=��9�4�@��!�*?��*E�*E��G��N��>��4� �,�,�T�2�2�)�$�/�/���$����=�t�D����%����@�$�G���t�t�|��
�#�c�(�7K�0K��&�+L��,
�,
�
��t�$���
�
�D�v�|�D�'9�:�;�G�L'�1�/�G��Jrc	��V^8�dQhR\R,R\\\\\\3,,RR/#)rir�Nr
rj).N)rrrr�)rms"rrnrnLs>��'%�'%��i�(�'%��U�3��S�#�-�.�/�'%�
�'%rc�<�VUu/uF#q"^,R8XgKV^,V^,bK%	ppVUu.uF%pV^,V9gKV^,R8wgK#VNK'	ppVF+pVwrgr�V!RVVW7,V4VPV4K-	R#uupiuupi)aiFilter Hyper-V SR-IOV/VFs when used with synthetic hv_netvsc.

Hyper-V's netvsc driver may register an SR-IOV/VF interface with a mac
that matches the synthetic (hv_netvsc) interface.  This VF will be
enslaved to the synthetic interface, but cloud-init may be racing this
process.  The [perhaps-yet-to-be-enslaved] VF should never be directly
configured, so we filter interfaces that duplicate any hv_netvsc mac
address, as this the most reliable indicator that it is meant to be
subordinate to the synthetic interface.

VF drivers will be mlx4_core, mlx5_core, or mana.  However, given that
this list of drivers has changed over time and mana's dependency on
hv_netvsc is expected to be removed in the future, we no longer rely
on these names. Note that this will not affect mlx4/5 instances outside
of Hyper-V, as it only affects environments where hv_netvsc is present.
�	hv_netvsczdIgnoring %r VF interface with driver %r due to synthetic hv_netvsc interface %r with mac address %r.N)r)
r�r
�i�hv_netvsc_mac_to_name�interfaces_to_remover
rr(r�rs
&&        rr�r�Ls���*'��&�q�A�$�+�*=�
��!��a��d�
�J���
���A��Q�4�(�(�	
�-.�q�T�[�-@�	
�����*�	�(���6��
D���!�&��
	
�	���)�$�*����s�B�B�B�	B�Bc
��/p\4FFwpp\VR4pV'gKW09d\RV:RW,:RV:R24hW0V&KH	V#)zPBuild a dictionary mapping Infiniband interface names to their hardware
address.Fr�r�r��')r�r�r.)rrrrr�s    r�get_ib_hwaddrs_by_interfacer�vsa���C�'�)�
��a��A�(��u�5���6��}�"��S�[�[�&�2�����I�*��Jrc�0�V^8�dQhR\R\/#)ri�convert_to_addressr)rr�)rms"rrnrn�s����(��S�rc�:�V!V3/VB# \dR#i;i)z�Use a function to return an address. If conversion throws a ValueError
exception return False.

:param check_cb:
    Test function, must return a truthy value
:param address:
    The string to test.

:return:
    Address or False

F)rA)r�r�kwargss&&,r�maybe_get_addressr��s)���!�'�4�V�4�4������s���c�0�V^8�dQhR\R\/#�rirrjr�)rms"rrnrn�s��	B�	B�3�	B�4�	Brc�H�\\\PV44#)z�Returns a bool indicating if ``s`` is an IP address.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IP address or not.
)rlr��	ipaddress�
ip_address�rs&r�
is_ip_addressr��s���!�)�"6�"6��@�A�Arc�0�V^8�dQhR\R\/#r�r�)rms"rrnrn����	C�	C�S�	C�T�	Crc�H�\\\PV44#)z�Returns a bool indicating if ``s`` is an IPv4 address.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IPv4 address or not.
)rlr�r��IPv4Addressr�s&r�is_ipv4_addressr������!�)�"7�"7��A�B�Brc�0�V^8�dQhR\R\/#r�r�)rms"rrnrn�r�rc�H�\\\PV44#)z�Returns a bool indicating if ``s`` is an IPv6 address.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IPv4 address or not.
)rlr�r��IPv6Addressr�s&r�is_ipv6_addressr��r�rc�0�V^8�dQhR\R\/#r�r�)rms"rrnrn�s��	P�	P�3�	P�4�	Prc�L�\\\PVRR74#)z�Returns a bool indicating if ``s`` is an IPv4 or IPv6 network.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IPv4 address or not.
F�r5)rlr�r��
ip_networkr�s&r�
is_ip_networkr��s���!�)�"6�"6���N�O�Orc�0�V^8�dQhR\R\/#r�r�)rms"rrnrn������S��T�rc�L�\\\PVRR74#)z�Returns a bool indicating if ``s`` is an IPv4 network.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IPv4 address or not.
Fr�)rlr�r��IPv4Networkr�s&r�is_ipv4_networkr���#����)�/�/���G��rc�0�V^8�dQhR\R\/#r�r�)rms"rrnrn�r�rc�L�\\\PVRR74#)z�Returns a bool indicating if ``s`` is an IPv6 network.

:param address:
    The string to test.

:return:
    A bool indicating if the string is an IPv4 address or not.
Fr�)rlr�r��IPv6Networkr�s&r�is_ipv6_networkr��r�rc�<�V^8�dQhR\R\R\/#)rir�subnetrjr�)rms"rrnrn�s!��(�(�S�(�#�(�$�(rc�f�\P!V4p\P!VRR7pW#9#)z�Returns a bool indicating if ``s`` is in subnet.

:param address:
    The string of IP address.

:param subnet:
    The string of subnet.

:return:
    A bool indicating if the string is in subnet.
Fr�)r�r�r�)rr�r��subnet_networks&&  r�is_ip_in_subnetr��s/���%�%�g�.�J��)�)�&��?�N��'�'rc�<�V^8�dQhR\R\R\/#)ri�gatewayr�rjr�)rms"rrnrn�s!����C�����rc��\W4'*# \d$p\PRTTT4Rp?R#Rp?ii;i)z�Returns a bool indicating if should add gateway onlink flag.

:param gateway:
    The string of gateway address.

:param subnet:
    The string of subnet.

:return:
    A bool indicating if the string is in subnet.
zDFailed to check whether gateway %s is contained within subnet %s: %sNF)r�rAr-r�)r�r�r5s&& r�should_add_gateway_onlink_flagr��sD��
�"�7�3�3�3�������
1���
�	
����s��A�;�Ac�$�V^8�dQhR\/#rhrk)rms"rrnrns����d�rc���VR,PR4'gVR,\9dR#VR,R8Xd#\VPR44'dR#R#)z:Common helper for checking network_state subnets for ipv6.rc�6T�staticrF)�endswith�IPV6_DYNAMIC_TYPESr�r�)r�s&r�subnet_is_ipv6rsM���f�~���s�#�#�v�f�~�9K�'K��	���8�	#���
�
�9�8M�(N�(N��rc�$�V^8�dQhR\/#rh�r�)rms"rrnrns��C�C�s�Crc�Z�\\P!RV24P4#)z�Convert a network prefix to an ipv4 netmask.

This is the inverse of ipv4_mask_to_net_prefix.
    24 -> "255.255.255.0"
Also supports input as a string.�0.0.0.0/)r�r�r��netmask)�prefixs&r�net_prefix_to_ipv4_maskrs'���y�$�$�x��x�%8�9�A�A�B�Brc�$�V^8�dQhR\/#rh�r)rms"rrnrn&s��	=�	=�S�	=rc�H�\P!RV24P#)z�Convert an ipv4 netmask into a network prefix length.

If the input is already an integer or a string representation of
an integer, then int(mask) will be returned.
   "255.255.255.0" => 24
   str(24)         => 24
   "24"            => 24
r)r�r��	prefixlen)�masks&r�ipv4_mask_to_net_prefixr&s"�����(�4�&� 1�2�<�<�<rc�$�V^8�dQhR\/#rhr
)rms"rrnrn2s�� � �S� rc���\P!RV24PpV# \dMi;i\P!T4p\T4pT^8XdT#\
\PT(T^,
,P44pY4,	p\PT,
p^T,^,
pYV8wd\RT,4hT#)z�Convert an ipv6 netmask (very uncommon) or prefix (64) to prefix.

If the input is already an integer or a string representation of
an integer, then int(mask) will be returned.
   "ffff:ffff:ffff::"  => 48
   "48"                => 48
z::/zInvalid network mask '%s')	r�r�rrAr�r�min�
IPV6LENGTH�
bit_length)r
rr�mask_int�trailing_zeroes�leading_ones�all_oness&      r�ipv6_mask_to_net_prefixr2s���
��(�(�3�t�f��6�@�@�	�����
�	
�
��
�"�"�4�(�G��7�|�H��1�}��������y�H�q�L�9�E�E�G��O��.�L��$�$��6�I��Y��!�#�H����4�t�;�<�<��s�$'�5�5c�<�V^8�dQhR\R\R\/#)rir
r;rjr)rms"rrnrnUs!����c��s��s�rc�b�\\P!VRV2RR7P4#)zCGet string representation of broadcast address from an ip/mask pairrFr�)r�r�r��broadcast_address)r
r;s&&r�mask_and_ipv4_to_bcast_addrrUs/��������A�d�V�n�U�;�M�M��rc��]tRtRtRtR#)�RendererNotFoundErrori\rN)r�r�r�r�r�rrrrr\s��rr)r�
ipv6_slaaczipv6_dhcpv6-statelesszipv6_dhcpv6-stateful)rpz--format�csvz
--no-headingsz	--timeout�10z	--columnsr�findr
z
type=internal)r�)NNNNr�r:)T)TTN)TTTTTTF)`r#�	functoolsr��loggingrNr
�typingrrrrr�	cloudinitrr	�cloudinit.net.netops.iproute2r
�	getLoggerr�r-rrrrwrArrr!r7r?rCrJrQrTrXr^rare�	lru_cachersrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr/r7rMryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr.rrrr�<module>r*s
��
����	�	�8�8� �2�
����!��!�
�"����%�!�!�j�j��4�
��
7�"�J��H�;�<��G�$�6����T�"��#�����T�"� �#� �(���
��0�B�0�1�
���A�)�A�+�
.�,�J�	�J�	�O�d	��:-G�`$�(+�\[.�|+��0���8
� 
� D�N:�z'%�T
� �&	B�	C�	C�	P���(�"�2�C�	=� �F�	�L�	r

Youez - 2016 - github.com/yon3zu
LinuXploit