%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�f�[���ddlZddlZddlZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
eje�Zggddd	�Zd
�Ze	j&dd�
�d��Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zdd�Zy)�N)�copy�deepcopy)�IPv4Network)�subp�util)�net_prefix_to_ipv4_mask)�SimpleTable�F��ipv4�ipv6�hwaddr�upc	���tj|�}i}|D�]X}d|vr|dng}|jd�dk(r|dnd}|td|vxrd|v�ggd�}|jd	g�D]�}|jd
�dk(rvd|vr$t	td
|d���j�nd}|jdd�||jdd�|jdd�d�}	|dj|	���|d
dk(s��|jdd�}
|
r(|jd�s|
�d|jdd���}
|
|jdd�d�}	|dj|	���|||d<��[|S)a&Get network device dicts from ip route and ip link info.

    ipaddr_json: Output string from 'ip --json addr' command.

    Returns a dict of device info keyed by network device name containing
    device configuration values.

    Raises json.JSONDecodeError if json could not be decoded
    �flags�	link_type�ether�addressr
�UP�LOWER_UP)rrrr
�	addr_info�family�inet�	prefixlenz0.0.0.0/�local�	broadcast�scope)�ip�mask�bcastrr�inet6�/�@)r�scope6r
�ifname)�json�loads�get�bool�strr�netmask�append)�ipaddr_json�ipaddr_data�devs�devrr�dev_info�addrr�parsed_addrrs           �3/usr/lib/python3/dist-packages/cloudinit/netinfo.py�_netdev_info_iproute_jsonr5+s����*�*�[�)�K�
�D��%'�� '�3���G��B��$'�G�G�K�$8�G�$C�#�i�.�����t�u�}�<��u�)<�=���	
���G�G�K��,�	5�D��x�x��!�V�+�#�d�*���h�t�K�/@�.A�$B�C�K�K�L����(�(�7�B�/� �!�X�X�k�2�6�!�X�X�g�r�2�	���� �'�'��4��h��7�*��X�X�g�r�*���d�h�h�y�1��4�q����+�r�!:� ;�<�B��"�h�h�w��3����� �'�'��4�7	5�8'��S��]��K%'�L�K�z22.1zqRequired by old iproute2 versions that don't support ip json output. Consider upgrading to a more recent version.)�deprecated_version�
extra_messagec�0�i}d}t|j��D�]�\}}tjd|�}|rm|j	d�j�j
d�d}|j	d�j
d�}ggdtd	|vxrd
|v�d�||<��d|vrVtjd
|�}|stjd||���||dj|j����d|vr�tjd|�}|stjd||���|j�}|jd�}|jd�\}	}
}|sd}||dj|	|dr|dndt|�|dd�����d|vrhtjd|�}|stjd||����|j	d�dk(r|j	d�||d<���d||d<������|S)z�
    @param ipaddr_out: Output string from 'ip addr show' command.

    @returns: A dict of device info keyed by network device name containing
              device configuration values.
    @raise: TypeError if ipaddr_out isn't a string.
    Nz.^\d+:\s(?P<dev>[^:]+):\s+<(?P<flags>\S+)>\s+.*r0�@rr�,r
