From b982f3f4c2652fbc9cd6ab7920e900d20e0b3d32 Mon Sep 17 00:00:00 2001 From: Marek Kwaczynski Date: Fri, 8 Aug 2025 13:51:19 +0200 Subject: [PATCH] cloud_discovery: Track and persist discovery method Adds support for recording the method used to discover the cloud controller (e.g. DHCP, FLASH, OpenLAN). The selected method records the current date and time along with the discovery method into "/etc/ucentral/discovery.state.json". The date is stored in epoch format. Fixed: WIFI-14966 Signed-off-by: Marek Kwaczynski --- .../files/usr/bin/cloud_discovery | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery b/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery index c3d7f4b1c..efb90c0da 100755 --- a/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery +++ b/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery @@ -15,9 +15,14 @@ const ONLINE = 2; const OFFLINE = 3; const ORPHAN = 4; +const DISCOVER_DHCP = "DHCP"; +const DISCOVER_FLASH = "FLASH"; +const DISCOVER_LOOKUP = "OpenLAN"; + let ubus = libubus.connect(); let uci = libuci.cursor(); let state = DISCOVER; +let discovery_method = ""; let validate_time; let offline_time; let orphan_time; @@ -78,6 +83,14 @@ function gateway_load() { return readjsonfile('/etc/ucentral/gateway.json'); } +function discovery_state_write() { + let discovery_state = { + "type": discovery_method, + "updated": time() + }; + fs.writefile('/etc/ucentral/discovery.state.json', discovery_state); +} + function gateway_write(data) { let gateway = gateway_load(); gateway ??= {}; @@ -130,6 +143,7 @@ function set_state(set) { if (prev == VALIDATING) { ulog(LOG_INFO, 'Setting cloud controller to validated\n'); gateway_write({ valid: true }); + discovery_state_write(); } break; @@ -227,15 +241,18 @@ function interval_handler() { if (!time_is_valid()) return; + discovery_method = DISCOVER_DHCP; if (discover_dhcp()) return; if (system('/usr/bin/est_client enroll')) return; + discovery_method = DISCOVER_FLASH; if (!discover_flash()) return; + discovery_method = DISCOVER_LOOKUP; redirector_lookup(); break;