Development
This commit is contained in:
parent
2905f21052
commit
f04b2b36cc
5 changed files with 22 additions and 10 deletions
|
|
@ -69,6 +69,11 @@ def live_dhcp_leases():
|
|||
for r in cfg.get('dhcp_reservations', [])
|
||||
if r.get('mac') and r.get('hostname')
|
||||
}
|
||||
mac_to_desc = {
|
||||
r['mac'].lower(): r['description']
|
||||
for r in cfg.get('dhcp_reservations', [])
|
||||
if r.get('mac') and r.get('description')
|
||||
}
|
||||
for leases_file in glob.glob('/var/lib/misc/dnsmasq-routlin-*.leases'):
|
||||
stem = os.path.basename(leases_file)
|
||||
vlan_name = stem[len('dnsmasq-routlin-'):-len('.leases')]
|
||||
|
|
@ -95,12 +100,14 @@ def live_dhcp_leases():
|
|||
mac_norm = parts[1].lower()
|
||||
device_h = parts[3] if parts[3] != '*' else None
|
||||
res_h = mac_to_res.get(mac_norm)
|
||||
desc = mac_to_desc.get(mac_norm)
|
||||
desc_attr = f' data-hostname-desc="{e(desc)}"' if desc else ''
|
||||
if res_h and device_h and device_h.lower() != res_h.lower():
|
||||
hostname_html = f'<strong>{e(res_h)}</strong><br/>({e(device_h)})'
|
||||
hostname_html = f'<span{desc_attr}>{e(res_h)}<br/>({e(device_h)})</span>' if desc_attr else f'{e(res_h)}<br/>({e(device_h)})'
|
||||
elif res_h:
|
||||
hostname_html = f'<strong>{e(res_h)}</strong>'
|
||||
hostname_html = f'<span{desc_attr}>{e(res_h)}</span>' if desc_attr else e(res_h)
|
||||
elif device_h:
|
||||
hostname_html = e(device_h)
|
||||
hostname_html = f'<span{desc_attr}>{e(device_h)}</span>' if desc_attr else e(device_h)
|
||||
else:
|
||||
hostname_html = '-'
|
||||
rows.append({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue