%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__/sysconfig.cpython-312.pyc

�

�fţ��T�ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZddlm
Z
mZddlmZmZmZmZmZddlmZej.e�Zgd�Zdd�Zd	�Zd
�ZGd�d�ZGd
�de�ZGd�de�Z Gd�dejB�Z!d�Z"dd�Z#dd�Z$dd�Z%y)�N)�Mapping�Optional)�subp�util)�networkmanager_conf�resolv_conf)�IPV6_DYNAMIC_TYPES�is_ipv6_address�net_prefix_to_ipv4_mask�renderer�subnet_is_ipv6)�NetworkState)�	almalinux�centos�
cloudlinux�	eurolinux�fedora�miraclelinux�	openeuler�OpenCloudOS�openmandriva�rhel�rocky�suse�	TencentOS�	virtuozzoc��ddg}tt|��D]}||r|dz||z||<�|||<�dj|�S)Nz1Created by cloud-init automatically, do not edit.�� �
)�range�len�join)�sep�lines�is   �9/usr/lib/python3/dist-packages/cloudinit/net/sysconfig.py�_make_headerr()s`��;�
�
�E��3�u�:�
�����8��S�y�5��8�+�E�!�H��E�!�H�	�
�9�9�U���c�(�d}|ddk(xr|d|vS)N)z::z0.0.0.0�prefixr�network�)�route�default_netss  r'�_is_default_router06s%��$�L���?�a��D�E�)�$4��$D�Dr)c��tjd|�r)|jd�r|jd�r|Sd|zS|S)Nz\s�"z"%s")�re�search�
startswith�endswith)�values r'�_quote_valuer8;s=��	�y�y�������C� �U�^�^�C�%8��L��E�>�!��r)c�V�eZdZdZddd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zy)�	ConfigMapz!Sysconfig like dictionary object.�yes�no)TFc��i|_y�N��_conf��selfs r'�__init__zConfigMap.__init__Os	����
r)c�"�||j|<yr>r?)rB�keyr7s   r'�__setitem__zConfigMap.__setitem__Rs����
�
�3�r)c� �|j|Sr>r?�rBrEs  r'�__getitem__zConfigMap.__getitem__Us���z�z�#��r)c�8�|jj|�Sr>)r@�getrHs  r'rKz
ConfigMap.getXs���z�z�~�~�c�"�"r)c��||jvSr>r?rHs  r'�__contains__zConfigMap.__contains__[s���d�j�j� � r)c�<�|jj|d�yr>)r@�poprHs  r'�dropzConfigMap.drop^s���
�
���s�D�!r)c�,�t|j�Sr>)r"r@rAs r'�__len__zConfigMap.__len__as���4�:�:��r)c��y)z6Skip the pair key, value if it matches a certain rule.Fr-�rBrE�vals   r'�skip_key_valuezConfigMap.skip_key_valueds��r)c��tj�}|jt��|jr|jd�t|jj
��D]~}|j|}|j||�r�%t|t�r|j|}t|t�st|�}|j|�dt|��d����|j�S)Nr �=)�io�StringIO�writer(r@�sorted�keysrV�
isinstance�bool�	_bool_map�strr8�getvalue)rB�bufrEr7s    r'�	to_stringzConfigMap.to_stringhs����k�k�m���	�	�,�.�!��:�:��I�I�d�O��$�*�*�/�/�+�,�	>�C��J�J�s�O�E��"�"�3��.���%��&����u�-���e�S�)��E�
���I�I�3��U�(;�<�=�	>��|�|�~�r)c�:�|jj|�yr>)r@�update)rB�updatess  r'rfzConfigMap.updatexs���
�
���'�"r)N)�__name__�
__module__�__qualname__�__doc__r`rCrFrIrKrMrPrRrVrdrfr-r)r'r:r:FsF��+����I�
� ��#�!�"���� #r)r:c�V��eZdZdZ�fd�Zd�Zed��Zed��Zd�Z	dd�Z
�xZS)	�Routez!Represents a route configuration.c���tt|��d|_d|_d|_||_||_||_||_	y)N�F)
�superrmrC�last_idx�has_set_default_ipv4�has_set_default_ipv6�_route_name�_base_sysconf_dir�route_fn_tpl_ipv4�route_fn_tpl_ipv6)rB�
route_name�base_sysconf_dir�ipv4_tpl�ipv6_tpl�	__class__s     �r'rCzRoute.__init__sG���
�e�T�#�%���
�$)��!�$)��!�%���!1���!)���!)��r)c��t|j|j|j|j�}|j
j
�|_|j|_|j|_|j|_	|Sr>)
rmrtrurvrwr@�copyrqrrrs)rB�rs  r'r~z
Route.copy�sp�������"�"��"�"��"�"�	
���*�*�/�/�#����]�]��
�!%�!:�!:���!%�!:�!:����r)c�N�|j|j|jd�zS�N)�base�name)rvrurtrAs r'�	path_ipv4zRoute.path_ipv4��)���%�%��+�+�T�5E�5E�F�
�	
r)c�N�|j|j|jd�zSr�)rwrurtrAs r'�	path_ipv6zRoute.path_ipv6�r�r)c�
�d|vS)N�:r-)rB�addresss  r'�
is_ipv6_routezRoute.is_ipv6_route�s���g�~�r)c
�,�|dvrtdt|�z��tj�}|j	t��|jr|j	d�d}t|jj��D�]�}d|vr�	|jdd�}t|j|�}t|jd|z�}|dk(�r|j|��st|jd	|z�}|d
z}|j	dt|�z�dt|��d��|j	dt|�z�dt|��d��|j	d	t|�z�dt|��d��d|z}	|	|jvs��t|jd|z�}
|j	dt|�z�dt|
��d����h|d
k(s��o|j|�s���t|jd|���}d|z|jvrdt|jd|z�znd}
|j	|�d|�d|�d|
�d|j�d�
����|j�S)N)�ipv4�ipv6zUnknown protocol '%s'r ����ADDRESSr�GATEWAYr��NETMASKrorX�METRICr��PREFIXzmetric �/z via rz dev )�
ValueErrorrarYrZr[r(r@r\r]�replacer�r8rtrb)rB�protorc�reindexrE�index�
address_value�
gateway_value�
netmask_value�
metric_key�metric_value�prefix_values            r'rdzRoute.to_string�sW���(�(��4��E�
�C�D�D��k�k�m���	�	�,�.�!��:�:��I�I�d�O����$�*�*�/�/�+�,�5	�C���#���K�K�	�2�.�E���
�
�3��0�M���
�
�9�u�+<� =�>�M����t�'9�'9�-�'H� #�D�J�J�y�5�/@�$A� B�
�!�A�+���	�	� �3�w�<�/��m�1L�N���	�	� �3�w�<�/��m�1L�N���	�	� �3�w�<�/��m�1L�N��&��-�
�����+�#&�t�z�z�(�U�2B�'C�#D�L��I�I�#�c�'�l�2�L��4N�P���&��T�%7�%7�
�%F�"�4�:�:��u�g�.>�#?�@�� �%�'�4�:�:�5���D�J�J�x�%�/?�$@� A�A���
�	�	�&�$�%�$��(�(�
�	�Y5	�n�|�|�~�r))r�)rhrirjrkrCr~�propertyr�r�r�rd�
__classcell__�r|s@r'rmrm|sC���+�*���
��
�
�
��
�
�Br)rmc���eZdZdZdddddd�Z	d�fd�	Zed	��Zejd
��Zed��Z	e	jd��Z	ed
��Z
dd�Zd�Z�xZ
S)�NetInterfacezERepresents a sysconfig/networking-script (and its config + children).�Ethernet�Bond�Bridge�
InfiniBand�Vlan)�ethernet�bond�bridge�
infiniband�vlanc�h��tt|��g|_||_|jjd�}t
|||jd�|jd���|_|jjd�|_||_	||_
||jd<||_y)N�route_templatesr�r�)rzr{�iface_templates�DEVICE)
rpr�rC�children�	templatesrKrm�routes�iface_fn_tpl�kind�_iface_namer@ru)rB�
iface_nameryr�r��	route_tplr|s      �r'rCzNetInterface.__init__�s����	�l�D�*�,���
�"����N�N�&�&�'8�9�	�����]�]�6�*��]�]�6�*�	
���!�N�N�.�.�/@�A�����	�%���)��
�
�8��!1��r)c��|jSr>)r�rAs r'r�zNetInterface.name	s�����r)c�0�||_||jd<y)Nr�)r�r@)rBr�s  r'r�zNetInterface.name
s��%���)��
�
�8�r)c��|jSr>)�_kindrAs r'r�zNetInterface.kinds���z�z�r)c�|�||jvrt|��||_|j||jd<y)N�TYPE)�iface_typesr�r�r@)rBr�s  r'r�zNetInterface.kinds;���t�'�'�'��T�"�"���
�!�-�-�d�3��
�
�6�r)c�N�|j|j|jd�zSr�)r�rur�rAs r'�pathzNetInterface.paths'��� � ��+�+�T�Y�Y�?�
�	
r)c�,�t|j|j|j|j��}|j
j
�|_|rt|j�|_|r|jj
�|_	|S)N)r�)
r�r�rur�r�r@r~�listr�r�)rB�
copy_children�copy_routes�cs    r'r~zNetInterface.copy#sj����I�I�t�-�-�t�~�~�D�J�J�
���*�*�/�/�#�����d�m�m�,�A�J���{�{�'�'�)�A�H��r)c��|dk(r|dk(ryy)Nr�r�TFr-rTs   r'rVzNetInterface.skip_key_value.s���&�=�S�F�]��r))r�)FF)rhrirjrkr�rCr�r��setterr�r�r~rVr�r�s@r'r�r��s����O����"���K�=G�2�(� �� �
�[�[�*��*�����
�[�[�4��4��
��
�
	�r)r�c�b�eZdZUdZddddd�ddd�d	�Zd
ddd
ddd�dddddd�d	�Zegd��ZiZe	e
d<d)d�Zed��Z
ed��Zed��Zed��Zed��Zed��Zed ��Zed)d!��Zed)d"��Zed#��Zed$��Ze	d)d%��Z		d*d&edee	d'dfd(�Zy)+�Rendererz7Renders network information in a /etc/sysconfig format.TF�none)�ONBOOT�USERCTL�
NM_CONTROLLED�	BOOTPROTO�static�auto)r��	STARTMODE)rr�IPV6_FORCE_ACCEPT_RA�STP�AGEING�PRIO�HWADDR�MTU)�	accept-ra�
bridge_stp�
bridge_ageing�bridge_bridgeprio�mac_address�mtu�
BRIDGE_STP�BRIDGE_AGEINGTIME�BRIDGE_PRIORITY�LLADDR)r�r�r�r�r�))�	bond_modezmode=%s)�bond_xmit_hash_policyzxmit_hash_policy=%s)�bond_miimonz	miimon=%s)�bond_min_linkszmin_links=%s)�bond_arp_intervalzarp_interval=%s)�bond_arp_ip_targetzarp_ip_target=%s)�bond_arp_validatezarp_validate=%s)�bond_ad_selectzad_select=%s)�bond_num_grat_arpznum_grat_arp=%s)�bond_downdelayzdowndelay=%s)�bond_updelayz
updelay=%s)�bond_lacp_ratezlacp_rate=%s)�bond_fail_over_maczfail_over_mac=%s)�bond_primaryz
primary=%s)�bond_primary_reselectzprimary_reselect=%sr�Nc�f�|si}|jdd�|_|jdd�|_|jdd�|_d}|jd|�|_|jd	�|jd
�|jd�d�|_|jd
d�|_y)N�sysconf_dirz
etc/sysconfig�
netrules_pathz(etc/udev/rules.d/70-persistent-net.rules�dns_pathzetc/resolv.confz,etc/NetworkManager/conf.d/99-cloud-init.conf�networkmanager_conf_path�controlr�r�)r�r�r��flavorr)rKr�r�r�r�r�r�)rB�config�nm_conf_paths   r'rCzRenderer.__init__qs�����F�!�:�:�m�_�E���#�Z�Z��G�
����
�
�:�/@�A��
�E��(.�
�
�&��)
��%��z�z�)�,�%�z�z�*;�<�%�z�z�*;�<�
���
�j�j��6�2��r)c�R�tj|jj|i��}|j	|�dD]I}|j|�}|��|dk(r|ddvr�$|j
|j|�}|s�E|||<�Kd|vr|dr|ddk(rd|d<yyyy)	N)r�r�r�r��type)�physicalr��	wakeonlanrzwol g�ETHTOOL_OPTS)r~�deepcopy�iface_defaultsrKrf�cfg_key_maps)�cls�iface�	iface_cfgr��flavor_defaults�old_key�	old_value�new_keys        r'�_render_iface_sharedzRenderer._render_iface_shared�s����-�-��(:�(:�(>�(>�v�r�(J�K������)�:�	3�G��	�	�'�*�I��$��m�+��f�
�F�1���*�*�6�2�6�6�w�?���)2�I�g�&�	3�
�5� ��k�"��f�
��+�(/�I�n�%�,�#�
!r)c	�L�|dk(r d|d<d|vrd|d<|jd�nd|d<t|t|j���D�]�\}}d}|j	d	�}|d
k(s|dk(rJ|dk(r|ddvrd|d<nd
|d<d
|d<�n�|dk(r|dk(rd|d<d|d<d|d<d|d<�nvd|d<d|d<�nj|dk(r4|dk(r|ddvrd|d<nd
|d<d|d<�nGd|d<d|d<d|d<d|d<�n1|dk(r*|dk(r|ddvrd|d<nd
|d<d|d<�nd|d<d|d<�n|dvr|d}	d|d<|dk(r�|	dvr�d|d<n�|dvr�t|�r|dk7rd}d|d<d|vrft
||vxr|d||k7�}
|
r(tjd |j|||d�t|�r|dk(rn|d||<n|d||<t|�rU|dk(rPd|d!<d|d<nE|d"k(r$|dk(rtjd#|�n$||v|d$<ntd%|�d&|j�d'���|j	d(�d"k(s���|dk(rd"|d)<���d|d$<��d*}d*}t|t|j���D�]�\}}|j	d	�}d+|vr
|dk7r|d+|d,<|d-vr|dk7r|r
|ddk7rd|d.<�B|tvr�K|dvs�Pt|�r]|d/z}|d0�d1|d2��}
|d3k(r|dk(r|
|d4<nq|
|d5<nk|d/k(r|dk(r|
|d6<n[|
|d7<nU|dk(r	|
|d8|z<nG|d7xxd9|
zz
cc<n6|d/z}|d3k(rd:n
t|�}|d0|d;|z<t|d2�|d<|z<d=|vr)|dk7r$d|d><t|d=�r	|d=|d?<n|d=|d@<dA|vr|dk7rd9j!|dA�|dB<dC|vs��A|dk7s��Ht|dC�dDkDr-tjdE|jt|dC��t|dCddDd/�D]\}}||dFt|�z<����y)GNrr�r��BRIDGE�dhcpr���startr�r��dhcp6zipv6_dhcpv6-stateful)�dhcp4r�managed�DHCLIENT6_MODErT�DHCPV6C�IPV6INITF�
IPV6_AUTOCONF�IPV6_FAILURE_FATALzipv6_dhcpv6-stateless�infoz-S�DHCPV6C_OPTIONS�
ipv6_slaac)rrr)r��static6�IPV6_MTUr�zZNetwork config: ignoring %s device-level mtu:%s because ipv4 subnet-level mtu:%s provided.r��manualz Unknown subnet type setting "%s"r�zUnknown subnet type 'z' found for interface '�'r�r�r��metricr��rr�DHCLIENT_SET_DEFAULT_ROUTEror�r�r+r�IPADDR6�IPV6ADDR�	IPADDR6_1�IPV6ADDR_SECONDARIESz
IPADDR6_%drr�IPADDRr��gateway�DEFROUTE�IPV6_DEFAULTGWr��
dns_search�DOMAIN�dns_nameservers�z6%s has %d entries in dns_nameservers. Only 3 are used.�DNS)rP�	enumerater"r�rKr
r_�LOG�warningr��debugr�r	rarr
r#)rr�subnets�has_default_router�r&�subnet�mtu_key�subnet_type�bootproto_in�mtu_mismatch�
ipv4_index�
ipv6_index�	ipv6_cidr�suff�ks                r'�_render_subnetszRenderer._render_subnets�s����V��%-�I�k�"��9�$�)/�	�+�&����x�(�%+�I�k�"�#�7�#�i�6H�6H�2I�J�u	0�I�A�v��G� �*�*�V�,�K��g�%��8N�)N��V�#� ��-�1B�B�17�	�+�.�29�	�+�.�2;�I�.�/��v�%��#9�9�+/�I�i�(�,0�I�j�)�16�I�o�.�6:�I�2�3�,0�I�j�)�+/�I�i�(�� 7�7��V�#� ��-�1B�B�17�	�+�.�29�	�+�.�28�I�.�/�,0�I�j�)�26�I�o�.�+/�I�i�(�48�I�/�0���,��V�#� ��-�1B�B�17�	�+�.�29�	�+�.�28�I�.�/�,0�I�j�)�15�I�o�.�� 1�1�(��5��)/�	�+�&��V�#�$�+<�<�18�	�+�.�� 5�5�"�&�)�f��.>�(�G�,0�I�j�)��F�?�#'��9�,�@�"�5�M�Y�w�-?�?�$�L�$����J�%�N�N�%�g�.�"�5�M��&�f�-�!�V�+�!�17���I�g�.�-3�E�]�	�'�*�!�&�)�f��.>�8=�I�4�5�16�I�o�.���(��V�#��I�I�@�+�N�+2�Y�*>�I�h�'� �"�I�N�N�4����z�z�)�$��0��V�#�-5�I�k�*�*/�I�h�'�ku	0�p�
��
�"�7�#�i�6H�6H�2I�J�@	6�I�A�v� �*�*�V�,�K��6�!��V�#�*0��*:�I�h�'��/�/��V�#�(�Y�{�-C�v�-M�BG�	�">�?��� 2�2��� 5�5�!�&�)�!+�a��J�+1�)�+<�f�X�>N� O�I�!�Q��!�V�+�3<�I�i�0�4=�I�j�1�#�q��!�V�+�5>�I�k�2�@I�I�&<�=�!�V�+�CL�I�l�Z�&?�@�%�&<�=� #�i���=�",�a��J�!+�q��2�c�*�o�D�17�	�1B�I�h��o�.�2I��x�(�3�I�i�$�.�/���&�6�V�+;�,0�I�j�)�&�v�i�'8�9�6<�Y�6G�	�"2�3�/5�i�/@�	�)�,��6�)�f��.>�*-�(�(�6�,�3G�*H�I�h�'�$��.�6�V�3C��6�"3�4�5��9��	�	�/�%�N�N���'8� 9�:�	�!*�&�1B�*C�B�Q�*G�� K�6���1�45�	�%�#�a�&�.�1�6�@	6r)c���|dk(ryt|t|j���D�]6\}}|jd�}|jdg�D�]	}|jd�xst	|d�}	t|�r�|tvr�|jd�r|js|jd�r$|jrtd|jz��d	|d
<|ddvrd	|d
<d|vr!|	r|d|d<d	|_n|d|d<d	|_d|vs��|d|d<��dD]"\}
}|
|vs�|�|j��}||
||<�$|xjdz
c_����9y)Nrrr�r�r�r*r�z?Duplicate declaration of default route found for interface '%s'Tr+r�r#r$r,r�r"r�))r*r�)r"r�)r+r�)�netmaskr�)r,r�ro)r2r"r�rKr
r0r	rrrsr�r�rq)
rr�	route_cfgr6r��_r8r:r.�is_ipv6r
�new_namers
             r'�_render_subnet_routeszRenderer._render_subnet_routesfs���
�V���"�7�#�i�6H�6H�2I�J�5	,�I�A�v� �*�*�V�,�K����H�b�1�3
,�� �*�*�V�,����)�$�1��&�e�,�#�+=�=��
�
�6�*�y�/M�/M��
�
�6�*�y�/M�/M�(�=�@I���P���-1�I�j�)� ��-�1B�B�BF�	�">�?� �E�)�"�:?�	�:J�I�&6�7�=A�I�:�38��3C�I�i�0�=A�I�:��5�(�.3�H�o�	�(�+�
.�	@�)���#�e�+�)1�
�9�3E�3E�2F�&G�G�16�w��I�g�.�	@��&�&�!�+�&�g3
,�5	,r)c�T�g}|jD]f\}}||jdd�g}|D]H}||vs�||}t|ttf�rdj|�}|j
||z��f�h|r/|dk(rdj|�|d<ydj|�|d<yy)NrF�-rr�BONDING_MODULE_OPTS�BONDING_OPTS)�
bond_tpl_optsr�r^�tupler�r#�append)	rrrr��	bond_opts�bond_key�	value_tpl�	bond_keys�
bond_values	         r'�_render_bonding_optszRenderer._render_bonding_opts�s����	�%(�%6�%6�		�!�X�y�!�8�#3�#3�C��#=�>�I�%�
���u�$�!&�x��J�!�*�u�d�m�<�%(�X�X�j�%9�
��$�$�Y�*�%=�>��

�		�����
47�8�8�I�3F�	�/�0�-0�H�H�Y�,?�	�.�)�r)c��tj}|j|�D]\}|d}|jdg�}||}|j}	|j|||j|�|j||	||��^y)Nr�r6)r�filter_by_physical�iter_interfacesrKr�rBr7rI)
r�
network_state�iface_contentsr��physical_filterrr��
iface_subnetsrrEs
          r'�_render_physical_interfacesz$Renderer._render_physical_interfaces�s���#�5�5��"�2�2�?�C�	�E��v��J�!�I�I�i��4�M�&�z�2�I�!�(�(�I�������/�/��	
�
�%�%��9�m�V�
�	r)c�L�tjd�}tjd�}|j|�D�]`}|d}||}|j	|||�|g}	|	j|j�|	D]}
d|
d<|dk7s�d|
_�|jd�r.|dk(r|jd�|d<n|jd�|d	<|jd
g�}|j}|j|||j|�|j||||�t|j|�D�
cgc]}
|
d|k(r|
d��c}
�}t|�D]9\}}|dk(rd|z}nd|z}|||<||}|dk(rd
|d<d|d<�0||d<d|d<�;��cycc}
w)Nr�zbond-masterr�T�BONDING_MASTERrr�r��MACADDRr6zBONDING_SLAVE_%szBONDING_SLAVE%sr�r��hotplugr��MASTER�SLAVE)r�filter_by_type�filter_by_attrrYrV�extendr�r�rKr�rBr7rIr\r2)rrZr[r��bond_filter�slave_filterrr�r�master_cfgs�
master_cfgr]rE�slave_iface�bond_slavesr��
bond_slave�slavestr�	slave_cfgs                   r'�_render_bond_interfacesz Renderer._render_bond_interfaces�s����-�-�f�5���.�.�}�=��"�2�2�;�?�9	.�E��v��J�&�z�2�I��$�$�Y��v�>�%�+�K����y�1�1�2�)�
-�
�/3�
�+�,��V�#�&,�J�O�
-�
�y�y��'��V�#�*/�)�)�M�*B�I�h�'�+0�9�9�]�+C�I�i�(�!�I�I�i��4�M�!�(�(�I�������/�/��	
�
�%�%��9�m�V�
�!�(5�'D�'D�$�(��#�#�=�1�Z�?�	 ��'���K�&/�{�%;�

.�!��z��V�#�1�E�9�H�0�5�8�H�&0�	�(�#�*�:�6�	��V�#�-3�I�k�*�-6�I�k�*�*4�I�h�'�)-�I�g�&�

.�Y9	.��Fs�;F!
c	��tjd�}|j|�D]�}|d}||}|dk(r0|jd�}|r||d<|d|j	d�|d<nPd|d	<d|_|d
}	t
|	|d�}
||
vr'tjd||	dj|
��|	|d
<|jdg�}|j}|j|||j|�|j||||���y)Nr�r�r�vlan_id�VLAN_ID�.�ETHERDEVICET�VLANzvlan-raw-devicezIName '%s' for vlan '%s' is not officially supportedby RHEL. Supported: %sr�PHYSDEVr6)rrerYrK�rfindr��_supported_vlan_namesr3rr#r�rBr7rI)
rrZr[r��vlan_filterrr�rrs�rdev�	supportedr]rEs
             r'�_render_vlan_interfacesz Renderer._render_vlan_interfacess8���-�-�f�5��"�2�2�;�?�"	�E��v��J�&�z�2�I�����)�)�I�.���+2�I�i�(�+5�6M�
�8H�8H��8M�+N�	�-�(�$(�	�&�!�!'�	���.�/��1�$��i�8H�I�	��Y�.��H�H�1�"������+��(,�	�)�$�!�I�I�i��4�M�!�(�(�I�������/�/��	
�
�%�%��9�m�V�
�A"	r)c��tt|j�t|j�g�syt	j
d�}|rGtjj|�r(t	j
tj|��}|jD]}|j|��|jD]}|j|��td�}t|�}|j|�s|dz|z}|S)Nr�;r )�anyr"r/�dns_searchdomainsr�
ResolvConf�osr��isfiler�load_text_file�add_nameserver�add_search_domainr(rar5)rZ�existing_dns_path�content�
nameserver�searchdomain�header�content_strs       r'�_render_dnszRenderer._render_dns:s�����M�1�1�2��M�3�3�4�
�
���(�(��,��������0A�!B�!�,�,��#�#�$5�6��G�(�7�7�	/�J��"�"�:�.�	/�)�;�;�	4�L��%�%�l�3�	4��c�"���'�l���%�%�f�-� �4�-�+�5�K��r)c��tjd�}|jr|jddd�t	|�dk(rydjt
�ddj|j��dg�}|S)Nr�main�dnsr�rr )r�NetworkManagerConfr/�set_section_keypairr"r#r(r[)rZr�r��outs    r'�_render_networkmanager_confz$Renderer._render_networkmanager_confSsk��%�8�8��<���(�(��'�'���v�>��w�<�1����g�g�|�~�t�T�Y�Y�w�}�}��-G��N�O���
r)c��|j|j�D��cic]\}}|jd�r||��}}}tjd�}|j|�D�]m}|d}	||	}
|dk7rd|
_|j�D]\}}||vs�|||
|<�|dk(r d|
vr|
jd�rd|
d<nd|
d<|jd�rd}
|dk(rd	}
|jd�|
|
<|dk(r8|jd
g�r&ddj|jd
��z|
d
<|jd
g�D]:}||}|g}|j|j�|D]}|	}|dk(rd}||d<��<|jdg�}|
j}|j|
||j|�|j|
|||���pycc}}w)Nr�r�rr��on�offr�ra�	LLADDRESS�bridge_portsz%sr�BRIDGE_PORTSr;rr6)r�itemsr5rrerYr�rKr#rgr�r�rBr7rI)rrZr[r��old_k�new_k�bridge_key_map�
bridge_filterrr�rr
rrE�bridged_iface_name�bridged_cfg�bridged_cfgs�
bridge_cfg�bridge_valuer]rEs                     r'�_render_bridge_interfacesz"Renderer._render_bridge_interfacesgs6��!$� 0� 0�� 8� >� >� @�
���u�����)�
�5�L�
��
�
!�/�/��9�
�"�2�2�=�A�2	�E��v��J�&�z�2�I����!)�	��$2�$8�$8�$:�
8� ����e�#�).�w��I�g�&�
8�����9�,� �}�}�\�2�26�	�,�/�27�	�,�/��y�y��'����V�#�%�C�!&���=�!9�	�#������9�9�^�R�0�04�s�x�x��	�	�.�1�8�1�I�n�-�',�i�i���&C�

8�"�-�-?�@�� +�}���#�#�K�$8�$8�9�".�8�J�#-�L���'�',��+7�J�x�(�	8�

8�"�I�I�i��4�M�!�(�(�I�������/�/��	
�
�%�%��9�m�V�
�a2	��
s�Gc��tjd�}|j|�D]c}|d}||}d|_|j	dg�}|j
}	|j
|||j|�|j||	||��ey)Nr�r�r6)	rrerYr�rKr�rBr7rI)
rrZr[r��	ib_filterrr�rr]rEs
          r'�_render_ib_interfaceszRenderer._render_ib_interfaces�s����+�+�L�9�	�"�2�2�9�=�	�E��v��J�&�z�2�I�)�I�N�!�I�I�i��4�M�!�(�(�I�������/�/��	
�
�%�%��9�m�V�
�	r)c��|s|j}i}|j�D]\}|ddk(r�|d}t|||�}|dk(r"|jd�|jd�|j	|||�|||<�^|j|||�|j
|||�|j|||�|j|||�|j|||�i}	|j�D]�\}}|s|jrN|j�|	|j<|jD]"}|s�|j�|	|j<�$|js�ot|jj |jj"gddg�D](\}
}|
|	vs�|jj|�|	|
<�*��|	S)	z3Given state, return /etc/sysconfig files + contentsr��loopbackr�rr�r�r�r�)r�rYr�rPr
r^rqr~r�r�r�r�rdr�r��zipr�r�)rryrZr�r�r[rr�r�contents�cpathr�s            r'�_render_sysconfigzRenderer._render_sysconfig�s���
��
�
�I�57��"�2�2�4�
	3�E��V�}�
�*���v��J�$�Z�1A�9�M�I�������x�(����v�&��$�$�U�I�v�>�)2�N�:�&�
	3�	�'�'�
�~�v�N��#�#�M�>�6�J��#�#�M�>�6�J��%�%�m�^�V�L��!�!�-���H���%3�%9�%9�%;�	L�!�J�	��I�.�.�+4�+>�+>�+@�����(�!*�!3�!3�I�I� �3<�3F�3F�3H�����0�I����$'��%�%�/�/��1A�1A�1K�1K�L��V�$�%�L�L�E�5��H�,�*3�*:�*:�*D�*D�U�*K����L�	L��r)rZ�returnc��|s|j}d}tj||j�}|j	|||j
|��j
�D]\}}tj|||��|jrLtj||j�}|j||��}	|	rtj||	|�|jrKtj||j�}
|j||�}|rtj|
||�|jrJ|j|�}tj||j�}
tj|
||d��tj||jd��}|j!d�r�tj"t$j&j)|��t+�dg}|j,r"|j/d	�|j/d
�tj|dj1|�dz|�yy)Ni�)r�)r�T)r��mode�
preserve_moder�r,zNETWORKING=yeszNETWORKING_IPV6=yeszIPV6_AUTOCONF=nor )r�r�target_pathr�r�r�r�r�
write_filer�r�r�r�r��_render_persistent_netrKr6�
ensure_dirr�r��dirnamer(�use_ipv6rPr#)rBrZr��target�	file_moderyr��datar��resolv_contentr��nm_conf_content�netrules_contentr��sysconfig_path�netcfgs                r'�render_network_statezRenderer.render_network_state�s�������I��	��+�+�F�D�4D�4D�E���0�0��m�T�[�[�I�1�
�
�%�'�	3�J�D�$�
�O�O�D�$�	�2�	3��=�=��'�'���
�
�>�H�!�-�-���.��N������.�)�D��(�(��+�+���5�5��L�#�>�>��y��O������o�y�I����#�:�:�=�I�� �,�,�V�T�5G�5G�H�M��O�O��(��"�	
��)�)�&�)�-�-�	�2J�K���"�"�9�-��O�O�B�G�G�O�O�N�;�<�"�n�&6�7�F��%�%��
�
�3�4��
�
�0�1��O�O���	�	�&� 1�D� 8�)�
�
.r)r>)NN)rhrirjrkrrrOrNr��dict�__annotations__rC�classmethodr
rBrIrVr^rqr~�staticmethodr�r�r�r�r�rrr�r-r)r'r�r�4s���A���"��	
�'�V�<��N�0��%�!'�#��

�'�0�!2�#��
��L�*�	
��M�(�I�t��3�&�0��0�2�E6��E6�N�;,��;,�z�@��@�4����(�<.��<.�|�$��$�L����0����&�:��:�x����$�@D�%��%�T%)��	2�#�2��D�>�2�

�2r)r�c	�`�dD�cgc]}|j|t|����� c}Scc}w)ziReturn list of supported names for vlan devices per RHEL doc
    11.5. Naming Scheme for VLAN Interfaces.)z{rdev}{vid:04}z{rdev}{vid}z{rdev}.{vid:04}z{rdev}.{vid})r|�vid)�format�int)r|r��vs   r'rzrzs5��

��
�	
���d��C���)����s�#+c�p�tj�dtvryt|�ryt	|�ryy)N�variantFT)r�system_info�
KNOWN_DISTROS�available_sysconfig�available_nm_ifcfg_rh�r�s r'�	availabler�"s4������)�$�M�9���6�"���V�$��r)c�T�tjtj|d��S)Nz;usr/lib*/NetworkManager/*/libnm-settings-plugin-ifcfg-rh.so)�globrr�r�s r'r�r�,s)���9�9�����I�	
��r)c���ddg}ddg}|D]}tj|||��r�yddg}|D]7}tjj	tj
||��s�7y	y)
N�ifup�ifdownz/sbinz	/usr/sbin)r4r�Fz/etc/sysconfig/network-scripts/network-functionszetc/sysconfig/configT)r�whichr�r�r�r�)r��expectedr4�p�expected_pathss     r'r�r�7s}����!�H��{�
#�F�
����z�z�!�F�6�:���
	:���N����
�7�7�>�>�$�*�*�6�1�5�6���r))�#r>)&r~r�rY�loggingr�r3�typingrr�	cloudinitrr�cloudinit.distros.parsersrr�
cloudinit.netr	r
rrr
�cloudinit.net.network_stater�	getLoggerrhr3r�r(r0r8r:rmr�r�rzr�r�r�r-r)r'�<module>r�s�����	��	�	�$� �F���5��g����!���
�$
�E�
�3#�3#�lk�I�k�\G�9�G�T]�x� � �]�@���r)

Zerion Mini Shell 1.0