HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //proc/676643/root/usr/share/netplan/netplan_cli/__pycache__/configmanager.cpython-310.pyc
o

ϐxe��@sddZddlZddlZddlZddlZddlZddlZddlmZGdd�de	�Z
Gdd�de�ZdS)znetplan configuration manager�N)�Optionalc@s�eZdZdifdd�Zdd�Zedd��Zedd	��Zddd�Zd
d�Z	ddd�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zd
S) �
ConfigManager�/cCsP||_tjdd�|_tj�|jd�|_tj�|jd�|_||_	t
�|_d|_dS)N�netplan_)�prefix�etc�run)
r�tempfile�mkdtemp�tempdir�os�path�join�temp_etc�temp_run�extra_files�set�new_interfaces�np_state)�selfrr�r�//usr/share/netplan/netplan_cli/configmanager.py�__init__s
zConfigManager.__init__cCs|jdus	Jd��t|j|�S�Nz.Must call parse() before accessing the config.)r�getattr)r�attrrrr�__getattr__(szConfigManager.__getattr__cCsD|jdus	Jd��i}|�|jj�|�|jj�|�|jj�|Sr)r�update�	ethernets�modems�wifis�r�
interfacesrrr�physical_interfaces,sz!ConfigManager.physical_interfacescCs||jdus	Jd��i}|�|jj�|�|jj�|�|jj�|�|jj�|�|jj�|�|jj�|�|jj�|Sr)	rr�bridges�bonds�
dummy_devices�tunnels�virtual_ethernets�vlans�vrfsr!rrr�virtual_interfaces5sz ConfigManager.virtual_interfacesNc
Cs�t��}z |j|jd�|r|D]}|�|�qt��|_|j�|�Wntjy7}zt	t
|���d}~wwt���}|jj
|d�t�d�|����Wd�|jS1sZwY|jS)z�
        Parse all our config files to return an object that describes the system's
        entire configuration, so that it can later be interrogated.

        Returns a libnetplan State wrapper
        )�rootdirN)�output_filezMerged config:
{})�netplan�Parser�load_yaml_hierarchyr�	load_yaml�Stater�import_parser_results�NetplanException�ConfigurationError�strr	�
TemporaryFile�
_dump_yaml�logging�debug�format�read)r�extra_config�parser�f�e�tmprrr�parseCs&	
��

��zConfigManager.parsecCs0|D]
}|�|||�q|j�|�d|_dS�N)�
_copy_filerrr)r�config_dict�config_filerrr�add`s
zConfigManager.addTcCs�|r|�tj�|jd�tj�|jd��|jtj�|jd�tj�|jdd�dd�|jtj�|jd�tj�|jd	d
�dd�dS)Nzetc/netplanr.�%run/NetworkManager/system-connections�NetworkManagerzsystem-connectionsT)�
missing_ok�run/systemd/network�systemd�network)�
_copy_treerr
rrrr)r�backup_config_dirrrr�backuphs��
�zConfigManager.backupc
Csz`t|j�D]}t�|j|�|j|=qd�|j�}d�|j�}tj�|�r>t�	tj�
|jd��|�|tj�
|jd��tj�|�r^t�	tj�
|jd��|�|tj�
|jd��WdSWdSt
y�}zt�d�|��t�d�t�d�WYd}~dSd}~ww)Nz${}/NetworkManager/system-connectionsz{}/systemd/networkrHrKz8Something really bad happened while reverting config: {}zZYou should verify the netplan YAML in /etc/netplan and probably run 'netplan apply' again.���)�dictrr�unlinkr;rr
�exists�shutil�rmtreerrrN�	Exceptionr9�error�sys�exit)r�
extra_file�temp_nm_path�temp_networkd_pathr@rrr�revertss.
�
��
��zConfigManager.revertcCst�|j�dSrC)rUrVr�rrrr�cleanup��zConfigManager.cleanupcCs$z|��WdStyYdSwrC)r`�FileNotFoundErrorr_rrr�__del__�s
�zConfigManager.__del__cCst�||�dSrC)rU�copy)r�src�dstrrrrD�razConfigManager._copy_fileFcCs.z	t�||�WdSty|rYdS�wrC)rU�copytreerb)rrerfrJrrrrN�s�zConfigManager._copy_treerC)T)F)�__name__�
__module__�__qualname__rr�propertyr#r+rBrGrPr^r`rcrDrNrrrrrs	




rc@seZdZdZdS)r5zL
    Configuration could not be parsed or has otherwise failed to apply
    N)rhrirj�__doc__rrrrr5�sr5)
rlr9r.rrUrYr	�typingr�objectrrWr5rrrr�<module>s