Skip to content

Commit

Permalink
🔌 Omada work #708
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Jul 6, 2024
1 parent 6db9cd2 commit 75bcf42
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def upgradeDB(self):
# -------------------------------------------------------------------------

# indicates, if CurrentScan table is available
# 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes
self.sql.execute("DROP TABLE IF EXISTS CurrentScan;")
self.sql.execute(""" CREATE TABLE IF NOT EXISTS CurrentScan (
cur_MAC STRING(50) NOT NULL COLLATE NOCASE,
Expand Down
19 changes: 10 additions & 9 deletions server/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,23 @@ def update_devices_data_from_scan (db):
SET dev_Vendor = (
SELECT cur_Vendor
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)
WHERE
(dev_Vendor IS NULL OR dev_Vendor IN ("", "null"))
AND EXISTS (
SELECT 1
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)""")

# Update only devices with empty or NULL dev_Network_Node_port
mylog('debug', '[Update Devices] - (if not empty) cur_Port -> dev_Network_Node_port')
sql.execute("""UPDATE Devices
SET dev_Network_Node_port = (
SELECT cur_Port
FROM CurrentScan
FROM CurrentScan
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)
WHERE EXISTS (
SELECT 1
Expand Down Expand Up @@ -328,14 +329,14 @@ def update_devices_data_from_scan (db):
SET dev_NetworkSite = (
SELECT cur_NetworkSite
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)
WHERE
(dev_NetworkSite IS NULL OR dev_NetworkSite IN ("", "null"))
AND EXISTS (
SELECT 1
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
AND CurrentScan.cur_NetworkSite IS NOT NULL AND CurrentScan.cur_NetworkSite NOT IN ("", "null")
)""")

Expand All @@ -345,14 +346,14 @@ def update_devices_data_from_scan (db):
SET dev_SSID = (
SELECT cur_SSID
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)
WHERE
(dev_SSID IS NULL OR dev_SSID IN ("", "null"))
AND EXISTS (
SELECT 1
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
AND CurrentScan.cur_SSID IS NOT NULL AND CurrentScan.cur_SSID NOT IN ("", "null")
)""")

Expand All @@ -362,14 +363,14 @@ def update_devices_data_from_scan (db):
SET dev_DeviceType = (
SELECT cur_Type
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
)
WHERE
(dev_DeviceType IS NULL OR dev_DeviceType IN ("", "null"))
AND EXISTS (
SELECT 1
FROM CurrentScan
WHERE dev_MAC = cur_MAC
WHERE Devices.dev_MAC = CurrentScan.cur_MAC
AND CurrentScan.cur_Type IS NOT NULL AND CurrentScan.cur_Type NOT IN ("", "null")
)""")

Expand Down
2 changes: 1 addition & 1 deletion server/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def setting_value_to_python_type(set_type, set_value):
elif set_type in ['integer.select', 'integer']:
value = int(set_value)
# belwo covers 'text.multiselect', 'list', 'subnets', 'list.select', 'list'
elif set_type in ['subnets' ] or 'list' in set_type:
elif set_type in ['subnets', 'text.multiselect' ] or 'list' in set_type:

mylog('debug', [f'[SETTINGS] Handling set_type: "{set_type}", set_value: "{set_value}"'])

Expand Down
2 changes: 1 addition & 1 deletion server/networkscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def process_scan (db):
skip_repeated_notifications (db)

# Clear current scan as processed
# TODO comment below for CurrentScan debugging
# 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes
db.sql.execute ("DELETE FROM CurrentScan")

# Commit changes
Expand Down

0 comments on commit 75bcf42

Please sign in to comment.