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

�

�f�0���ddlZddlmZddlmZddlmZmZddlm	Z	ddl
mZeje
�ZGd�d�ZGd	�d
e	j �Zdd�Zy)
�N)�OrderedDict)�Optional)�subp�util)�renderer)�NetworkStatec�$�eZdZd�Zd�Zd�Zd�Zy)�	CfgParserc
�4�tggggggid��|_y)N)�Match�Link�Network�DHCPv4�DHCPv6�Address�Route)r�	conf_dict)�selfs �8/usr/lib/python3/dist-packages/cloudinit/net/networkd.py�__init__zCfgParser.__init__s(��$��������
�

���c�R�|jj�D]�}||k(s�	|j|j|dzt|�z�t	t
j
|j|��|j|<|j|j���y)N�=�r�keys�append�str�list�dict�fromkeys�sort)r�sec�key�val�ks     r�update_sectionzCfgParser.update_section s������$�$�&�	)�A��C�x����q�!�(�(��s��S��X�)=�>�$(����t�~�~�a�7H�)I�$J����q�!����q�!�&�&�(�	)rc��|jj�D]�}||k(s�	||j|vrg|j||<|j||j|dzt|�z�t	t
j
|j||��|j||<|j||j���y)z�
        For each route section we use rid as a key, this allows us to isolate
        this route from others on subsequent calls.
        rNr)rr"�ridr#r$r%s      r�update_route_sectionzCfgParser.update_route_section(s���
���$�$�&�		.�A��C�x��d�n�n�Q�/�/�-/�D�N�N�1�%�c�*����q�!�#�&�-�-�c�C�i�#�c�(�.B�C�)-��M�M�$�.�.��"3�C�"8�9�*����q�!�#�&����q�!�#�&�+�+�-�		.rc��d}t|jj��D]�\}}|s�	|dk(r)t|�D]}|d|zdzz
}||dzz
}|dz
}��7|dk(r<t|�D]-}|d|zdzz
}t||�D]}||dzz
}|dz
}��/�x|d|zdzz
}t|�D]
}||dzz
}�|dz
}��|S)N�r�[z]
�
r)�sortedr�items)r�contentsr%�v�e�ns      r�get_final_confzCfgParser.get_final_conf8s�����4�>�>�/�/�1�2�	!�D�A�q����I�~����%�A���a��%��/�H���D��(�H���$�H�%��g�����)�A���a��%��/�H�#�A�a�D�\�)�� �A��H�,�� �D�(��)�)��C�!�G�e�O�+�����)�A���D��(�H�)��D� ��%	!�(�rN)�__name__�
__module__�__qualname__rr&r)r4�rrr
r
s��
�)�.� rr
c��eZdZdZdd�Zdefd�Zdefd�Zdefd�Zdefd�Z	defd	�Z
ded
efd�Zdefd�Z
d
�Z		ddedeeddfd�Zd
edefd�Zy)�Rendererz�
    Renders network information in /etc/systemd/network

    This Renderer is currently experimental and doesn't support all the
    use cases supported by the other renderers yet.
    Nc�h�|si}|jdd�|_|jdd�|_y)N�resolve_conf_fnz/etc/systemd/resolved.conf�network_conf_dirz/etc/systemd/network/)�getr<r=)r�configs  rrzRenderer.__init__Ys:����F�%�z�z��;� 
���!'�
�
�� 7�!
��r�cfgc��d}dddd�}|sy|j�D]&\}}||vs�||s�|j||||��(|dS)Nr�Name�Driver�
MACAddress)�name�driver�mac_addressrE)r/r&)r�ifacer@r"�
match_dictr%r1s       r�generate_match_sectionzRenderer.generate_match_sectioncsj������'�
�
����$�$�&�	5�D�A�q��E�z�e�A�h��"�"�3��5��8�4�	5��V�}�rc�P�d}|syd|vr|dr|j|d|d�yyy)Nr
�mtu�MTUBytes)r&)rrHr@r"s    r�generate_link_sectionzRenderer.generate_link_sectionts7�������E�>�e�E�l����s�J��e��=�+�>rc��d}dddd�}d}d|vrdt|d�z}|j�D]+\}}||vr�|d	k(r||z
}|j|||||��-y
)zy
        Parse a route and use rid as a key in order to isolate the route from
        others in the route dict.
        r�Gateway�Destination�Metric)�gateway�network�metricr+�prefix�/rTN)rr/r))	rr(�confr@r"�
route_cfg_maprVr%r1s	         r�parse_routeszRenderer.parse_routes}s���
�� �$��
�
����t���3�t�H�~�.�.�F��J�J�L�	D�D�A�q��
�%���I�~��V����$�$�S�#�}�Q�/?��C�	Drc	��d}d}d}|jdg�D�]}|d}|dk(s|dk(r|dk(rd}n|d	k(rd
}n|dk(r|dk(rd	}n|dk(rd
}d|vr*|dr%|dD]}|jd
|��||�|dz}�d|vs�jddddd�}	|j�D]�\}
}|
dk(r/d|vr|dt|d�zz
}|j	d|	|
|��:|
dk(r |jdd|��|	|
|�|dz}�_|
dk(s|
dk(s�j|j	||	|
dj
|������|j	|d|�|dvr6t|jdd �t�r|j	|d!|d�|S)"N�norr�subnets�type�dhcp4�dhcp�ipv4�ipv6�yes�dhcp6�routes�r��addressrrP�DNS�Domains)rhrS�dns_nameservers�
dns_searchrVrWrSr�arkrl� �DHCP)rbrcz	accept-rar+�IPv6AcceptRA)	r>rZr/rr&r)�join�
isinstance�bool)rrHr@r`r"r(r2�t�i�subnet_cfg_mapr%r1s            r�
parse_subnetszRenderer.parse_subnets�s������������9�b�)�&	P�A��&�	�A��G�|�q�F�{��4�<�!�D��V�^� �D��g���4�<�!�D��V�^� �D��1�}��8���8��"�A��%�%��#��i��C�8���'�C�	"�
�A�~�(�(�',�"+�	"���G�G�I�
P�D�A�q��I�~�#�q�=���s�1�X�;�'7�!7�7�A��*�*�9�n�Q�6G��K��i���0�0�#�q���Y��q�0A�1��"�A�g���/�/�1��3D��*�*�3��q�0A�3�8�8�A�;�O�
P�3&	P�P	���3���-��?�"�z��I�I�k�2�&��(
�
���s�N�E�+�4F�G��rc��dD]\}||vr�t||�j�}	tj|�}|rdnd}|dk(rd}nd}|j|d	|��^y#t$r |dk7rt
j
d|�d}Y�HwxYw)
N)�dhcp4domain�dhcp6domainrcr\�routezInvalid dhcp4domain value - %sryrr�
UseDomains)r�casefoldr�translate_bool�
ValueError�LOG�warningr&)r�dr@�item�ret�sections      r�dhcp_domainzRenderer.dhcp_domain�s���2�	;�D��1�}���a��g�,�'�'�)�C�
��)�)�#�.��"�e���
�}�$�"��"�����w��c�:�	;���
��'�>��K�K� @�#�F��C��
�s�A#�#&B�B�nsc�~�d}|jd�}|s)|jdk(r|j|jd�}n|s|jdk(ry|jd�r%|j	|ddj|d��|jd	�r&|j	|d
dj|d	��yy)Nr�dnsrg)�search�nameservers�r�rjrnr�ri)r>�version�dns_searchdomainsrkr&rq)rrHr@r�r"r�s      r�	parse_dnszRenderer.parse_dns�s������i�i�����r�z�z�Q���.�.�!�1�1��C�����q����7�7�8�����s�I�s�x�x��H�
�/F�G��7�7�=�!����s�E�3�8�8�C�
�4F�+G�H�"rc���ddddd�}|dk(r|jddd	d
dd��d
|�d�|vrJ|dd|��fvr@|d
|�d�}|j�D]#\}}||vs�|jd|��|||��%yyy)Nzuse-dns�use-domainszuse-hostnamezuse-ntp)�UseDNSr|�UseHostname�UseNTP�4z
send-hostname�hostnamezroute-metriczuse-mtuz
use-routes)�SendHostname�Hostname�RouteMetric�UseMTU�	UseRoutesr`�
-overridesrc�ipv�DHCPv)�updater/r&)	rr@�devicer`r��dhcp_config_maps�dhcp_overridesr%r1s	         r�parse_dhcp_overrideszRenderer.parse_dhcp_overrides�s����'�)��	
���c�>��#�#�$3� *�#1�'�!-��
��'��*�%��/�D���'��O�=
�5
�$�d�7�)�:�$>�?�N�(�.�.�0�
P���1���&��&�&��w�i�'8�!�^�A�=N�O�
P�5
�/rc��d}tjd|�|dz|zdz}tj||�tj|||�y)Nzsystemd-networkz Setting Networking Config for %sz10-cloud-init-z.network)r��debugr�
write_file�chownbyname)r�linkrX�nwk_dir�net_fn_owner�net_fns      r�create_network_filezRenderer.create_network_file
sK��(���	�	�4�d�;��+�+�d�2�Z�?�������%������|�<r�
network_state�	templates�returnc���|j}|rtj|�|z}tj|�|j|�}|j
�D]\}}|j|||��y�N)r=r�target_pathr�
ensure_dir�_render_contentr/r�)rr�r��target�network_dir�ret_dictr%r1s        r�render_network_statezRenderer.render_network_stateso���+�+����*�*�6�2�[�@�K�����$��'�'�
�6���N�N�$�	8�D�A�q��$�$�Q��;�7�	8rc�<�i}|j�D�]�}t�}|j||�}|j||�|j	||�}|j|||�d}|j
�D]}|jd|��||�|dz}�|jdk(r�|d}	|jdj�D]"\}
}d|vs�|jd�|	k(s� |
}	n|	|jdvru|jd|	}|j||�dD]L}
d	|
�d
�|vr.d|jd	|
�d�i�vr|	�d
|
�d|
�d�}t|��|j||||
��N|j||j!�i����|S)Nr�crgr�rE�	ethernetszset-name)r��6r`�domainr�r�z has both dhcpzdomain and dhcpz*-overrides.use-domains configured. Use one)�iter_interfacesr
rJrNrwr��iter_routesrZr�r?r/r>r��RuntimeErrorr�r�r4)rr�r�rHr@r�r`r(r{rE�dev_name�dev_cfgr�r��	exceptions               rr�zRenderer._render_content#s������'�'�)�4	:�E��+�C��.�.�u�c�:�D��&�&�u�c�2��%�%�e�S�1�D��N�N�5�#�r�*��C����)�
���!�!�A�c�U�)�U�C�8��A�g��	
��z�z�Q��&+�F�m��*,���;�)?�)E�)E�)G�"�%�H�g�!�W�,�"�;�;�z�2�d�:�#+�D�!�	"�
�2�9�9�[�1�1��Y�Y�{�3�D�9�F��$�$�V�S�1�#-�
N��"�7�)�6�2�f�<� -�%�z�z�D��	��*D�b�I�!J�$(�&��w�i�@,�,3�9�57�!8�&�
#/�y�"9�9��1�1�#�v�t�W�M�
N�
�O�O�T�3�#5�#5�#7�8�9�i4	:�l�rr�)NN)r5r6r7�__doc__rr
rJrNrZrwr�rr�r�r�rrr�r�r8rrr:r:Qs����
����">�	�>�D�9�D�03�	�3�l;�)�;�$I�I�I�<�I�"P�	�P�8=�%)��	8�#�8��D�>�8�

�8� 8�,�8�4�8rr:c�V�ddg}ddg}|D]}tj|||��r�yy)N�ip�	systemctlz	/usr/sbinz/bin)r�r�FT)r�which)r��expectedr��ps    r�	availabler�^s=���k�"�H��6�
"�F�
����z�z�!�F�6�:���rr�)�logging�collectionsr�typingr�	cloudinitrr�
cloudinit.netr�cloudinit.net.network_stater�	getLoggerr5r�r
r:r�r8rr�<module>r�sP���#�� �"�4��g����!��<�<�~J�x� � �J�Zr

Zerion Mini Shell 1.0