rrrr!z?\s+inet6\s(?P<ip>\S+)(\s(peer\s\S+))?\sscope\s(?P<scope6>\S+).*z*Could not parse ip addr show: (line:%d) %sr
rzd\s+inet\s(?P<cidr4>\S+)(\smetric\s(?P<metric>\d+))?(\sbrd\s(?P<bcast>\S+))?\sscope\s(?P<scope>\S+).*�cidr4r"�32rr r)rr rr�linkz-\s+link/(?P<link_type>\S+)\s(?P<hwaddr>\S+).*rrr)�	enumerate�
splitlines�re�match�group�lower�splitr)�LOG�warningr,�	groupdict�pop�	partitionr)�
ipaddr_outr/�dev_name�num�line�mrrBr<r2�_�prefixs            r4�_netdev_info_iprouterRas2���D��H��z�4�4�6�7�@�	��T��H�H�F��M����w�w�u�~�+�+�-�3�3�C�8��;�H��G�G�G�$�*�*�3�/�E�����4�5�=�@�Z�5�-@�A�	�D��N���_����.��	�A�����@�#�t�����N�6�"�)�)�!�+�+�-�8�
�t�^����-���A�����@�#�t����K�K�M�E��I�I�g�&�E�#�o�o�c�2�O�D�!�V������N�6�"�)�)��/4�W�~�U�7�^�2�3�F�;�"�7�^�	�
��t�^����@�$��A�����@�#�t����w�w�{�#�w�.�+,�7�7�8�+<��X��x�(�+-��X��x�(��A@�B�Kr6c���i}|j�D�]^}t|�dk(r�|ddvr?|j�d}|jd�r|dd}||vrt	t
�||<|j
�j�j�}t|�dkDr!tjd|d�rd|d<tt|��D�]�}||d	k(r>||dzjd
�\}}|dj|t|�d���J||d
k(r||dz|ddd<�g||dk(r||dz|d<�~||dk(rK||dzdk(r |djd||dzi���|djd||dzi���||dk(r*|dddd
z||dzz}|||ddd<��||jd�r"||jd�|ddd<��9||dk(s��Ctjd||dz�}	|	r|	j!d�|ddd<���||dz|ddd<�����a|S)Nr��	� �:����zflags=[x\d]+<up.*>Trrr"r)rrrr zaddress:rr!�addr:r
r�r�scope:r$�scopeid�	.*<(\S+)>)r@�lenrE�endswithr�DEFAULT_NETDEV_INFOrD�striprA�search�ranger,r�
startswith�lstriprBrC)
�
ifconfig_datar/rN�curdev�toks�i�network�net_bits�addr6�ress
          r4�_netdev_info_ifconfig_netbsdro�s���
�D��(�(�*�(E���t�9��>����7�+�%��Z�Z�\�!�_�F����s�#�������T�!�'�(;�<��V���z�z�|�!�!�#�)�)�+���t�9�q�=��y�y�.��Q��8�%)��V��T�"��s�4�y�!�	E�A��A�w�&� �$(��Q��K�$5�$5�c�$:�!����V��V�$�+�+�"�,C�H�,M�N���a��K�'�48��Q��K��V��V�$�R�(��1��a��J�&�)-�a�!�e���V��X�&��a��G�#���A��;�'�)���L��(�/�/��t�A��E�{�0C�D���L��(�/�/��t�A��E�{�0C�D��a��K�'��V��V�,�R�0��6��<�t�A��E�{�J��16��V��V�$�R�(��.��a��#�#�H�-�59�!�W�^�^�H�5M��V��V�$�R�(��2��a��I�%��h�h�|�T�!�a�%�[�9���9<���1��D��L��(��,�X�6�9=�a�!�e��D��L��(��,�X�6�3	E�(E�T�Kr6c��i}|j�D�]�}t|�dk(r�|ddvr?|j�d}|jd�r|dd}||vrt	t
�||<|j
�j�j�}|ddk(r	d|d<n/t|�dkDr!tjd|d�rd|d<tt|��D�]}||d	k(r/|d
jd||dzjd�i��;||jd
�r!||jd
�|d
dd<�p||dk(r||dz|d
dd<��||jd�r!||jd�|d
dd<��||dk(r||dz|d
dd<��||dk(s||dk(r||dz|d<��||dk(rM||dzdk(r!|djd||dzi���2|djd||dzi���S||dk(r*|ddddz||dzz}|||ddd<���||jd�r"||jd�|ddd<���||dk(s���tjd||dz�}|r|jd�|ddd<��||dz|ddd<�����|S)NrrTrWrXrTrYz
flags=\d+<up,rrrrZzbcast:r rzmask:rr+rrr!r
r[rr"r\r$r]r^)r@r_rEr`rrarDrbrArcrdr,rfrerBrC)rgr/rNrhrirjrmrns        r4�_netdev_info_ifconfigrq�s���
�D��(�(�*�1E���t�9��>����7�+�%��Z�Z�\�!�_�F����s�#�������T�!�'�(;�<��V���z�z�|�!�!�#�)�)�+����7�d�?�!%�D��L�����Y��]��y�y�)�4��7�3�%)��V��T�"��s�4�y�!�	E�A��A�w�&� ��V��V�$�+�+��4��A��;�-�-�g�6�7���a��#�#�H�-�48��G�N�N�8�4L��V��V�$�R�(��1��a��K�'�48��Q��K��V��V�$�R�(��1��a��#�#�G�,�37��7�>�>�'�3J��V��V�$�R�(��0��a��I�%�37��A��;��V��V�$�R�(��0��a��H�$��Q��7�(:�)-�a�!�e���V��X�&��a��G�#���A��;�'�)���L��(�/�/��t�A��E�{�0C�D���L��(�/�/��t�A��E�{�0C�D��a��K�'��V��V�,�R�0��6��<�t�A��E�{�J��16��V��V�$�R�(��.��a��#�#�H�-�59�!�W�^�^�H�5M��V��V�$�R�(��2��a��I�%��h�h�|�T�!�a�%�[�9���9<���1��D��L��(��,�X�6�9=�a�!�e��D��L��(��,�X�6�=	E�'1E�f�Kr6c�x���i}tj�r*tjddgddg��\}}t|�}n�tjd�r'	tjgd��\}}t|�}nTtjd�r*tjddgddg��\}}t|�}ntjd	�|d
k(r|Stttf�d
��fd�	��||��|S#tj$r(tjgd��\}}t|�}Y�ewxYw)N�ifconfigz-arrY��rcsr)rz--jsonr2)rr2�showz>Could not print networks: missing 'ip' and 'ifconfig' commandsr
c���t|t�r|j�}n-t|ttf�rt|�}nt
d��|D]%\}}||vr|||<�t|��s��||��'y)zQRecursively replace 'empty_vals' in data (dict, tuple, list)
        with new_valzUnexpected input to fillN)�
isinstance�dict�items�tuple�listr?�	TypeError)�data�new_val�
empty_vals�myiter�key�val�fill�
recurse_typess      ��r4r�znetdev_info.<locals>.fill9su����d�D�!��Z�Z�\�F�
��u�d�m�
,��t�_�F��6�7�7��	#�H�C���j� �#��S�	��C��/��S�'�"�		#r6)r)r
)r
r6)r�	is_NetBSDrro�whichr5�ProcessExecutionErrorrRrqrFrGryr{r|)�emptyr/�	ifcfg_out�_errrKr�r�s     @@r4�netdev_infor�s���
�D��~�~�� �I�I�z�4�&8�q�!�f�E���D�+�I�6��	
���D�	�	4�!%���+C�!D��Z��,�Z�8�D�

���J�	� �I�I�z�4�&8�q�!�f�E���D�$�Y�/�����L�	
�
��{����5�$�'�M�#� 	��u���K��G�)�)�	4�!%���+A�!B��Z��'�
�3�D�	4�s�%C>�>8D9�8D9c��i}g|d<g|d<|j�}ddddddd�}|D�]!}t|�}|s�|j�}dg}|ddk(rd|d	<d|d
<n]d|dvr|djd�\}}	n&|d}d}	|jd
�t	|	�|d
<||d	<t	|	�|d
<d|d<tt
|��D]N}
||
dk(r||
dz|d<|jdd�||
dk(r||
dz|d<||
dk(s�D||
dz|d<�Pdj|�|d<|dj|���$	tjgd�ddg��\}}|j�}
|
D]�}i}|s�|j�}|ddk(rd|d	<d|d<n|d|d	<d|d<d|d<tt
|��D]T}
||
dk(r||
dz|d<d|d<||
dk(r||
dz|d<||
dk(r||
dz|d<||
dk(s�J|ddz|d<�V|dj|���|S#tj$rY|SwxYw)aP
    Get network route dicts from ip route info.

    @param iproute_data: Output string from ip route command.

    @returns: A dict containing ipv4 and ipv6 route entries as lists. Each
              item in the list is a route dictionary representing destination,
              gateway, flags, genmask and interface information.
    rr
r
)�destinationr�gateway�genmask�iface�metric�Ur�default�0.0.0.0r�r�r"r=�Hr��viarY�Gr0r�r�r)rz	--onelinez-6�router|�table�allrtz::/0�UG�::�expires�e)r@rrEr,rrdr_�insert�joinrr�)�iproute_data�routes�entries�default_route_entryrN�entryrirr2�cidrrj�
iproute_data6�_err6�entries6s              r4�_netdev_route_info_iprouter�Ms���F��F�6�N��F�6�N��%�%�'�G�������
���%���(�)�����z�z�|�������7�i��#,�E�-� �(�E�)���d�1�g�~�#�A�w�}�}�S�1���t��A�w�������S�!�#:�4�#@��i� �#'�E�-� �6�t�<�E�)��(�E�)���s�4�y�!�	.�A��A�w�%��#'��A��;��i� ����Q��$��A�w�%��!%�a�!�e���g���A�w�(�"�"&�q�1�u�+��h��	.�������g���v����e�$�;%�<)�!%���F��A��"
����!�+�+�-���	)�D��E����:�:�<�D��A�w�)�#�'-��m�$�!%��g��'+�A�w��m�$�#'��i� �!$��g���3�t�9�%�	
:����7�e�#�'+�A��E�{�E�)�$�%)�E�'�N���7�e�#�%)�!�a�%�[�E�'�N���7�h�&�&*�1�q�5�k�E�(�O���7�i�'�%*�7�^�c�%9�E�'�N�	
:�
�6�N�!�!�%�(�-	)�.�M��7�%�%�
��4�M�7
�s�H>�>I�Ic
���i}g|d<g|d<|j�}|D]�}|s�|j�}t|�dks(|ddk(s |ddk(s|ddk(s|ddk(s|dd	k(r�Mt|�d
kr/|jd�|jd�|d|d
<d|d<|d|d|d|d|d|d|d|d
d�}|dj|���	t	jgd�ddg��\}}|j�}|D]�}|s�|j�}t|�d
ks(|ddk(s |ddk(s|ddk(s|ddk(s|ddk(r�M|d|d|d|d|d|d|dd�}|ddk(r�u|djd�rt
jdd|d�|d<|dj|���|S#tj$rY|SwxYw)Nrr
�r�Kernel�Destination�Internet�	Internet6�Routing��-��rYr[��)r�r�r�rr��ref�user�)�netstatz-Ar!�--route�	--numericrt�Proto�Active)r�r�rr�r�r�r�r��lor�z/128z\/128$r
)	r@rEr_r,rr`rA�subr�)	�
route_datar�r�rNrir��route_data6r�r�s	         r4�_netdev_route_info_netstatr��sv��
�F��F�6�N��F�6�N��#�#�%�G��#%�����z�z�|��
��I��M��A�w�(�"��A�w�-�'��A�w�*�$��A�w�+�%��A�w�)�#���t�9�q�=��K�K����K�K����1�g�D��G��D��G���7��A�w��A�w��!�W��1�g���7���7��!�W�	
��	�v����e�$�G#%�J&)�#�y�y�>�Q��F� 
���e��)�)�+���	)�D����:�:�<�D��D�	�A�
���7�h�&���7�m�+���7�j�(���7�g�%���7�h�&��#�A�w���7��a���q�'��A�w��A�w��a���E��W�~��%���]�#�,�,�V�4�')�v�v��r�5��#7�(��m�$�
�6�N�!�!�%�(�=	)�>�M��G�%�%�
��D�M�G
�s�#G�G(�'G(c�,�i}tjd�r'tjgd��\}}t|�}|Stjd�r+tjgd�ddg��\}}t|�}|Stjd�|S)	Nr)rz-or�r|r�)r�r�r�z--extendrrYrtz;Could not print routes: missing 'ip' and 'netstat' commands)rr�r�r�rFrG)r��iproute_outr��	route_outs    r4�
route_infor��s���
�F��z�z�$��"�i�i�(E�F���d�+�K�8���M�
���I�	� �I�I�;�!�Q��
���D�,�I�6��
�M�	���I�	
��Mr6c���g}d}	t|��}|sygd�}t|�}t|j��D]�\}}|j	d�D]5}|j||d|d|d|j	d	|�|d
f��7|j	d�D]2}|j||d|d||j	d|�|d
f��4t
|j	d��t
|j	d��zd
k(s��|j||d||||d
f���|j�}t
t|j�t���}	tjdd|	�}
|j|
|g�dj#|�dzS#t$rI}|jtjdjt!|���dd��Yd}~�ad}~wwxYw)N�.)r��
)�Device�Up�Address�Mask�Scopez
Hw-Addressrrrrrrr
r$r�r�zNet device info�+z Net device info failed ({error})��error�!�P)r�r	�sortedrzr(�add_rowr_�
get_string�maxr@r�center�extend�	Exceptionr,�formatr*r�)�linesr��netdev�fields�tblr0r~r2�netdev_s�max_len�headerr�s            r4�netdev_pformatr�
s����E��E�-)��5�)����K���&�!��!�&�,�,�.�1�	�K�S�$�����(�

�������T�
��T�
��V������%�0��X��
�	�

�����(�

�������T�
��T�
������5�1��X��
�	�

��4�8�8�F�#�$�s�4�8�8�F�+;�'<�<��A�����$�t�*�e�U�E�4��>�J��1	�6�>�>�#���c�(�-�-�/�S�9�:�����.��W�=��
���f�h�'�(��9�9�U��d�"�"��Y�
�
����K�K�2�9�9��A��9�G���
�	
�	
��
�s�F � 	G2�)?G-�-G2c
��g}	t�}|jd�r�gd�}t|�}t|jd��D]D\}}t	|�}	|j||d|jdd�|d|d|dg��F|j�}tt|j�t�
��}	tjdd|	�}
|j|
|g�|jd
�r�gd�}t|�}t|jd
��D]I\}}t	|�}|ddk(r�	|j||d|jdd�|d|dg��K|j�}tt|j�t�
��}	tjdd|	�}
|j|
|g�	dj'|�dzS#t$r(}tjtd	|z�Yd}~���d}~wwxYw#t$r(}tjtd	|z�Yd}~��#d}~wwxYw#t $rf}|j#tjdj%t	|���dd��tjtd|z�Yd}~��d}~wwxYw)Nr)�Router��Gateway�Genmask�	Interface�Flagsr�r�r�r�r�rzRoute info formatting error: %sr�zRoute IPv4 infor�r
)r�r�r�r�r�r�r�zRoute IPv6 infozRoute info failed ({error})r�r�r�zRoute info failed: %sr�)r�r(r	r?r*r��KeyErrorr�logexcrFr�r_r�r@r�r�r�r,r�r�)
r�r��	fields_v4�tbl_v4�n�r�route_idr��route_sr�r��	fields_v6�tbl_v6s
             r4�
route_pformatr�As����E�C,�����:�:�f���I�!��+�F�#�F�J�J�v�$6�7�
L���A��q�6��L��N�N�$��m�,��E�E�)�Y�7��i�L��g�J��g�J�
�	�
L��'�'�)�G��#�g�0�0�2��<�=�G��[�[�!2�C��A�F��L�L�&�'�*�+��:�:�f���I�!��+�F�#�F�J�J�v�$6�7�
L���A��q�6���W�:��%��L��N�N�$��m�,��E�E�)�T�2��g�J��g�J���
L� �'�'�)�G��#�g�0�0�2��<�=�G��[�[�!2�C��A�F��L�L�&�'�*�+��9�9�U��d�"�"��G �L��K�K��%F��%J�K�K��L��: �L��K�K��%F��%J�K�K��L��y�6�
����K�K�-�4�4�3�q�6�4�B�C��
�	
�
	
���C�0�1�4�5�5��
6�sH�
I�3G.�/H"�.	H�7H�H�"	I�+I�I�	K�AK�Kc�H�g}t�j�}|r|D]}|j|�|����n|j|�t	�j�}|r|D]}|j|�|����n|j|�dj|�S)Nr�)r�r@r,r�r�r�)rQr��netdev_linesrN�route_liness     r4�
debug_infor��s����E�!�#�.�.�0�L�
� �	2�D��L�L�6�4�0�1�	2�	���\�"��/�,�,�.�K�
��	2�D��L�L�6�4�0�1�	2�	���[�!��9�9�U��r6)r
)z	ci-info: )r&�loggingrArr�	ipaddressr�	cloudinitrr�cloudinit.net.network_stater�cloudinit.simpletabler	�	getLogger�__name__rFrar5�deprecate_callrRrorqr�r�r�r�r�r�r��r6r4�<module>rs�����	��!� �?�-��g����!��& "�2��5�I��3�l�����K��
K��
K�\-�`6�r-�`U�pR�j�&1#�hF#�Rr6

Zerion Mini Shell 1.0