Development
This commit is contained in:
parent
351ce39558
commit
3b2f645254
4 changed files with 34 additions and 30 deletions
|
|
@ -118,9 +118,12 @@ def build_radius_users(data):
|
|||
if default_vlan is None:
|
||||
return None
|
||||
|
||||
fr_opts = data.get('radius', {}).get('options', {})
|
||||
mac_fmt = fr_opts.get('mac_format', 'aabbccddeeff')
|
||||
apply_to = fr_opts.get('apply_to', 'all')
|
||||
fr_opts = data.get('radius', {}).get('options', {})
|
||||
mac_fmt = fr_opts.get('mac_format', 'aabbccddeeff')
|
||||
apply_to = fr_opts.get('apply_to', 'all')
|
||||
auth_mode = fr_opts.get('auth_mode', 'mab')
|
||||
mab_first = fr_opts.get('mab_first', True)
|
||||
emit_mac_entries = (auth_mode == 'mab') or mab_first
|
||||
|
||||
lines = [
|
||||
"# Generated by core.py -- do not edit manually.",
|
||||
|
|
@ -129,25 +132,26 @@ def build_radius_users(data):
|
|||
]
|
||||
|
||||
vlan_by_name = {v["name"]: v for v in data.get("vlans", [])}
|
||||
for r in data.get("dhcp_reservations", []):
|
||||
if r.get("enabled") is not True:
|
||||
continue
|
||||
raw_mac = r.get("mac", "")
|
||||
if not raw_mac:
|
||||
continue
|
||||
vlan = vlan_by_name.get(r.get("vlan", ""))
|
||||
if not vlan:
|
||||
continue
|
||||
mac = fmt_mac(raw_mac, mac_fmt)
|
||||
vlan_id = vlan.get('vlan_id')
|
||||
lines += [
|
||||
f"# {r['description']} -> VLAN {vlan_id} ({vlan['name']})",
|
||||
f"{mac} Cleartext-Password := \"{mac}\"",
|
||||
f" Tunnel-Type = VLAN,",
|
||||
f" Tunnel-Medium-Type = IEEE-802,",
|
||||
f" Tunnel-Private-Group-Id = \"{vlan_id}\"",
|
||||
"",
|
||||
]
|
||||
if emit_mac_entries:
|
||||
for r in data.get("dhcp_reservations", []):
|
||||
if r.get("enabled") is not True:
|
||||
continue
|
||||
raw_mac = r.get("mac", "")
|
||||
if not raw_mac:
|
||||
continue
|
||||
vlan = vlan_by_name.get(r.get("vlan", ""))
|
||||
if not vlan:
|
||||
continue
|
||||
mac = fmt_mac(raw_mac, mac_fmt)
|
||||
vlan_id = vlan.get('vlan_id')
|
||||
lines += [
|
||||
f"# {r['description']} -> VLAN {vlan_id} ({vlan['name']})",
|
||||
f"{mac} Cleartext-Password := \"{mac}\"",
|
||||
f" Tunnel-Type = VLAN,",
|
||||
f" Tunnel-Medium-Type = IEEE-802,",
|
||||
f" Tunnel-Private-Group-Id = \"{vlan_id}\"",
|
||||
"",
|
||||
]
|
||||
|
||||
default_id = default_vlan.get('vlan_id')
|
||||
ap_ips = fr_opts.get('ap_ips', [])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue