__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

���gˉ���SSKJr SSKrSSKrSSKJrJr SSKJr SSK	J
r
 SSKJrJ
r
Jr SSKJrJr "SS	\R$5r"S
S5rg)�)�defaultdictN)�AF_INET�AF_INET6)�AbstractSet)�NetplanRoute)�SystemConfigState�NetplanConfigState�DEVICE_TYPES)�is_valid_macaddress�route_table_lookupc��\rSrSrSrSrg)�DiffJSONEncoder�c��[U[5(aUR5$[RRX5$�N)�
isinstancer�to_dict�json�JSONEncoder�default)�self�objs  �0/usr/share/netplan/netplan_cli/cli/state_diff.pyr�DiffJSONEncoder.defaults4���c�<�(�(��;�;�=� ����'�'��2�2��N)�__name__�
__module__�__qualname__�__firstlineno__r�__static_attributes__rrrrrs��3rrc���\rSrSrSrS\S\4SjrS\4Sjr	S-S\
S\4S	jjrS\4S
jrS\
S\
S\
S\4S
jrS\S\SS4SjrS\S\4SjrS\S\4SjrS\
S\
4SjrS\S\SS4SjrS\S\SS4SjrS\S\SS4SjrS\S\SS4SjrS\S\
SS4SjrS\S\SS4SjrS\S\4S jrS\S\\4S!jrS"\\S#\\
S\S\4S$jrS\4S%jr S\SS4S&jr!S\4S'jr"S(\S\4S)jr#S*\
S\
4S+jr$S,r%g).�NetplanDiffState�&z�
DiffState is mainly responsible for getting both system's and Netplan's configuration
state, compare them and provide a data-structure containing the differences it found.
�system_state�
netplan_statec�*�XlX l0Ulgr)r%r&�route_lookup_table_names)rr%r&s   r�__init__�NetplanDiffState.__init__,s��(��*��(*��%r�returnc� �S00nUR5nUR5n[[UR	55[UR	55-5nUHn0USU'M
 UR5HupVUSUR
U5 M UR5HupVUSUR
U5 M URRH"nURUSURS'M$ U$)zs
Return the states of both the system and Netplan in a common representation
that makes it easier to compare them.
�
interfaces�data_sources)�_get_system_interfaces�_get_netplan_interfaces�set�list�keys�items�updater%�interface_listr.�name)r�
full_state�system_interfaces�netplan_interfaces�all_interfaces�	interface�configs       r�get_full_state�NetplanDiffState.get_full_state2s��
�"�
�
�!�7�7�9��!�9�9�;���T�"3�"8�"8�":�;�d�CU�CZ�CZ�C\�>]�]�^��'�I�24�J�|�$�Y�/�(�"3�!8�!8�!:��I��|�$�Y�/�6�6�v�>�";�"4�!9�!9�!;��I��|�$�Y�/�6�6�v�>�"<��*�*�9�9�I�GP�G]�G]�J�|�$�Y�^�^�4�^�D�:��rr<c��UR5nURURS055nU(aURU5=n(aX0nO0nUR5nUR	XQ5 UR5H�upURS05RS5nURS05RS5nUR
XaU5nURXH5 URXH5 URXH5 URXH5 URXH5 URXH5 USRU5 M� [[USR5SS95US'U$)aV
Compare the configuration of interfaces currently found in the system against Netplan configuration.
A number of heuristics are used to eliminate configuration that is automatically set in the system,
such as certain routes and IP addresses. That is necessary because this configuration will not be found
in Netplan. For example, if Netplan is enabling DHCP on an interface and not defining any extra IP addresses,
we don't count the IPs automatically assigned to the interface as a difference. We do though count the eventual
absence of addresses that should be assigned by DHCP as a difference.
r-r%�id�indexc�*�USRS5$)N�rB)�get)�ifaces r�<lambda>�+NetplanDiffState.get_diff.<locals>.<lambda>us��[`�ab�[c�[g�[g�ho�[pr��key)r>�_get_comparable_interfacesrE�_create_new_report�_analyze_missing_interfacesr4�_create_new_iface�_analyze_ip_addresses�_analyze_nameservers�_analyze_search_domains�_analyze_mac_addresses�_analyze_routes�_analyze_parent_linksr5�dict�sorted)	rr<r8r-r=�report�	netdef_idrBrFs	         r�get_diff�NetplanDiffState.get_diffOs_���(�(�*�
��4�4�Z�^�^�L�RT�5U�V�
��#���	�2�2�v�2�'�0�
��
��(�(�*���(�(��;�!+�!1�!1�!3��I��
�
�>�2�6�:�:�4�@�I��J�J�~�r�2�6�6�w�?�E��*�*�9��G�E��&�&�v�5��%�%�f�4��(�(��7��'�'��6�� � ��/��&�&�v�5��<� �'�'��.�"4� $�F�6�,�+?�+E�+E�+G�Mp�$q�r��|���
rc��000S.$)N)r-�missing_interfaces_system�missing_interfaces_netplanr)rs rrL�#NetplanDiffState._create_new_reportxs���)+�*,�
�	
rrXrBc��UUUU00S.0$)N)rBr7rAr%r&r)rrXr<rBs    rrN�"NetplanDiffState._create_new_ifaces#����!�� "�!#��
�	
rr=rFNc��[UR55SnURS05RS/5Vs1sHoDiM nnURU5nURS05RSS5nURS05RSS5nURS05RS/5n[	5n	URS05RS05R5GH�up�[R"U
5nURS	/5n1S
kRU5(dU	RU
5 SU;a�UR(a�[UR[R5(aSU;aU	RU
5 [UR[R5(aS
U;aU	RU
5 [UR[R5(aSS1RU5(aSn[UR[R5(aSU;aSnURS05RS5n
SU;dGM�U
SLdGM�U	RU
5 GM� URU	5nU	RU5nU(a
SX#SS'U(a
SX#SS'U(a*X#SR!S[[#U5505 U(a+X#SR!S[[#U5505 ggs snf)Nrr&�	addresses�dhcp4F�dhcp6�
link_localr%�flags>�ra�dhcp�link�dynamicri�ipv4�ipv6rhrj�	accept_rargT�missing_dhcp4_address�missing_dhcp6_address�missing_addresses)r2r3rE�_normalize_ip_addressesr1r4�	ipaddress�ip_interface�intersection�add�
is_link_localr�ip�IPv4Address�IPv6Address�
differencer5rV)rr=rFr7rw�netplan_ipsrnrore�
system_ips�addr�	addr_datarfrm�present_only_in_netplan�present_only_in_systems                rrO�&NetplanDiffState._analyze_ip_addresses�s����E�J�J�L�!�!�$��$*�J�J���$C�$G�$G��UW�$X�Y�$X�b�r�$X��Y��2�2�;�?�� &�
�
�?�B� ?� C� C�G�U� S�� &�
�
�?�B� ?� C� C�G�U� S���Z�Z���4�8�8��r�J�
��U�
�%�z�z�.�"�=�A�A�+�r�R�X�X�Z�O�D��'�'��-�B��M�M�'�2�.�E�5�A�A�%�H�H����t�$�
���2�#3�#3��b�e�e�Y�%:�%:�;�;��j�@X��N�N�4�(��b�e�e�Y�%:�%:�;�;��j�@X��N�N�4�(��"�%�%��!6�!6�7�7��I�&�3�3�E�:�:�,1�)��"�%�%��!6�!6�7�7��U�?�,1�)��
�
�?�B�7�;�;�K�H�I��u�}��e�!3����t�$�E [�H#.�"8�"8��"D��!+�!6�!6�{�!C�� �CG�E�K��'�(?�@� �CG�E�K��'�(?�@�!��K��(�/�/�#�T�&�1G�*H�%I�1�
�#��K��'�.�.�#�T�&�1H�*I�%J�0�
�#��sZs�Mr-c���0nUR5HWup4URS5bURS5cM+URS05RS5(dMSXBU'MY U$)a�In order to compare interfaces, they must exist in the system AND in Netplan.
Here we filter out interfaces that don't have a system_state, a netplan_state
or a netdef ID.

There is a special case where the interface will have a system_state and a netdef_id
but will be missing in Netplan. That will happen when the user removes the interface
only from Netplan but doesn't run netplan apply.
r%r&rA)r4rE)rr-�filteredr<r=s     rrK�+NetplanDiffState._get_comparable_interfaces�sm����!+�!1�!1�!3��I��z�z�.�)�1�V�Z�Z��5P�5X���:�:�n�b�1�5�5�d�;�;��"(�Y��"4��rrbc�p�[5nUH%nURU5nURU5 M' U$)z\Apply some transformations to IP addresses so their representation
will match the system's.
)r1�_compress_ipv6_addressru)rrb�new_ips_setrws    rrq�(NetplanDiffState._normalize_ip_addresses�s9���e���B��,�,�R�0�B��O�O�B����r�addressc��[R"U5nSU;aUR$[UR5$![
a Us$f=f)z�
Compress IPv6 addresses to match the system representation
Example: 1:2:0:0::123/64 -> 1:2::123/64
         1:2:0:0::123 -> 1:2::123
If "address" is not an IPv6Address, return the original value
�/)rrrs�with_prefixlen�strrw�
ValueError)rr�r}s   rr��'NetplanDiffState._compress_ipv6_address�sL��	��)�)�'�2�D��g�~��*�*�*��t�w�w�<����	��N�	�s�'?�?�A�
Ac�4�[UR55SnURS05RS05n[URS05RS/55n[URS05RS/55nUVs1sHotUS:XdM
UiM nnUVs1sHotUS:XdM
UiM n	nUVs1sHotUS	:XdM
UiM n
nURS05RS
5SLnSURS05RS
/5;nU(dU	(dU
(aaURS05RS5(aXh-
nU(aXi-
nUVs1sHowU
;dM
UiM n
nU(aU(aXm-
nO�U(d�URS05RS5(aGUVs1sH:n[	[
R"U5[
R5(aM8UiM< nnURS05RS5(aGUVs1sH:n[	[
R"U5[
R5(aM8UiM< nnURU5nURU5nU(a!X#SRS[U505 U(a"X#SRS[U505 ggs snfs snfs snfs snfs snfs snf)Nrr.�dnsr&�nameservers_addressesr%�DHCPv4�DHCPv6�NDiscrmFrlrercrd�missing_nameservers_addresses)r2r3rEr1rrr�
ip_addressrxryrzr5)rr=rFr7r.�netplan_nameservers�system_nameservers�ns�dhcp4_ns�dhcp6_ns�ndisc_ns�accept_ra_enabled�link_local_enabled�
link_local_nsrr�s                rrP�%NetplanDiffState._analyze_nameservers�s����E�J�J�L�!�!�$���z�z�.�"�5�9�9�%��D��
"�&�*�*�_�b�"A�"E�"E�F]�_a�"b�c�� ����N�B�!?�!C�!C�D[�]_�!`�a��!-�N��2�b�1A�X�1M�B���N�!-�N��2�b�1A�X�1M�B���N�!-�M��2�b�1A�W�1L�B���M�#�J�J���;�?�?��L�TY�Y��#�v�z�z�/�2�'F�'J�'J�<�Y[�'\�\���x�8��z�z�/�2�.�2�2�7�;�;�%7�%B�"�!�%7�%B�"�*<�O�*<�B�h��R�*<�M�O�!�&7�%7�%G�"��'��:�:�o�r�2�6�6�w�?�?�7I�*n�7I��1;�I�<P�<P�QS�<T�V_�Vk�Vk�1l�+-�7I�&�*n��:�:�o�r�2�6�6�w�?�?�7I�*n�7I��1;�I�<P�<P�QS�<T�V_�Vk�Vk�1l�+-�7I�&�*n�#6�"@�"@�AS�"T��!3�!>�!>�?R�!S��!��K��(�/�/�/��6L�1M�1�
�#��K��'�.�.�/��6M�1N�0�
�#��]O��N��M��P��*n��*nsH�K<�)K<�5L�L�L�!L�?	L�L�7L�L�7L�Lc��[UR55Sn[URS05RS/55n[URS05RS/55nURS05RS05nUVs1sHovUS:XdM
UiM nnUVs1sHovUS:XdM
UiM n	nU(dU	(aYURS05RS	5(aXX-
nURS05RS
5SLn
U
(aXY-
nO]U(dVURS05RS	5(d&URS05RS5(a
[5nUR	U5nUR	U5nU(a!X#SRS
[U505 U(a"X#SRS
[U505 ggs snfs snf)Nrr&�nameservers_searchr%r.�searchr�r�rcrmFrd�missing_nameservers_search)r2r3r1rErzr5)
rr=rFr7�netplan_search_domains�system_search_domainsr.�s�dhcp4_search�dhcp6_searchr�rr�s
             rrQ�(NetplanDiffState._analyze_search_domains7s����E�J�J�L�!�!�$��!$�V�Z�Z���%D�%H�%H�I]�_a�%b�!c�� #�F�J�J�~�r�$B�$F�$F�G[�]_�$`� a���z�z�.�"�5�9�9�(�B�G��#/�O�<�a��?�h�3N��<��O�#/�O�<�a��?�h�3N��<��O��<��z�z�/�2�.�2�2�7�;�;�(=�(L�%�!'�
�
�?�B� ?� C� C�K� P�X]� ]�� �(=�(L�%��*��:�:�o�r�2�6�6�w�?�?�6�:�:�o�_a�Cb�Cf�Cf�gn�Co�Co�,/�E�)�"8�"C�"C�DY�"Z��!6�!A�!A�BX�!Y��!��K��(�/�/�,�d�3I�.J�1�
�#��K��'�.�.�,�d�3J�.K�0�
�#��;P��Os�H�)H�5H
�H
c�|�[UR55SnURS05RS5nURS05RS5nU(a[U5(dgU(a?U(a7XE:wa1X#SR	SU05 X#SR	SU05 gggg)Nrr%�
macaddressr&�missing_macaddress)r2r3rErr5)rr=rFr7�system_macaddress�netplan_macaddresss      rrR�'NetplanDiffState._analyze_mac_addresses^s����E�J�J�L�!�!�$��"�J�J�~�r�:�>�>�|�L��#�Z�Z���<�@�@��N���&9�:L�&M�&M���!3� �6���N�+�2�2�(�*<�4����O�,�3�3�(�*;�5��	7�"4�rc�F�[UR55Sn[URS05RS/55n[URS05RS/55nUR	U5nURURS055=n(aUR
U5 URS05RS05Vs/sHowPM nnURXXU5nURU5n	URU5n
U
(a1X#SR
S[U
SS9Vs/sHo�PM sn05 U	(a2X#SR
S[U	S	S9Vs/sHo�PM sn05 ggs snfs snfs snf)
Nrr&�routesr%rb�missing_routesc��UR$r��to��rs rrG�2NetplanDiffState._analyze_routes.<locals>.<lambda>�s��cd�cg�cgrrIc��UR$rr�r�s rrGr��s��de�dh�dhr)
r2r3r1rE�_normalize_routes�_normalize_gatewaysr5�_filter_system_routesrzrV)rr=rFr7�netplan_routes�
system_routes�netplan_gatewaysrw�system_addressesrr��routes            rrS� NetplanDiffState._analyze_routesqs����E�J�J�L�!�!�$���V�Z�Z���<�@�@��2�N�O���F�J�J�~�r�:�>�>�x��L�M�
��/�/��?�� $�7�7��
�
�?�TV�8W�X�X��X��!�!�"2�3�*0���N�B�)G�)K�)K�K�Y[�)\�]�)\�2�B�)\��]��2�2�=�TZ�[�
�"0�";�";�M�"J��!.�!9�!9�.�!I��!��K��(�/�/� �f�=S�Yg�6h�"i�6h�U�5�6h�"i�1�
�#��K��'�.�.� �f�=T�Zh�6i�"j�6i�U�5�6i�"j�0�
�#��^��#j��
#ks�!F�F
�?F
rWc��^^�TRRVs1sHo3iM nnTRRVs1sH!o3R(dMURiM# nnURU5n[
[U4SjU55n/nTRRH0nURU;dMURUR5 M2 [U5n[U5nT(a [U4SjU5n[U4SjU5nTRR5nUHQnTRRRU5Rn	S[R"U	S50USU'MS UHKnURU5RSS5URU5RS5S.US	U'MM gs snfs snf)
Nc�h>�TRRRU5RS:g$)N�wifis)r&�netdefsrE�type)�irs �rrG�>NetplanDiffState._analyze_missing_interfaces.<locals>.<lambda>�s(���T�-?�-?�-G�-G�-K�-K�A�-N�-S�-S�W^�-^rc�>�UT:H$rr�r�r<s �rrGr��s	���A��Nrc�>�UT:H$rrr�s �rrGr��s	���1�	�>rr��otherr\rB)r�rBr])r&r�r%r6rXrzr2�filter�appendr7rV�get_datarEr�r
)
rrWr<rFr:�system_interfaces_netdef_ids�netplan_only�system_onlyr%�
iface_types
` `       rrM�,NetplanDiffState._analyze_missing_interfaces�s����15�1C�1C�1K�1K�L�1K��e�1K��L�EI�EV�EV�Ee�Ee�'y�Ee�E�ix�ix�����Ee�$�'y�)�4�4�5Q�R���F�#^�`l�m�n�����&�&�5�5�E����&8�8��"�"�5�:�:�.�6��l�+���[�)���!�":�L�I�L� �!9�;�G�K��(�(�1�1�3��!�E��+�+�3�3�7�7��>�C�C�J���(�(��W�=�:�F�.�/��6�"�!�E�$�(�(��/�3�3�F�G�D�%�)�)�%�0�4�4�W�=�;�F�/�0��7�!��9M��'ys�G �G%�G%c��[UR55SnURS05RS5URS05RS5/nURS05RS5URS05RS5/nURS05RS5URS05RS5/nURS05RS/5URS05RS/5/nUSS/:wa:USUS	:wa.US(a
USX#SS
'US	(a
US	X#SS
'USS/:wa:USUS	:wa.US(a
USX#SS'US	(a
US	X#SS'USS/:wa:USUS	:wa.US(a
USX#SS'US	(a
US	X#SS'U///:wa`[US5n[US	5n	X�:wa>X�-
=n
(a[U
5X#SS
'X�-
=n(a[U5X#SS
'gggg)zo
Analyse if interfaces such as bonds, bridges and VRFs are correctly attached to their
members and vice versa.
rr%�bondr&�bridge�vrfr-NrD�missing_bond_link�missing_bridge_link�missing_vrf_link�missing_interfaces)r2r3rEr1)rr=rFr7r�r�r�r-�system�netplan�missing_system�missing_netplans            rrT�&NetplanDiffState._analyze_parent_links�s���
�E�J�J�L�!�!�$���
�
�>�2�.�2�2�6�:�F�J�J��XZ�<[�<_�<_�`f�<g�h���*�*�^�R�0�4�4�X�>��
�
�?�\^�@_�@c�@c�dl�@m�n���z�z�.�"�-�1�1�%�8�&�*�*�_�VX�:Y�:]�:]�^c�:d�e���j�j���4�8�8��r�J�F�J�J�Wf�hj�Lk�Lo�Lo�p|�A�MB�C�
��D�$�<��D��G�t�A�w�$6��A�w�DH��G���O�,�-@�A��A�w�CG��7���N�+�,?�@��d�D�\�!�f�Q�i�6�!�9�&<��a�y�FL�Q�i���O�,�-B�C��a�y�EK�A�Y���N�+�,A�B��4��,��3�q�6�S��V�#3��1�v�CF�q�6���O�,�-?�@��1�v�BE�a�&���N�+�,>�?��"�b��!���A��'�F��*�Q�-�(�G�� �%,�%5�5�>�5�HL�^�H\�E�K��/�0D�E�&,�&6�6�?�6�IM�o�I^�E�K��0�1E�F�7�	!�	"rr�c��[5nUH�nUR[R:XaUR	S5UlURUR5UlURUR5UlURUR5UlURS:wa7URRS5nUSS:Xd	USS:Xa
USUlURU5 M� U$)z^Apply some transformations to Netplan routes so their representation
will match the system's.
�mainrr�rD�32�128r)r1�tabler�_TABLE_UNSPEC_�$_default_route_tables_name_to_numberr�r��	from_addr�via�splitru)rr��new_routes_setr��	ip_prefixs     rr��"NetplanDiffState._normalize_routes�s�������E��{�{�l�9�9�9�"�G�G��O����2�2�5�8�8�<�E�H�"�9�9�%�/�/�J�E�O��3�3�E�I�I�>�E�I��x�x�9�$�!�H�H�N�N�3�/�	��Q�<�4�'�9�Q�<�5�+@�(��|�E�H����u�%�#�&�rc��[5nURR5nURS5nUR	5Vs/sHnURS5U:XdMUPM nnUVVs/sHoURS/5HowPM M nnnURS5=n	(a�UVs/sHXnURS5S:XdMURS5[
R:XdM?URS5S:XdMVUPMZ n
n[SU	[
RSS	9n[U
5S
:XaRU
SRS5=n(aX�l	U
SRS
5=n(aURU5UlURU5 URS5=n
(GaUVs/sHXnURS5S:XdMURS5[R:XdM?URS5S:XdMVUPMZ n
nURU
5n
[SU
[RSS	9n[U
5S
:XaRU
SRS5=n(aX�l	U
SRS
5=n(aURU5UlURU5 U$s snfs snnfs snfs snf)afConvert the gateway4 and gateway6 properties to NetplanRoutes.
The only information stored by these properties is the destination IP for
the default route. Networkd and Network Manager will set a default metric
for it when the route is installed. As we have no control over it, there
will always be a diff. The same is true for the route table number.
To avoid the noise in the diff report when these properties are used,
we use the following heuristic: if there is one and only one static default
route in the system and gateway4 and/or gateway6 are used, we set the same
metric and table as found in the system.
rAr��gateway4r�r�family�protocol�static)r�r�r�r�rDr�metricr��gateway6)r1r%r�rE�valuesr�valuer�lenr�r�r�rurr�)rr=�
routes_setr9r<rF�ifacesr�r�r��default_routesr�r�r�s              rr��$NetplanDiffState._normalize_gateways�s����U�
� �-�-�6�6�8���J�J�t�$�	�%6�%=�%=�%?�3�%?�E��Y�Y�t�_�	�1��%?��3�%+�Q�V�E���8�R�9P��%�9P�%�V��Q��z�z�*�-�-�8�-�17�E���!&���4��I�!=�$�"'�)�)�H�"5����"F�$�#(�)�)�J�"7�8�"C�$��N�E�
!�I�8�G�M�M�\d�e�E��>�"�a�'�+�A�.�2�2�8�<�<�6�<�#)�L�*�1�-�1�1�'�:�:�5�:�"&�"K�"K�E�"R�E�K��N�N�5�!��z�z�*�-�-�8�-�17�E���!&���4��I�!=�$�"'�)�)�H�"5����"G�$�#(�)�)�J�"7�8�"C�$��N�E��2�2�8�<�H� �I�8�H�N�N�]e�f�E��>�"�a�'�+�A�.�2�2�8�<�<�6�<�#)�L�*�1�-�1�1�'�:�:�5�:�"&�"K�"K�E�"R�E�K��N�N�5�!����O3��Q��E�� EsB�J?�%J?�2$K�5K
�!K
�7K
�K
�?K�!K�K�Kr�r�c��UVs/sH,n[[R"U5R5PM. nn[	[SU55nUVs/sH,n[[R"U5R5PM. nnURS05RS/5n[5nUGH3n	U	RS:XaAU	RS:wa1[R"U	R5R(dMUU	RS:XaMgURS05RS5n
U	RS:XaU
S	LaM�U	RS:wa[R"U	R5nUR(aNU	R[R:Xa	S
U;aGMU	R[ R:Xa	SU;aGM.U	RS:XaRU	R"S
:XaBU	RU;d/[R"U	R5R$(aGM�U	R[R:Xa#U	R"S:XaU	RS:XaGM�U	R[R:Xa3U	RS:wa#U	RU;dU	RU;aGM"UR'U	5 GM6 U$s snfs snf)ac
Some routes found in the system are installed automatically/dynamically without
being configured in Netplan.
Here we implement some heuristics to remove these routes from the list we want
to compare. We do that because these type of routes will probably never be found in the
Netplan configuration so there is no point in comparing them against Netplan.
c��US:g$)Nz	fe80::/64r)�ns rrG�8NetplanDiffState._filter_system_routes.<locals>.<lambda>4s	��q�K�/?rr&rerirrhrmrgFrlrk�host�local�	multicastzff00::/8)r�rrrs�networkr2r�rwrEr1�scoper�rvr�r�rr�rr��is_loopbackru)rr�r�r=rw�local_networksrbrer�r�rm�route_tos            rr��&NetplanDiffState._filter_system_routes)s<��M]�]�L\�b�#�i�4�4�R�8�@�@�A�L\��]��f�%?��P�Q��BR�S�BR�B�S��/�/��3�6�6�7�BR�	�S��Z�Z���4�8�8��r�J�
����"�E��{�{�f�$����Y�)>�y�G]�G]�^c�^f�^f�Gg�Gu�Gu���~�~��'���
�
�?�B�7�;�;�K�H�I��~�~��%�)�5�*@���x�x�9�$�$�1�1�%�(�(�;���)�)��|�|�x�~�~�5�&�J�:N� ��|�|�w�}�}�4��:�9M� ����v�%�%�*�*��*?��X�X��*�i�.D�.D�U�X�X�.N�.Z�.Z���|�|�x�~�~�-�%�*�*��2K�PU�PX�PX�\f�Pf��������.�5�>�>�T�3I����^�3�u�x�x�9�7L���J�J�u��M#�N�
��[^��Ts�3K1�3K6c�4�URR5n0nURRR	5GH�up40nSSU00XS'XSSn[
R"URS5US'URUS'URUS'URUS'URbURUS'URVs/sHowPM nnU(ac0US	'UHXn0n	UR(aURU	S
'UR(aURU	S'SU	0US	[U5'MZ [!UR"5=n
(aX�S
'[!UR$5=n(aX�S'[!UR&5=n(aX�S'UR(=n
(aX�S'UR*=n(aX�S'UR,=n(aX�S'UR.R
S5=n(aUR0US'UR.R
S5=n(aUR0US'UR.R
S5=n(aUR0US'X1;aeSnUR	5H1unnUR
S5=n(dM UU:XdM(SnXSUU'M3 U(dUR3U5 GM�GM�UR3U5 GM� UR5U5 U$s snf)Nr&rAr�r�rcrdrermrb�label�lifetimerfr�r�r�r�r�r�r�r�r�FT)r%r�r&r�r4r
rEr�rcrdrermrbrrr�r2�nameserver_addresses�nameserver_searchr��	_gateway4�	_gateway6r��linksrAr5�_netplan_state_find_parents)rr9r-r<r=rF�	iface_refr}rbrf�nameserversr�r�r�r��macr�r�r��
found_somerJr�rXs                       rr0�(NetplanDiffState._get_netplan_interfacesas��� �-�-�6�6�8���
�!%�!3�!3�!;�!;�!A�!A�!C��I��E� /�$�	�1B�C�E���(��9�I� ,� 0� 0����g� F�I�f��!'���I�g��!'���I�g��&,�&7�&7�I�l�#����+�)/�)9�)9�	�+�&�*0�*:�*:�;�*:�$��*:�I�;��)+�	�+�&�%�D��E��z�z�)-����g���}�}�,0�M�M��j�)�9@�%�8H�I�k�*�3�t�9�5�
&�#�6�#>�#>�?�?�{�?�5@�1�2��f�6�6�7�7�v�7�28�.�/��f�m�m�,�,�v�,�&,�(�#�!�+�+�+�x�+�(0�*�%�!�+�+�+�x�+�(0�*�%��'�'�'�s�'�*-�,�'����)�)�(�3�3�v�3�&,�i�i�	�(�#��|�|�'�'��/�/�t�/�$(�G�G�	�&�!��l�l�&�&�u�-�-�s�-�#&�6�6�	�%� ��1�#�
�"3�"9�"9�";�J�C��$)�I�I�d�O�3�y�3�$�	�1�)-�J�.3�.>�J�s�O�	#<�"��%�%�e�,�"��!�!�%�(�U"D�X	
�(�(��4����{<s�Lc���[[5nUR5H�up4USRS5=n(aX%R	U5 USRS5=n(aX%R	U5 USRS5=n(dM~X%R	U5 M� UR5Hup6[U5XSS'M g)z)Associates interfaces with their parents r&r�r�r�r-N)rr1r4rErur2)rr-�parentsr<r=ri�memberss       rr�,NetplanDiffState._netplan_state_find_parents�s����c�"��!+�!1�!1�!3��I��o�.�2�2�8�<�<�t�<��
�!�!�)�,��o�.�2�2�6�:�:�t�:��
�!�!�)�,��o�.�2�2�5�9�9�t�9��
�!�!�)�,�
"4�#*�-�-�/��I�CG��=�J�!�/�2�<�@�#2rc�t�0nURR5R5GHup#US:XaMURS5nSSU00X'URS5=n(a
XQUSS'XSnURS5=n(aXvS'0nURS/5Hkn	[	U	R55Sn
U	RU
5RS5nU
S	U3nS
U	RU
5RS
/50X�'Mm U(aX�S'URS5=n
(aX�S'URS
5=n(aX�S'URS5=n(a%UVs/sHnUR
U5PM snUS'URS5=n(aUUS'URS5=n(aUUS'URS5=n(aUUS'URS5=n(aUUS'URS5=n(dGM�UUS'GM U$s snf)Nznetplan-global-stater�r%rArBrbr�prefixr�rf�
dns_addressesr��
dns_searchr�r�r�r-r�r�r�)r%r�r4rEr2r3�_system_route_to_netplan)rr-r<r=�device_typerXrrBrbr}rwr �	full_addrrr�r�r�r�uplink_interfacesr�r�r�s                      rr/�'NetplanDiffState._get_system_interfaces�sM���
�!%�!2�!2�!;�!;�!=�!C�!C�!E��I��2�2�� �*�*�V�,�K�%3�f�k�5J�$K�J�!�"�J�J�t�,�,�y�,�>G�9�%�n�5�d�;�"�-�n�=�I��
�
�7�+�+�u�+�%*�'�"��I��
�
�;��3���$�)�)�+�&�q�)�����"��)�)�(�3��!�d�!�F�8�,�	�(/����"��1A�1A�'�2�1N�'O�	�$�4��)2�+�&�$�j�j��9�9�{�9�5@�1�2����L�1�1�v�1�28�.�/����H�-�-�v�-�Y_�&`�Y_�PU�t�'D�'D�U�'K�Y_�&`�	�(�#��j�j��.�.�s�.�*-�	�,�'�$*�J�J�|�$<�<� �<�*;�	�,�'��z�z�&�)�)�t�)�$(�	�&�!����H�-�-�v�-�&,�	�(�#��j�j��'�'�s�'�'�#&�	�%� �_"F�b���#'as�9H5�system_routec�4�0nURS5=n(aX2S'URS5=n(aXBS'URS5=n(aXRS'URS5=n(aXbS'URS5=n(aXrS'URS5=n(aX�S'URS5=n	(aX�S'URS	5=n
(aX�S	'URS
5=n(aURU5US
'[S0UD6$)Nr�r�r��fromr�r�rr�r�r�r)rEr�r)rr(r�r�r�r�r�r�r�
route_typer�r�s            rr#�)NetplanDiffState._system_route_to_netplan�s)����!�%�%�h�/�/�6�/�$�(�O��!�!�$�'�'�2�'��$�K��"�"�5�)�)�3�)��%�L�$�(�(��0�0�9�0�!*�+��!�%�%�h�/�/�6�/�$�(�O� �$�$�W�-�-�5�-�"�'�N�%�)�)�&�1�1�:�1�&�&�M�#�'�'�
�3�3�8�3� (�*�� �$�$�W�-�-�5�-�!�F�F�u�M�E�'�N��$�e�$�$rr7c��UR5(a[U5$UR(d[5UlURR	US5$)Nr)�isdigit�intr(rrE)rr7s  rr��5NetplanDiffState._default_route_tables_name_to_numbersD���<�<�>�>��t�9���,�,�,>�,@�D�)��,�,�0�0��q�9�9r)r&r(r%)�)&rrrr �__doc__rr	r)rUr>r�rYrLr/rNrOrKr1rqr�rPrQrRrSrMrTr�rrr�r2r�r0rr/r#r�r!rrrr#r#&s���
+�%6�+�GY�+����:'�#�'�t�'�R
�D�
�	
�3�	
�3�	
�s�	
�t�	
�>�D�>��>�$�>�@�T��d��,	��	��	�
�c�
�c�
�;�4�;��;��;�z%�d�%�4�%�D�%�N�T��$��4��&�d��4��D��6!�$�!�3�!�4�!�F&_�D�&_��&_�$�&_�P�����46�$�6�;�|�3L�6�p6�;�|�3L�6�`d�eh�`i�6�sw�6�|�6�pP��P�dQ�d�Q�t�Q�4��4�l%�T�%�l�%�0:��:��:rr#)�collectionsrrrr�socketrr�typingr�netplan.netdefr�netplan_cli.cli.staterr	r
�netplan_cli.cli.utilsrrrrr#rrr�<module>r9s@��$$���$��'�U�U�I�3�d�&�&�3�p:�p:r

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 143 B 0644
core.cpython-313.pyc File 2.77 KB 0644
ovs.cpython-313.pyc File 7.62 KB 0644
sriov.cpython-313.pyc File 22.89 KB 0644
state.cpython-313.pyc File 35.3 KB 0644
state_diff.cpython-313.pyc File 38.25 KB 0644
utils.cpython-313.pyc File 17.91 KB 0644
Filemanager