Development
This commit is contained in:
parent
f04b2b36cc
commit
5a3a18d5b0
7 changed files with 123 additions and 33 deletions
|
|
@ -29,7 +29,7 @@ def _hash_ok():
|
|||
def _parse_ip():
|
||||
raw = request.form.get('ip', '').strip()
|
||||
if not raw:
|
||||
return 'dynamic'
|
||||
return ''
|
||||
ip = validate.ip(raw)
|
||||
if not ip:
|
||||
flash(f'The configuration has not been saved because "{raw}" is not a valid IP address.', 'error')
|
||||
|
|
@ -38,7 +38,7 @@ def _parse_ip():
|
|||
|
||||
|
||||
def _check_ip_in_vlan_subnet(ip, vlan):
|
||||
if not ip or ip == 'dynamic':
|
||||
if not ip:
|
||||
return None
|
||||
subnet = vlan.get('subnet')
|
||||
prefix = vlan.get('subnet_mask')
|
||||
|
|
@ -98,13 +98,14 @@ def addreservation_add():
|
|||
|
||||
entry = {
|
||||
'description': description,
|
||||
'hostname': hostname,
|
||||
'mac': mac,
|
||||
'ip': ip,
|
||||
'radius_client': radius_client,
|
||||
'enabled': True,
|
||||
'vlan': vlan_name,
|
||||
}
|
||||
if hostname:
|
||||
entry['hostname'] = hostname
|
||||
cfg.setdefault('dhcp_reservations', []).append(entry)
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
|
|
@ -192,12 +193,15 @@ def reservations_edit():
|
|||
before = copy.deepcopy(res)
|
||||
res.update({
|
||||
'description': description,
|
||||
'hostname': hostname,
|
||||
'mac': mac,
|
||||
'ip': ip,
|
||||
'radius_client': radius_client,
|
||||
'enabled': 'enabled' in request.form,
|
||||
})
|
||||
if hostname:
|
||||
res['hostname'] = hostname
|
||||
else:
|
||||
res.pop('hostname', None)
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue