Development
This commit is contained in:
parent
d8d1d46fd2
commit
eed1d295dc
69 changed files with 3355 additions and 3230 deletions
|
|
@ -1,44 +0,0 @@
|
|||
import copy
|
||||
|
||||
from flask import Blueprint, request, redirect, flash
|
||||
from auth import require_level
|
||||
from config_utils import load_config, save_config_with_snapshot, verify_config_hash
|
||||
import sanitize
|
||||
import validation as validate
|
||||
|
||||
bp = Blueprint('action_apply_mdns', __name__)
|
||||
|
||||
|
||||
@bp.route('/action/apply_mdns', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def apply_mdns():
|
||||
mdns_enabled = 'mdns_enabled' in request.form
|
||||
|
||||
if not verify_config_hash(request.form.get('config_hash', '')):
|
||||
flash('Configuration was modified by another session. Please refresh and try again.', 'error')
|
||||
return redirect('/view/view_mdns')
|
||||
|
||||
cfg = load_config()
|
||||
mdns_reflect_vlans = sanitize.filterlist(
|
||||
request.form.getlist('mdns_reflect_vlans'),
|
||||
{v.get('name') for v in cfg.get('vlans', [])},
|
||||
)
|
||||
|
||||
before = copy.deepcopy(cfg.get('mdns_reflection', {}))
|
||||
cfg.setdefault('mdns_reflection', {}).update({
|
||||
'enabled': mdns_enabled,
|
||||
'reflect_vlans': mdns_reflect_vlans,
|
||||
})
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
flash(msg, 'error')
|
||||
return redirect('/view/view_mdns')
|
||||
|
||||
flash(save_config_with_snapshot(
|
||||
cfg,
|
||||
path='mdns_reflection', key='global', operation='edit',
|
||||
before=before or None, after=copy.deepcopy(cfg['mdns_reflection']),
|
||||
description='Updated mDNS reflection settings',
|
||||
), 'success')
|
||||
return redirect('/view/view_mdns')
|
||||
Loading…
Add table
Add a link
Reference in a new issue