%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�fJ$���ddlZddlZddlZddlmZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZej"e�ZdZGd�d�ZGd	�d
�Zy)�N)�defaultdict)�	lru_cache)�IPv4Address�
IPv4Interface�
IPv6Interface)�Dict�List�Optional�Tuple�Unionz"([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}c��eZdZdZd�Zedefd��Zedefd��Zedefd��Z	edefd��Z
edefd��Zy	)
�Ifstatez�
    This class holds the parsed state of a BSD network interface.
    It is itself side-effect free.
    All methods with side-effects should be implemented on one of the
    ``BSDNetworking`` classes.
    c��||_d|_i|_i|_d|_g|_g|_g|_d|_d|_	g|_
d|_d|_d|_
d|_g|_i|_g|_y)NrF)�name�index�inet�inet6�up�options�nd6�flags�mtu�metric�groups�description�media�status�mac�macs�vlan�members)�selfrs  �D/usr/lib/python3/dist-packages/cloudinit/distros/parsers/ifconfig.py�__init__zIfstate.__init__s�����	���
���	���
������������
����������*.���$(��
�%)���"&�����	���	�����returnc�>�d|jvxsd|jvS)N�loopback�lo)rr�r"s r#�is_loopbackzIfstate.is_loopback0s���T�Z�Z�'�>�4�4�;�;�+>�>r%c�v�d|jvry|jgk(r|jrd|jvryy)N�egressT�EthernetF)rrr*s r#�is_physicalzIfstate.is_physical4s6���t�{�{�"���;�;�"�����
�d�j�j�0H��r%c��d|jvS)N�bridge�rr*s r#�	is_bridgezIfstate.is_bridge=s���4�;�;�&�&r%c��d|jvS)N�laggr2r*s r#�is_bondzIfstate.is_bondAs������$�$r%c�@�d|jvxs|jik7S)Nr )rr r*s r#�is_vlanzIfstate.is_vlanEs���$�+�+�%�;�4�9�9��?�;r%N)�__name__�
__module__�__qualname__�__doc__r$�property�boolr+r/r3r6r8�r%r#rrs�����(�?�T�?��?���T�����'�4�'��'��%��%��%��<��<��<r%rc
��eZdZdZd�Ze�dedeeee	e
e	fffd��Zd�Zde
deeeffd�Zd	�Zde
deeeffd
�Zde
defd�Zy)
�Ifconfiga8
    A parser for BSD style ``ifconfig(8)`` output.
    For documentation here:
    - https://man.freebsd.org/ifconfig(8)
    - https://man.netbsd.org/ifconfig.8
    - https://man.openbsd.org/ifconfig.8
    All output is considered equally, and then massaged into a singular form:
    an ``Ifstate`` object.
    c� �i|_i|_y�N)�_ifs_by_name�_ifs_by_macr*s r#r$zIfconfig.__init__Us�������r%�textr&c�8	�d}tt�}d}|j�D�]J}t|�dk(r�|ddvrO|dz
}|j	�d}|jd�r|dd}t
|�}||_||j|<|s�l|j�j�j	�}t|�dkDrm|djd�rY|j|�}|ik7rCtj|d�|_|d	|_d
|vr
|d
|_d|vr
|d|_|djd�r4t'jd
|d�}	|jj)|	�|ddk(rt+|d�|_|ddk(r||jd�dzd|_|djd�s(|djd�s|djd�rNt'jd
|d�}
t|
�dkDr'|xj.|
dj	d�z
c_|ddk(r?|d|_|j2j)|d�||dj)|�|ddk(r5|j2j)|d�||dj)|�|ddk(r|xj4|ddz
c_|ddk(r||jd�dzd|_|ddk(r@t'jd
|d�}t|�dkDr|dj	d�|_|ddk(r
|d|_|ddk(r9|j=|�}tj|d�|j>|d<|ddk(r9|jA|�}tj|d�|jB|d<|ddk(s|ddk(r|xjD|dz
c_"|dd k(s���i|_#|d|jFd!<tIdt|��D] }
||
d"k(s�||
dz|jFd#<�"��MtK|�|_&i|j�|jL�S)$a
        Parse the ``ifconfig -a`` output ``text``, into a dict of ``Ifstate``
        objects, referenced by ``name`` *and* by ``mac`` address.

        This dict will always be the same, given the same input, so we can
        ``@lru_cache()`` it. n.b.: ``@lru_cache()`` takes only the
        ``__hash__()`` of the input (``text``), so it should be fairly quick,
        despite our giant inputs.

        @param text: The output of ``ifconfig -a``
        @returns: A dict of ``Ifstate``s, referenced by ``name`` and ``mac``
        rN)�	� ��:���zflags=rrrrz
capabilities=�<|>rzdescription:�zoptions=�ec_capabilities�
ec_enabled�,�ether�hwaddrzgroups:zmedia:z: rrrrzmember:z	laggport:zvlan:�idz
interface:�link)'r�list�
splitlines�len�split�endswithrrrD�lower�strip�
startswith�_parse_flags�copy�deepcopyrrrr�re�append�intrrrrrrrr�_parse_inetr�_parse_inet6rr!r �range�dictrE)r"rF�ifindex�
ifs_by_mac�dev�line�curif�toksr�capsr�nd6_opts�ip�is              r#�parsezIfconfig.parseYsr���� ��&�
����O�O�%�^	7�D��4�y�A�~���A�w�k�)�
�1����
�
��Q����>�>�#�&�!�#�2�J�E��e�n��#��	�+.��!�!�%�(����:�:�<�%�%�'�-�-�/�D��4�y�1�}��a��!3�!3�H�!=��)�)�$�/���B�;� $�
�
�e�G�n� =�C�I�"�4�[�C�F���~�"'��,����5�(�%*�8�_��
��A�w�!�!�/�2��x�x���Q��0���	�	� � ��&��A�w�'�!���Q��L��	��A�w�.�(�"&�t�z�z�#���':�'<�"=����Q��"�"�:�.���7�%�%�&7�8���7�%�%�l�3��(�(�6�4��7�3���w�<�!�#��K�K�7�1�:�#3�#3�C�#8�8�K��A�w�'�!��q�'���������Q��(��4��7�#�*�*�3�/��A�w�(�"�������Q��(��4��7�#�*�*�3�/��A�w�)�#��
�
�d�1�2�h�&�
��A�w�(�"� ����D�!1�A�!5�!7�8��	��A�w�%���8�8�F�D��G�4���x�=�1�$�&�q�k�/�/��4�C�G��A�w�(�"�!�!�W��
��A�w�&� ��%�%�d�+��"&�-�-��1��"6�����A����A�w�'�!��&�&�t�,��#'�=�=��A��#7��	�	�"�Q�%� ��A�w�)�#�t�A�w�+�'=����t�A�w�&���A�w�'�!����!%�a��������q�#�d�)�,�7�A��A�w�,�.�+/��A��;�����(�7�y^	7�@ �
�+���8�$�#�#�8�t�'7�'7�8�8r%c��|jSrC)rEr*s r#rizIfconfig.ifs_by_mac�s�����r%rmc��d}d|dvr?t|d�}t|j�}d|vrg||jd�dz}nOtt	t|dd���}d|vr||jd�dz}t|d�d|���}|jjd�d}t|j�|||d�fS)N�/rJ�	broadcast�r)�netmaskrv�	prefixlen)	r�strrxrrrc�with_prefixlenrYrp)r"rmrvrprxrys      r#rdzIfconfig._parse_inet�s����	��$�q�'�>��t�A�w�'�B��"�*�*�o�G��d�"� ����K�!8�1�!<�=�	��+�c�$�q�'�1�o�6�7�G��d�"� ����K�!8�1�!<�=�	��$�q�'�7�;�<�B��%�%�+�+�C�0��3�	�����J�"�&�&�
�
�	
r%c�\�tdt|��D]}||dk(s�||dzcSy)NrNryrJ)rfrX)r"rmrqs   r#�_get_prefixlenzIfconfig._get_prefixlen�s6���q�#�d�)�$�	#�A��A�w�+�%��A��E�{�"�	#r%c���d}d|dvrTd}|djd�\}}d|vr|jd�d}n|j|�}t|�d|���}nQd|dvr&t|d�}|djd�d}n$|j|�}t|d�d|���}|s|jrd}n|s|jrd}t|j�||d�fS)N�%rJz
link-localruz
site-local)ry�scope)rYr}r�
is_link_local�
is_site_localrzrp)r"rmr��ip6�restryrps       r#rezIfconfig._parse_inet6�s������$�q�'�>� �E��Q��
�
�c�*�I�C���d�{� �J�J�s�O�A�.�	� �/�/��5�	��#�y�9�:�B�
�D��G�^��t�A�w�'�B��Q��
�
�c�*�1�-�I��+�+�D�1�I��$�q�'�9�=�>�B���)�)� �E��2�+�+� �E��B�E�E�
�)�e�D�E�Er%c�R�tjd|d�}i}t|�dkDr}|djd�|d<d|dvrd|d<nd|d<tdt|��D]<}||d	k(rt	||dz�|d	<� ||d
k(s�)t	||dz�|d
<�>|S)NrMrJrQrrTFrNrr)rarYrXrfrc)r"rmr�ret�ts     r#r^zIfconfig._parse_flagss��������a��)�����u�:��>� ��8�>�>�#�.�C��L��s�7�|�#� ��D�	�!��D�	��1�c�$�i�(�
2����7�h�&�$'��Q��U��$4�C��M��!�W��%�!$�T�!�a�%�[�!1�C��J�	
2�
�
r%N)r9r:r;r<r$rrzrrrr	rrrirVrrgrdr}rer^r?r%r#rArAJs������[�q9�#�q9�$�s�E�'�4��=�2H�,I�'I�"J�q9��q9�f �
��
��s�D�y�)9�
�.#�
F��F�%��T�	�*:�F�2���$�r%rA)r_�loggingra�collectionsr�	functoolsr�	ipaddressrrr�typingrr	r
rr�	getLoggerr9�LOG�MAC_RErrAr?r%r#�<module>r�sP����	�#��?�?�5�5��g����!��	2��3<�3<�lI�Ir%

Zerion Mini Shell 1.0