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

�

�f�&����UddlZddlmZmZddlmZmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZddlmZddlmZddlmZej2e�ZGd�de�Zd	efd
�ZGd�de�Z Gd
�de �Z!Gd�de �Z"Gd�de �Z#Gd�de �Z$Gd�de �Z%gd�Z&e!e$e#e%e"d�Z'ee(e	e fe)d<dee(de
e(dfd	ee	e fd�Z*	ddeee(dee(d	e	e fd�Z+y)�N)�ABC�abstractmethod)�Dict�Iterable�List�Optional�Type�Union)�subp�util)�	available)�NetworkStatec��eZdZy)�NoActivatorExceptionN)�__name__�
__module__�__qualname__���:/usr/lib/python3/dist-packages/cloudinit/net/activators.pyrrs��rr�returnc��tjd||�	tj|�\}}t|�rtj	d||�y#tj
$rt
jtd|�YywxYw)Nz#Attempting command %s for device %sz(Running %s resulted in stderr output: %sTz#Running interface command %s failedF)�LOG�debugr�len�warning�ProcessExecutionErrorr�logexc)�cmd�device_name�_out�errs    r�_alter_interfacer#sm���I�I�3�S�+�F���i�i��n���s��s�8��K�K�B�C��M����%�%�����C�>��D���s�:A�.B�Bc��eZdZeeddeedefd���Zeededefd���Z	eededefd���Z
edeedefd	��Z
ed
edefd��Zy)
�NetworkActivatorN�targetrc��t��)z>Return True if activator is available, otherwise return False.��NotImplementedError�r&s rr
zNetworkActivator.available!s
��"�#�#rr c��t��)zWBring up interface.

        Return True is successful, otherwise return False
        r(�r s r�bring_up_interfacez#NetworkActivator.bring_up_interface'�
��"�#�#rc��t��)zYBring down interface.

        Return True is successful, otherwise return False
        r(r,s r�bring_down_interfacez%NetworkActivator.bring_down_interface0r.r�device_namesc�,��t�fd�|D��S)zjBring up specified list of interfaces.

        Return True is successful, otherwise return False
        c3�@�K�|]}�j|����y�w�N)r-)�.0�device�clss  �r�	<genexpr>z7NetworkActivator.bring_up_interfaces.<locals>.<genexpr>?s�����M�f�3�)�)�&�1�M�s�)�all)r7r1s` r�bring_up_interfacesz$NetworkActivator.bring_up_interfaces9s����M��M�M�Mr�
network_statec�l�|j|j�D�cgc]}|d��	c}�Scc}w)z\Bring up all interfaces.

        Return True is successful, otherwise return False
        �name)r:�iter_interfaces)r7r;�is   r�bring_up_all_interfacesz(NetworkActivator.bring_up_all_interfacesAs5���&�&� -� =� =� ?�@�1�Q�v�Y�@�
�	
��@s�1r4)rrr�staticmethodrr�str�boolr
r-r0�classmethodrr:rr@rrrr%r% s�����$�(�3�-�$�4�$���$���$��$��$���$���$�#�$�$�$���$��N�x��}�N��N��N��
�L�
�T�
��
rr%c�b�eZdZeddeedefd��Zededefd��Zededefd��Z	y)	�IfUpDownActivatorNr&rc��t|��S�z3Return true if ifupdown can be used on this system.r*)�
eni_availabler*s rr
zIfUpDownActivator.availableQs���F�+�+rr c�"�d|g}t||�S)�bBring up interface using ifup.

        Return True is successful, otherwise return False
        �ifup�r#�r rs  rr-z$IfUpDownActivator.bring_up_interfaceVs���{�#����[�1�1rc�"�d|g}t||�S)rK�ifdownrMrNs  rr0z&IfUpDownActivator.bring_down_interface_s����%����[�1�1rr4)
rrrrArrBrCr
r-r0rrrrFrFLsl��
�,�(�3�-�,�4�,��,��2��2��2��2��2�#�2�$�2��2rrFc�X�eZdZeddefd��Zededefd��Zededefd��Zy)�IfConfigActivatorNrc�<�d}dg}tj|||��S)z3Return true if ifconfig can be used on this system.�ifconfigz/sbin)�searchr&)r�which)r&�expectedrUs   rr
zIfConfigActivator.availablejs#��������z�z�(�6�&�A�Arr c�$�d|dg}t||�S)zoBring up interface using ifconfig <dev> up.

        Return True is successful, otherwise return False
        rT�uprMrNs  rr-z$IfConfigActivator.bring_up_interfaceqs���;��-����[�1�1rc�$�d|dg}t||�S)zqBring up interface using ifconfig <dev> down.

        Return True is successful, otherwise return False
        rT�downrMrNs  rr0z&IfConfigActivator.bring_down_interfacezs���;��/����[�1�1rr4�	rrrrArCr
rBr-r0rrrrRrRisb���B�$�B��B��2��2��2��2��2�#�2�$�2��2rrRc�X�eZdZeddefd��Zededefd��Zededefd��Zy)�NetworkManagerActivatorNrc��t|��S)z9Return true if NetworkManager can be used on this system.r*)�nm_availabler*s rr
z!NetworkManagerActivator.available�s���6�*�*rr c���ddlm}||�}|�tjd�yddd|g}t	||�rdddd	|g}nt	gd
�|�dddd|g}t	||�S)zdBring up connection using nmcli.

        Return True is successful, otherwise return False
        r)�
conn_filenamezFUnable to find an interface config file. Unable to bring up interface.F�nmcli�
connection�loadrY�filename)rcrd�reload�ifname)�cloudinit.net.network_managerrbrrr#)r rbrfrs    rr-z*NetworkManagerActivator.bring_up_interface�s~��	@� ��-�����K�K�0�
����f�h�7���C��-��L�$�
�H�E�C��>��L��L�$��+�F�C���[�1�1rc�&�ddd|g}t||�S)zeBring down interface using nmcli.

        Return True is successful, otherwise return False
        rcr6�
disconnectrMrNs  rr0z,NetworkManagerActivator.bring_down_interface�s����,��<����[�1�1rr4r\rrrr^r^�s_���+�$�+��+��2��2��2��2�.�2�#�2�$�2��2rr^c��eZdZddgZed
defd��Zededefd��Zede	edefd	��Z
ed
edefd��Zededefd��Z
y)�NetplanActivator�netplan�applyNrc��t|��S)z2Return true if netplan can be used on this system.r*)�netplan_availabler*s rr
zNetplanActivator.available�s��!��/�/rr c�`�tjd�ttjd�S��YApply netplan config.

        Return True is successful, otherwise return False
        zBCalling 'netplan apply' rather than altering individual interfacesr9�rrr#rm�NETPLAN_CMDr,s rr-z#NetplanActivator.bring_up_interface��+��	�	�	�
-�	
� � 0� <� <�e�D�Drr1c�`�tjd�ttjd�Srsru)r1s rr:z$NetplanActivator.bring_up_interfaces�rwrr;c�6�ttjd�S)rtr9)r#rmrv)r;s rr@z(NetplanActivator.bring_up_all_interfaces�s�� � 0� <� <�e�D�Drc�`�tjd�ttjd�Srsrur,s rr0z%NetplanActivator.bring_down_interface�rwrr4)rrrrvrArCr
rBr-rr:rr@r0rrrrmrm�s����g�&�K��0�$�0��0��	E��	E��	E��	E��	E�(�3�-�	E�D�	E��	E��E�|�E��E��E��	E�#�	E�$�	E��	Errmc�r�eZdZed	defd��Zededefd��Zededefd��Z	ededefd��Z
y)
�NetworkdActivatorNrc��t|��SrH)�networkd_availabler*s rr
zNetworkdActivator.available�s��"��0�0rr c�(�dddd|g}t||�S)�1Return True is successful, otherwise return False�ip�link�setrYrMrNs  rr-z$NetworkdActivator.bring_up_interface�s!���V�U�D�+�6����[�1�1rr;c�"�gd�}t|d�S)r�)�	systemctl�restartzsystemd-networkdzsystemd-resolvedr9rM)r;rs  rr@z)NetworkdActivator.bring_up_all_interfaces�s��O����U�+�+rc�(�dddd|g}t||�S)r�r�r�r�r[rMrNs  rr0z&NetworkdActivator.bring_down_interface�s!���V�U�F�K�8����[�1�1rr4)rrrrArCr
rBr-rr@r0rrrr|r|�s����1�$�1��1��2��2��2��2�
�,�|�,��,��,�
�2�#�2�$�2��2rr|)�enirnznetwork-manager�networkdrT�NAME_TO_ACTIVATOR�priorityr&c���|D�cgc]
}|tvs�|��}}|rtd|z��|D�cgc]}t|��
}}|D�cgc]}|j|�r|��c}Scc}wcc}wcc}w)Nz0Unknown activators provided in priority list: %s)�DEFAULT_PRIORITY�
ValueErrorr�r
)r�r&r?�unknownr=�activator_classes�
activator_clss       r�search_activatorr�
s���#�@�Q�a�/?�&?�q�@�G�@���>��H�
�	
�>F�F�T�*�4�0�F��F�/����"�"�6�*�	����
A��
G��s�
A �A �A%�A*c��|�t}t||�}|sd}|r
|dk7rd|z}td|�d|����|d}tj	d||�|S)N��/z
 in target=%sz%No available network activators foundz. Searched through list: rz.Using selected activator: %s from priority: %s)r�r�rrr)r�r&�found�tmsg�selecteds     r�select_activatorr�sr����#���X�v�.�E�����f��m�"�V�+�D�"�"&��
2�
�	
��Q�x�H��I�I�8�(�H���Or)NN),�logging�abcrr�typingrrrrr	r
�	cloudinitrr�cloudinit.net.enir
rI�cloudinit.net.netplanrqrir`�cloudinit.net.network_stater�cloudinit.net.networkdr~�	getLoggerrr�	ExceptionrrCr#r%rFrRr^rmr|r�r�rB�__annotations__r�r�rrr�<module>r�sC���#�>�>� �8�@�C�4�B��g����!��	�9�	�	�$�	�)
�s�)
�X2�(�2�:2�(�2�6%2�.�%2�P2E�'�2E�j2�(�2�6����.�!�!�8��4��T�"2�3�3�4��
��3�i�
�!&�s�D�y�!1�
�	�$��
 �!�
�"CG���t�C�y�!��2:�3�-��	�
��r

Zerion Mini Shell 1.0