Skip to content

Commit

Permalink
Services: Kea DHCP [new]: Leases DHCPv4 - deduplicate records. appara…
Browse files Browse the repository at this point in the history
…ntly kea leases from memory can be duplicated (see also https://gitlab.isc.org/isc-projects/kea/-/issues/2293), use the first two fields (ip+mac) to deduplicate them. closes #7136
  • Loading branch information
AdSchellevis committed Jan 24, 2024
1 parent b407f5e commit 41b3881
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/opnsense/scripts/dhcp/get_kea_leases.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@

result = {'records': []}
header = None
dedup_keys = set()
with open(filename, 'r') as csvfile:
for idx, record in enumerate(csv.reader(csvfile, delimiter=',', quotechar='"')):
rec_key = ','.join(record[:2])
if idx == 0:
header = record
elif header:
elif header and rec_key not in dedup_keys:
dedup_keys.add(rec_key)
named_record = {'if': None}
for findx, field in enumerate(record):
if findx < len(header):
Expand Down

0 comments on commit 41b3881

Please sign in to comment.