Development

This commit is contained in:
Matthew Grotke 2026-05-25 22:12:12 -04:00
parent 91d8b950b7
commit ba74852d8a
2 changed files with 17 additions and 11 deletions

View file

@ -39,8 +39,7 @@ def _flat_index_to_vlan_res(vlans, flat_idx):
def _parse_ip(): def _parse_ip():
raw = request.form.get('ip', '').strip() raw = request.form.get('ip', '').strip()
if not raw: if not raw:
flash('The configuration has not been saved because an IP address is required.', 'error') return 'dynamic'
return None
ip = validate.ip(raw) ip = validate.ip(raw)
if not ip: if not ip:
flash(f'The configuration has not been saved because "{raw}" is not a valid IP address.', 'error') flash(f'The configuration has not been saved because "{raw}" is not a valid IP address.', 'error')
@ -49,6 +48,8 @@ def _parse_ip():
def _check_ip_conflicts(ip, vlan): def _check_ip_conflicts(ip, vlan):
if ip == 'dynamic':
return None
dhcp = vlan.get('dhcp_information', {}) dhcp = vlan.get('dhcp_information', {})
pool_start = dhcp.get('dynamic_pool_start') pool_start = dhcp.get('dynamic_pool_start')
pool_end = dhcp.get('dynamic_pool_end') pool_end = dhcp.get('dynamic_pool_end')
@ -117,7 +118,7 @@ def add_dhcp_reservation():
cfg, cfg,
path=f'vlans.{vlan_name}.reservations', key=mac, operation='add', path=f'vlans.{vlan_name}.reservations', key=mac, operation='add',
before=None, after=entry, before=None, after=entry,
description=f'Added DHCP reservation: {hostname or mac} ({ip})', description=f'Added DHCP reservation: {hostname or mac} ({ip or "dynamic"})',
), 'success') ), 'success')
return redirect(VIEW) return redirect(VIEW)
@ -214,7 +215,7 @@ def edit_dhcp_reservation():
cfg, cfg,
path=f'vlans.{vlan_name}.reservations', key=mac, operation='edit', path=f'vlans.{vlan_name}.reservations', key=mac, operation='edit',
before=before, after=copy.deepcopy(res), before=before, after=copy.deepcopy(res),
description=f'Edited DHCP reservation: {hostname or mac} ({ip})', description=f'Edited DHCP reservation: {hostname or mac} ({ip or "dynamic"})',
), 'success') ), 'success')
return redirect(VIEW) return redirect(VIEW)

View file

@ -2073,6 +2073,12 @@
} }
] ]
}, },
{
"type": "info_bar",
"variant": "info",
"text": "This page assigns fixed or dynamic IPs to devices and authorizes them to be placed on a specified VLAN.",
"client_requirement": "client_is_administrator+"
},
{ {
"type": "table", "type": "table",
"datasource": "live:dhcp_leases", "datasource": "live:dhcp_leases",
@ -2176,8 +2182,7 @@
}, },
{ {
"col": "ip", "col": "ip",
"input_type": "text", "input_type": "text"
"validate": "ipv4"
}, },
{ {
"col": "radius_client", "col": "radius_client",
@ -2203,7 +2208,7 @@
{ {
"type": "card", "type": "card",
"id": "add-form", "id": "add-form",
"label": "Add Reservation", "label": "Add Reservation/Authorization",
"client_requirement": "client_is_administrator+", "client_requirement": "client_is_administrator+",
"items": [ "items": [
{ {
@ -2247,15 +2252,15 @@
"label": "IP Address", "label": "IP Address",
"name": "ip", "name": "ip",
"input_type": "text", "input_type": "text",
"validate": "ipv4", "placeholder": "e.g. 192.168.10.50",
"placeholder": "e.g. 192.168.10.50" "hint": "Leave blank to authorize device on this VLAN dynamically."
}, },
{ {
"type": "field", "type": "field",
"label": "RADIUS Client", "label": "RADIUS Client",
"name": "radius_client", "name": "radius_client",
"input_type": "checkbox", "input_type": "checkbox",
"hint": "Authenticate this device via RADIUS." "hint": "This device acts as a RADIUS authenticator, verifying credentials of other devices on the network."
}, },
{ {
"type": "button_row", "type": "button_row",
@ -2264,7 +2269,7 @@
"type": "button_primary", "type": "button_primary",
"action": "/action/add_dhcp_reservation", "action": "/action/add_dhcp_reservation",
"method": "post", "method": "post",
"text": "Add Reservation" "text": "Add"
}, },
{ {
"type": "button_cancel", "type": "button_cancel",