%PDF- %PDF-
Mini Shell

Mini Shell

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

�

���fU���ddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZej e�Zgd�Zgd�Zgd�Zd	�Zd
�Zdd�Zd�Zd
�Zd�ZGd�dej8�Zdd�Zdd�Zy)�N)�Optional)�subp�util)�ParserError�renderer�subnet_is_ipv6)�NetworkState)zpre-up�upzpost-up�downzpre-downz	post-down)�
bridge_ageing�bridge_bridgeprio�	bridge_fd�
bridge_gcinit�bridge_hello�
bridge_maxage�bridge_maxwait�
bridge_stp)�address�netmask�	broadcast�network�metric�gateway�pointtopoint�media�mtu�hostname�
leasehours�	leasetime�vendor�client�bootfile�server�hwaddr�provider�frame�netnum�endpoint�local�ttlc�D�g}gd�}|j�D]}\}}|dk(r�|dk(r
|d�d|d��}|s�!||vs�&t|t�rdj|�}d|vr|j	dd�}|jd	j
||���t|�S)
N)
rrrrr�pointopointr�scope�
dns_search�dns_nameserversrr�/�prefix� �_�-�    {0} {1})�items�
isinstance�list�join�replace�append�format�sorted)�iface�subnet�content�	valid_map�key�values      �3/usr/lib/python3/dist-packages/cloudinit/net/eni.py�_iface_add_subnetrE@s����G��I��l�l�n�
=�
��U��)����)��%�i�0�&��2B�C�E��S�I�%��%��&��������c�z��k�k�#�s�+���N�N�=�/�/��U�;�<�
=��'�?��c
�P�|dk7rgSg}gd�}gd�}ddi}|ddvr|jd�|j�D]�\}}t|t�r	||rdnd	}|r||vr�&|d
k(r#|r!||k7rtjd|d||��N||vr9|D]3}	|jd
j
|j||�|	���5��t|t�rdj|�}|jd
j
|j||�|����t|�S)Nr)	�control�	device_id�driver�index�inet�mode�name�subnets�type)�bridge_pathcost�bridge_portprio�bridge_waitport�mac_address�	hwaddressrP)�bond�bridge�
infiniband�vlan�on�offrzZNetwork config: ignoring %s device-level mtu:%s because ipv4 subnet-level mtu:%s provided.rNr5r2)r;r6r7�bool�LOG�warningr<�getr8r9r=)
r>rK�ipv4_subnet_mtur@�
ignore_map�multiline_keys�renamesrBrC�vs
          rD�_iface_add_attrsre^sD��
��z��	��G�
�J��N��k�*�G��V�}�D�D����-�(��k�k�m�K�
��U��e�T�"�!�#�J�D�E�E���z�)���%�<�O���'����:��&�M��#��
��.� ��
O�����}�3�3�G�K�K��S�4I�1�M�N�
O���e�T�"��H�H�U�O�E����}�+�+�G�K�K��S�,A�5�I�J�-K�0�'�?�rFc�@�|d}|d}|dk(rd}n|dvrd|z}nd|z}|j�}|j||d��djdi|��d	jdi|��g}|r2|jd
�r!|j	djdi|���|S)
NrNrH�auto)�hotplugzallow-z
# control-)�fullname�cverbz{cverb} {fullname}ziface {fullname} {inet} {mode}rTz    hwaddress {mac_address}�)�copy�updater<r_r;)r>rK�render_hwaddressrirHrj�subst�liness        rD�_iface_start_entryrq�s����V�}�H��I��G��&����	�L�	 ��7�"���w�&���J�J�L�E�	�L�L�h��7�8�	$��#�#�,�e�,�/�(�/�/�8�%�8�
�E��E�I�I�m�4�
���9�2�9�9�B�E�B�C��LrFc�d�d}|j�D�]V}|j�}|jd�r�&|jd�}|d}|dk(�rm|d}|jd�s tj
j
||�}tj|�D�]}	t	j|	�}
|
D�cgc]u}tj
jtj
j
|	|��r6tjd|�� tj
j
|	|���w}
}|
D]}t|d	�5}
|
j�j�}ddd�tj
j|�}t|tj
j!|�|��������|d
k(r�|d}|jd�s tj
j
||�}tj|�D]}	t|	d	�5}
|
j�j�}ddd�tj
j|	�}t|tj
j!|�|������|dk(r|ddD]}||vrd|i||<d
||d<����|dk(rB|dd\}}}||vrd|i||<nd||vrt#d|�d|�d���|||d<|||d<|}���|dk(r|ddk(r|d}n|d}|||d<��|t$vr
|d|||<��%|t&vr:|||vrg|||<|||j)dj
|dd����g|jd�r}d||vri||d<|dk(r1g||dd<|ddD]}||ddj)|�����|dk(s���g||dd<|ddD]}||ddj)|�����|jd��r
d||vri||d<|t*vr#|j-dd d�}|d||d|<��A|d!k(r1g||dd"<|ddD]}||dd"j)|����w|d#k(r6|dj/�d$k(r|d||dd$<���|d||dd$<���|d%k(r+d&||dvri||dd&<|d||dd&|d<���|d'k(s���d(||dvri||dd(<|d||dd(|d<��|jd)�s��'d*||vri||d*<|j-d)d d�}|d||d*|<��Y|j1�D]}d||vs�d+||d<�ycc}w#1swY��1xYw#1swY��gxYw),a~Parses the file contents, placing result into ifaces.

    '_source_path' is added to every dictionary entry to define which file
    the configuration information came from.

    :param ifaces: interface dictionary
    :param contents: contents of interfaces file
    :param src_dir: directory interfaces file was located
    :param src_path: file path the `contents` was read
    N�#r2rzsource-directory�r0z^[a-zA-Z0-9_-]+$�r�sourcerg�_source_pathTr>��familyz
Interface z* can only be defined once. Re-defined in 'z'.�methodrU�ether�zdns-�dnsz
dns-search�searchzdns-nameservers�nameservers�bridge_rW��bridge_ports�ports�	bridge_hw�macrQ�pathcostrR�portpriozbond-rVF)�
splitlines�strip�
startswith�split�os�pathr9�glob�listdir�isfile�re�match�open�read�abspath�_parse_deb_config_data�dirnamer�NET_CONFIG_OPTIONS�NET_CONFIG_COMMANDSr;�NET_CONFIG_BRIDGE_OPTIONSr:�lower�keys)�ifaces�contents�src_dir�src_path�currif�liner��option�parsed_src_dir�
expanded_path�dir_contentsr��entry�fp�src_data�	abs_entry�new_src_path�abs_pathr>ryrz�val�domainr#�
bridge_option�bond_options                          rDr�r��sk���F��#�#�%�s;���z�z�|���?�?�3����
�
�3����q����'�'�"�1�X�N�!�,�,�S�1�!#�����g�~�!F��!%���>�!:�
�
�!�z�z�-�8��!-� �������r�w�w�|�|�M�4�'H�I��H�H�%7��>�J�	�G�G�L�L���5� �� �*��E��e�S�)�5�R�#%�7�7�9�?�?�#4��5� "������ 6�I�*���"�'�'�/�/�)�*D�i��	�
�"�x�
� ��8�L��*�*�3�/�!�w�w�|�|�G�\�B��!%���<�!8�
�
��-��-�1��!�w�w�y���0�H�1��7�7�?�?�=�9��&��H�b�g�g�o�o�h�&?���	
��v�
��q�r��
-����&�'��%�F�5�M�)-��u�
�f�%�

-��w�
�$)�!�A�J�!�E�6�6��F�"�#�H�!��u�
��V�E�]�*�!�-2�H�>���'-�F�5�M�(�#�&,�F�5�M�(�#��F�
�{�
"��Q�x�7�"��A�h���A�h��*-�F�6�N�;�'�
�)�
)�%*�1�X�F�6�N�6�"�
�*�
*��V�F�^�+�)+��v��v�&��6�N�6�"�)�)�#�(�(�5���9�*=�>�
�
�
�v�
&��F�6�N�*�(*��v��u�%���%�24��v��u�%�h�/�#�A�B�i�C�F��6�N�5�)�(�3�:�:�6�B�C��,�,�79��v��u�%�m�4�#�A�B�i�H�F��6�N�5�)�-�8�?�?��G�H�
�
�
�y�
)��v�f�~�-�+-��v��x�(��2�2� &���y�"�a� @�
�:?��(��v��x�(��7��>�)�46��v��x�(��1�"�1�2�Y�D�E��6�N�8�,�W�5�<�<�U�C�D��;�&�
��8�>�>�#�u�,�6;�A�h�F�6�N�8�,�U�3�6;�A�h�F�6�N�8�,�U�3��,�,��V�F�^�H�%=�=�;=�F�6�N�8�,�Z�8�AF�q���v��x�(��4�U�1�X�>��,�,��V�F�^�H�%=�=�;=�F�6�N�8�,�Z�8�AF�q���v��x�(��4�U�1�X�>�
�
�
�w�
'��V�F�^�+�)+��v��v�&� �.�.��"�a�8�K�27��(�F�6�N�6�"�;�/�gs;�h����*������&�$)�F�5�M�&�!�*��Q �5�5��1�1�s�=A:V�
V	�!V%�V"
�%V/c�:�i}t||dd��t|�S)N)r�r�)r��_ifaces_to_net_config_data)�eni_datar�s  rD�convert_eni_datar�7s ��
�F��6�8�T�D�I�%�f�-�-rFc��i}|j�D]�\}}|jd�d}||vr"|dk(rd}nd}||gd�||<d|vr|d||d<||d	d
�}|jd�rd|d<nd
|d<|jd	�dk(r|d|d<dD]}||vs�||||<�d|vr&dD]!}||dvs�|d|s�|d||d|z<�#||dj|���dt	|�D�	cgc]}	||	��	c}	d�Scc}	w)z�Return network config that represents the ifaces data provided.
    ifaces = _parse_deb_config_data(...)
    config = ifaces_to_net_config_data(ifaces)
    state = parse_net_config_data(config).�:r�lo�loopback�physical)rPrNrOrUrTrz)�_orig_eni_namerPrgrH�manual�staticr)rrrr})rr~�dns_rOrt)�version�config)r6�	partitionr_r;r=)
r��devsrN�data�devname�dtyper?�copy_key�n�ds
          rDr�r�>sn��
�D��l�l�n�0�
��d��.�.��%�a�(���$���$��"��"��%*�G��K�D��M��d�"�/3�K�/@��W�
�m�,�$(�$�x�.�A���8�8�F�� &�F�9�� (�F�9���8�8�H���)� $�Y��F�9��;�	2�H��4��#'��>��x� �	2��D�=�.�
8����U��#��U��A��)-�e��Q��F�6�A�:�&�
8�	
�W�
�i� �'�'��/�=0�@�f�T�l�$C��T�!�W�$C�D�D��$Cs�8D	c�P�eZdZdZdd�Zdd�Zd
d�Zd
d�Z		ddede	e
d	dfd
�Zy)�Rendererz@Renders network information in a /etc/network/interfaces format.Nc��|si}|jdd�|_|jdd�|_|jdd�|_y)N�eni_path�etc/network/interfaces�
eni_header�
netrules_pathz(etc/udev/rules.d/70-persistent-net.rules)r_r�r�r�)�selfr�s  rD�__init__zRenderer.__init__jsF����F��
�
�:�/G�H��
� �*�*�\�4�8���#�Z�Z��G�
��rFc���g}|dz}|dz}d}ddd�}d}|dd	k(r|d
d	k(rd}n|ddk(r
|d
dk(rd}d}	dD]�}
|r|
dk(r�|
dk(r|	|�d||
�d||
��z
}	�$|
|vs�)|
dk(rCd||
vr|	dz
}	n|jd
�dk(r|	dz
}	n|	dz
}	d
|vs�_|	d||
�d|d
��z
}	�q|	d||
�d||
��z
}	��|j||	z|z�|j||	z|z�|S)a�When rendering routes for an iface, in some cases applying a route
        may result in the route command returning non-zero which produces
        some confusing output for users manually using ifup/ifdown[1].  To
        that end, we will optionally include an '|| true' postfix to each
        route line allowing users to work with ifup/ifdown without using
        --force option.

        We may at somepoint not want to emit this additional postfix, and
        add a 'strict' flag to this function.  When called with strict=True,
        then we will not append the postfix.

        1. http://askubuntu.com/questions/168033/
                 how-to-set-static-routes-in-ubuntu-server
        zpost-up route addzpre-down route delz || true�gwr)rrr�rz0.0.0.0rz defaultz::r1rz -A inet6 default)rrrrr2r�z	 -A inet6� z -hostz -netr0)r_r;)r��route�indentr@r
r�or_true�mapping�
default_gw�
route_line�ks           rD�
_render_routezRenderer._render_routesse����
�)�
)���,�,������
��
�
����y�(�U�9�-=��-J�#�J�
�9�
��
%�%��/�Q�*>�,�J��
�1�	D�A��a�9�n���I�~��J���
�E�!�H�M�M�
��e���	�>��e�A�h��"�k�1�
����8�,��2�"�h�.�
�"�g�-�
��5�(�"�%��(�E�(�O�&L�L�
��g�a�j�%��(�"C�C�J�!	D�"	���r�J���0�1����t�j�(�7�2�3��rFc	�Z�g}|jdi�}|jdd�}|jdd�}|rd|d<|�rit|�D�]X\}}d}	||d<|d|d<|jd	d
�|d	<d}
t|�r|
dz
}
n|jd
�}	|
|d<|ddk(s|ddk(s|ddk(rd|d<|�K|rdnd|d<nA|ddk(rd
|d<d|d<n.|ddk(rd
|d<d|d<nt|�rd|d<|�	|rdnd|d<d|D�cgc]}d|dz|v��c}vrd|d	<t	t|||��t
||�zt|||	�z�}|jdg�D]$}
|j|j|
d����&|j|���[|Sg}d |vsd!|vr!|jd"jd&i|���|jd#jd&i|���|jt|d$d�%��|j|�|Scc}w)'NrOz	accept-ra�	wakeonlan�gzethernet-wolrKrPrMrHrgrL�6r�dhcp4�dhcp6zipv6_dhcpv6-stateful�dhcp�1�0�	accept_razipv6_dhcpv6-stateless�
ipv6_slaacr�Tzauto %srN�alias�rn�routesz    )r�zbond-masterzbond-slaveszauto {name}ziface {name} {inet} {mode}r)rKr`rk)r_�pop�	enumeraterr8rqrEre�extendr�r;r<)r�r>rn�sectionsrOr��ethernet_wolrKr?r`�subnet_inetr�rpr�s              rD�
_render_ifacezRenderer._render_iface�s������)�)�I�r�*���I�I�k�4�0�	��y�y��d�3���$'�E�.�!��!*�7�!3�7
'�
��v�"&��!&��g�� &�v���f�
�#)�:�:�i��#@��i� �$��!�&�)��3�&�K�&,�j�j��&7�O� +��f�
��6�N�g�-��f�~��0��f�~�)?�?�%+�E�&�M� �,�4=�S�3��k�*��F�^�'>�>�$*�E�&�M�$'�E�&�M��F�^�|�3�$*�E�&�M�$'�E�&�M�#�F�+�$,�E�&�M� �,�4=�S�3��k�*��DL��<@�I��v��/�4�7���(/�E�)�$��&��u�7G��(��v�6�7�'�u�e�_�E�	F���$�Z�Z��"�5�K�E��L�L��!3�!3�E�&�!3�!I�J�K�����&�o7
'�D���E���%��%�)?����1�]�1�1�:�E�:�;��L�L�<�5�<�<�E�u�E�F��L�L� ��a��F�
�
�O�O�E�"����5s�H(c��
�dddddd�gd�}|j�D],}|jd�dk(s�tj|�}�.|j}|rd	j|�|d
dd<|j}|rd	j|�|d
dd
<ddddddd��
g}|j|j|��t|j��
fd���D]9}|jd�dk(r�|j|j||����;|j�D]"}|j|j|���$dj|D�	cgc]}	dj|	���c}	�dzScc}	w)z1Given state, emit etc/network/interfaces content.r�r�rLr�rg)rPrH)rNrPrLrOrNr2rOrr/r.rtr|�rx�)r�r�rXrVrWrYc����|d|dfS)NrPrNrk)r��orders �rD�<lambda>z-Renderer._render_interfaces.<locals>.<lambda>s���5��6��+�Q�v�Y�7�rF)rBr�z

�
)
�iter_interfacesr_rl�deepcopyr/r9�dns_searchdomainsr�r�r=�iter_routesr;r�)r��
network_staternr�r>r�
searchdomainsr�r��sr�s          @rD�_render_interfaceszRenderer._render_interfaces�s�������!+��?�@�	
��#�2�2�4�	*�E��y�y�� �D�(��]�]�5�)��	*�$�3�3���25�(�(�;�2G�B�y�M�!��.�/�%�7�7�
��-0�X�X�m�-D�B�y�M�!��\�*�
������

��������*�*�2�.�/���)�)�+�7�
�		�E�
�y�y�� �D�(���O�O��"�"�5�;K�"�L�
�		�#�.�.�0�	7�E��O�O�D�.�.�u�5�6�	7��{�{�(�;�Q�D�I�I�a�L�;�<�t�C�C��;s�%Fr��	templates�returnc�8�tj||j�}tjt
jj|��|jr|jnd}tj|||j|�z�|jrztj||j�}tjt
jj|��tj||j|�d��yy)Nr�T)r@�
preserve_mode)
r�target_pathr�r�
ensure_dirr�r�r�r��
write_filer�r��_render_persistent_net)r�r�r�target�fpeni�header�netruless       rD�render_network_statezRenderer.render_network_state(s���� � �����7�����������.�/�$(�O�O����������v��(?�(?�
�(N�N�O�����'�'���0B�0B�C�H��O�O�B�G�G�O�O�H�5�6��O�O���3�3�M�B�"�
�rF�N)r��F)NN)�__name__�
__module__�__qualname__�__doc__r�r�r�r�r	r�dictrrkrFrDr�r�gsK��J�
�2�hK�Z2D�n%)��	�#���D�>��

�rFr�c��d}t||dd���}|sd}|jd�s|dz
}|j||��}||zS)Nr�)r�r�r�)r�r�r�r�)r��endswithr�)r�r
rnr�rr�s      rD�network_state_to_enir=sc��'�H�� � �!�
��H�����?�?�4� ��$���*�x�*�*��(8��H��H��rFc���gd�}ddg}|D]}tj|||��r�ytj|d�}tjj|�syy)N)�ifquery�ifup�ifdownz/sbinz	/usr/sbin)r~rFr�T)r�whichrr�r�r�)r�expectedr~�p�enis     rD�	availablerQs^��,�H��{�
#�F�
����z�z�!�F�6�:����
�
�6�#;�
<�C�
�7�7�>�>�#���rFr)NFr
)rlr��loggingr�r��typingr�	cloudinitrr�
cloudinit.netrrr�cloudinit.net.network_stater	�	getLoggerrr]r�r�r�rErerqr�r�r�r�rrrkrFrD�<module>r&s������	�	�� �?�?�4��g����!����	����8�<9�x�0B*�J.�&E�RS�x� � �S�l�(
rF

Zerion Mini Shell 1.0