AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.128   [ 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 :  /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 : /usr/share/netplan/netplan/cli/commands/__pycache__/try_command.cpython-310.pyc
o

|hEc��@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mmZddl
mZddlZddlmZdZGdd�dej�ZdS)znetplan try command line�N)�
ConfigManager)�NetplanApply�xcsxeZdZ�fdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�
NetplanTrycs`t�jdddd�d|_d|_d|_d|_d|_d|_tj	�
dd�|_tj�
|jdd	d
�|_dS)N�tryzLTry to apply a new netplan config to running system, with automatic rollbackT)�
command_id�description�leafF�DBUS_TEST_NETPLAN_ROOT�/�run�netplanznetplan-try.ready)�super�__init__�configuration_changed�new_interfaces�config_file�_config_manager�
t_settings�t�os�environ�get�_rootdir�path�join�_netplan_try_stamp��self��	__class__��6/usr/share/netplan/netplan/cli/commands/try_command.pyr)s�zNetplanTry.__init__cCs|js
t|jd�|_|jS)N)�prefix)rrrrr!r!r"�config_manager7szNetplanTry.config_managercCs"tj�|j�rt�|j�dSdS)NTF)rr�isfiler�removerr!r!r"�clear_ready_stamp=szNetplanTry.clear_ready_stampcCs*tj|jdddd�t|jd���dS)Nz/run/netplani�T)�mode�exist_ok�w)r�makedirsr�openr�closerr!r!r"�touch_ready_stampCszNetplanTry.touch_ready_stampcCsP|jjddd�|jjdttdd�|jjddd�|j|_|��|��dS)	Nz
--config-filezGApply the config file in argument in addition to current configuration.)�helpz	--timeoutz=Maximum number of seconds to wait for the user's confirmation)�type�defaultr/z--statez0Directory containing previous YAML configuration)�parser�add_argument�int�DEFAULT_INPUT_TIMEOUT�command_try�func�
parse_args�run_commandrr!r!r"rGs���zNetplanTry.runc
Csp|��s
t�tj�z�zDtj��}tj�	|�|_
|j
�|j�t
�
t
j|j�t
�
t
j|j�|��|��t�jddd|jd�|��|j
j|jd�Wn@tjjybtd�|��Yn.tjjyptd�Yn ty�}ztd|�td�|��WYd}~nd}~wwW|j
r�|j
�|j�|��|� �dS|j
r�|j
�|j�|��|� �w)NTF��run_generate�sync�
exit_on_error�	state_dir)�timeoutz
Reverting.z
Configuration accepted.z
An error occurred: %s)!�
is_revertable�sys�exitr�	EX_CONFIG�stdin�filenor
�terminal�Terminalr�saver�signal�SIGINT�_signal_handler�SIGUSR1�backup�setupr�
command_apply�stater.�get_confirmation_inputr?�
InputRejected�print�revert�
InputAccepted�	Exception�reset�cleanupr')r�fd�er!r!r"r6UsB
����
zNetplanTry.command_trycCs d}|jrd}|jj|d�dS)NFT)�backup_config_dir)rr$rM)rr[r!r!r"rMzszNetplanTry.backupcCsd|jr-tj�ddd�}tj�|j��d�}t��}tj�|d�||��}|j�	|j|i�d|_
dS)Nr�etcr
z.yamlz
{}.{}.yamlT)rrrr�basename�rstrip�time�formatr$�addr)r�dest_dir�	dest_name�dest_suffix�	dest_pathr!r!r"rN�s
zNetplanTry.setupcCs^t��}tj�|dd�}t�|�tjd|dd�|j�	�t
�jddd|d�t�|�dS)Nr\r
z/etc/netplanT)�
dirs_exist_okFr:)
�tempfile�mkdtemprrrr+�shutil�copytreer$rTrrO�rmtree)r�tempdir�confdirr!r!r"rT�s

zNetplanTry.revertcCs|j��dS�N)r$rXrr!r!r"rX�szNetplanTry.cleanupc	
Cs�g}|jr|�|j�d}z	|jj|d�}Wntjy4}zt�|�t�	t
j�WYd}~nd}~wwg}i}|�|j
�|�|j�|��D]}|jsXd}|�|j|f�qI|rp|D]\}}td�||��q]td�dSdS)a
        Check if the configuration is revertable, if it doesn't contain bits
        that we know are likely to render the system unstable if we apply it,
        or if we revert.

        Returns True if the parsed config is "revertable", meaning that we
        can actually rely on backends to re-apply /all/ of the relevant
        configuration to interfaces when their config changes.

        Returns False if the parsed config contains options that are known
        to not cleanly revert via the backend.
        N)�extra_configzBreverting custom parameters for bridges and bonds is not supportedz{}: {}zL
Please carefully review the configuration and use 'netplan apply' directly.FT)r�appendr$�parse�utils�
config_errors�logging�errorrArBrrC�update�bridges�bonds�values�is_trivial_compound_itf�idrSr`)	rro�np_staterZ�revert_unsupported�multi_iface�itf�reason�ifnamer!r!r"r@�s4
���zNetplanTry.is_revertablecCs(|tjkr
tj���|jrtj���dSrn)rIrLr
rFrUrrR)r�sig�framer!r!r"rK�s



�zNetplanTry._signal_handler)�__name__�
__module__�__qualname__r�propertyr$r'r.rr6rMrNrTrXr@rK�
__classcell__r!r!rr"r's
%	-r)�__doc__rtrr_rirIrArg�netplan.configmanagerr�netplan.cli.utils�clirr�netplan.cli.commands.applyr�netplan.terminalr
�netplan.libnetplan�
libnetplanr5�NetplanCommandrr!r!r!r"�<module>s

Anon7 - 2022
AnonSec Team