Name matching fixes 🩹

This commit is contained in:
Jokob-sk
2023-11-04 12:06:12 +11:00
parent c8e494596e
commit 973cd60893
7 changed files with 190 additions and 102 deletions

View File

@@ -247,6 +247,8 @@ def update_devices_names (db):
recordsToUpdate = []
recordsNotFound = []
nameNotFound = "(name not found)"
ignored = 0
notFound = 0
@@ -274,30 +276,34 @@ def update_devices_names (db):
mylog('verbose', ['[Update Device Name] Pholus entries from prev scans: ', len(pholusResults)])
for device in unknownDevices:
newName = -1
newName = nameNotFound
# Resolve device name with DiG
newName = resolve_device_name_dig (device['dev_MAC'], device['dev_LastIP'])
# count
if newName != -1:
if newName != nameNotFound:
foundDig += 1
# Resolve with Pholus
if newName == -1:
newName = resolve_device_name_pholus (device['dev_MAC'], device['dev_LastIP'], pholusResults)
if newName == nameNotFound:
newName = resolve_device_name_pholus (device['dev_MAC'], device['dev_LastIP'], pholusResults, nameNotFound, False)
# Try IP matching only
if newName == nameNotFound:
newName = resolve_device_name_pholus (device['dev_MAC'], device['dev_LastIP'], pholusResults, nameNotFound, True)
# count
if newName != -1:
if newName != nameNotFound:
foundPholus += 1
# isf still not found update name so we can distinguish the devices where we tried already
if newName == -1 :
if newName == nameNotFound :
# if dev_Name is the same as what we will change it to, take no action
# this mitigates a race condition which would overwrite a users edits that occured since the select earlier
if device['dev_Name'] != "(name not found)":
if device['dev_Name'] != nameNotFound:
recordsNotFound.append (["(name not found)", device['dev_MAC']])
else:
# name wa sfound with DiG or Pholus
# name was found with DiG or Pholus
recordsToUpdate.append ([newName, device['dev_MAC']])
# Print log