/usr/share/netplan/netplan/cli/commands/__pycache__
Edit: /usr/share/netplan/netplan/cli/commands/__pycache__/try_command.cpython-38.pyc (5877B)
U
)/b @ s d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddl
m mZ ddl
mZ ddlZdZG dd dejZdS )znetplan try command line N)
ConfigManager)NetplanApplyx c sx e Zd Z fddZedd Zdd Zdd Zd d
Zdd Z d
d Z
dd Zdd Zdd Z
dd Zdd Z ZS )
NetplanTryc sZ t jdddd d| _d | _d | _d | _d | _tj dd| _
tj| j
dd d
| _
d S )NtryzLTry to apply a new netplan config to running system, with automatic rollbackT)
command_iddescriptionleafFZDBUS_TEST_NETPLAN_ROOT/runnetplanznetplan-try.ready)super__init__configuration_changednew_interfaces_config_manager
t_settingstosenvironget_rootdirpathjoin_netplan_try_stampself __class__ 6/usr/share/netplan/netplan/cli/commands/try_command.pyr ( s zNetplanTry.__init__c C s | j st | _ | j S N)r r r r r r config_manager5 s zNetplanTry.config_managerc C s" t j| jrt | j dS dS )NTF)r r isfiler remover r r r clear_ready_stamp; s zNetplanTry.clear_ready_stampc C s* t j| jd ddd t| jd d S )Nz/run/netplani T)modeexist_okw)r makedirsr openr closer r r r touch_ready_stampA s zNetplanTry.touch_ready_stampc C sP | j jddd | j jdttdd | j jddd | j| _| | d S ) 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)typedefaultr- z--statez0Directory containing previous YAML configuration)parseradd_argumentintDEFAULT_INPUT_TIMEOUTcommand_tryfunc
parse_argsrun_commandr r r r r E s zNetplanTry.runc
C sV | sttj zztj
}tj
|| _| j| j ttj| j ttj| j | | t jddd| jd | | jj| jd W n tj
jk
r td | Y n^ tj
jk
r td Y n@ t k
r$ } z td| td | W 5 d }~X Y nX W 5 | jr@| j| j | | X d S )NTFrun_generatesync
exit_on_error state_dir)timeoutz
Reverting.z
Configuration accepted.z
An error occurred: %s)!
is_revertablesysexitr EX_CONFIGr resetr cleanupr% stdinfilenor terminalZTerminalZsavesignalSIGINT_signal_handlerSIGUSR1backupsetupr
command_applystater, Zget_confirmation_inputr=
InputRejectedprintrevert
InputAccepted Exception)r fder r r r4 S s4
zNetplanTry.command_tryc C s d}| j rd}| jj|d d S )NFT)backup_config_dir)config_filer" rK )r rV r r r rK x s zNetplanTry.backupc C sd | j rZtjddd}tj| j d}t }tj|d||}| j | j |i d| _
d S )Nr
etcr z.yamlz
{}.{}.yamlT)rW r r r basenamerstriptimeformatr" addr )r Zdest_dirZ dest_nameZdest_suffixZ dest_pathr r r rL ~ s zNetplanTry.setupc C s^ t }tj|dd}t| tjd|dd | j t
jddd|d t| d S )NrX r z/etc/netplanT)
dirs_exist_okFr8 )
tempfilemkdtempr r r r) shutilcopytreer" rQ r rM rmtree)r tempdirZconfdirr r r rQ s
zNetplanTry.revertc C s | j d S r! )r" rC r r r r rC s zNetplanTry.cleanupc C s g }| j r|| j | jj|d | jj| _td| j g }i }|| jj || jj
| D ]&\}}|rld|krld}|||f ql|r|D ]\}}td|| qtd dS dS ) 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.
)extra_configzNew interfaces: {}
parameterszBreverting custom parameters for bridges and bonds is not supportedz{}: {}zL
Please carefully review the configuration and use 'netplan apply' directly.FT)
rW appendr" parser loggingdebugr\ updatebridgesbondsitemsrP )r re Zrevert_unsupportedZmulti_ifaceifnamesettingsreasonr r r r> s(
zNetplanTry.is_revertablec C s* |t jkrtj n| jr&tj d S r! )rG rJ r rF rR r rO )r sigframer r r rI s
zNetplanTry._signal_handler)__name__
__module____qualname__r propertyr" r% r, r r4 rK rL rQ rC r> rI
__classcell__r r r r r &