Development
This commit is contained in:
parent
adcfe55c7c
commit
59d3d65d18
7 changed files with 146 additions and 75 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import copy
|
||||
import os
|
||||
|
||||
from flask import Blueprint, request, redirect, flash
|
||||
from auth import require_level
|
||||
from config_utils import load_config, save_config, verify_config_hash, queued_msg, queue_command
|
||||
from config_utils import load_config, save_config_with_snapshot, verify_config_hash, queued_msg, queue_command
|
||||
import sanitize
|
||||
import validation as validate
|
||||
|
||||
|
|
@ -54,8 +55,9 @@ def networkinterfaces_cardnetworkinterface_save():
|
|||
flash(f"Interface '{iface}' does not exist on this system.", 'error')
|
||||
return redirect(_VIEW)
|
||||
|
||||
cfg = load_config()
|
||||
gen = cfg.setdefault('network_interfaces', {})
|
||||
cfg = load_config()
|
||||
before = copy.deepcopy(cfg.get('network_interfaces', {}))
|
||||
gen = cfg.setdefault('network_interfaces', {})
|
||||
gen['wan_interface'] = wan
|
||||
gen['lan_interface'] = lan
|
||||
errors = validate.validate_config(cfg)
|
||||
|
|
@ -63,9 +65,12 @@ def networkinterfaces_cardnetworkinterface_save():
|
|||
for msg in errors:
|
||||
flash(msg, 'error')
|
||||
return redirect(_VIEW)
|
||||
save_config(cfg)
|
||||
|
||||
flash(queued_msg('core apply'), 'success')
|
||||
flash(save_config_with_snapshot(
|
||||
cfg, path='network_interfaces', key='global', operation='edit',
|
||||
before=before, after=copy.deepcopy(cfg['network_interfaces']),
|
||||
description='Updated network interfaces',
|
||||
cmd='core apply',
|
||||
), 'success')
|
||||
return redirect(_VIEW)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue