From 2e059b5887ef5d05b920b6085502c8b1eabc7209 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 23 Jan 2023 11:47:33 -0500 Subject: [PATCH] Make an API for getting full discovery data in one fetch This makes for faster nodediscover being possible, also makes web management of the data easier --- confluent_server/confluent/discovery/core.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index ddbec819..d2f73555 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -359,6 +359,14 @@ def show_info(mac): for i in send_discovery_datum(known_info[mac]): yield i +def dump_discovery(): + infobymac = {} + for mac in known_info: + infobymac[mac] = {} + for i in send_discovery_datum(known_info[mac]): + for kn in i.kvpairs: + infobymac[mac][kn] = i.kvpairs[kn] + yield msg.KeyValueData(infobymac) list_info = { 'by-node': list_matching_nodes, @@ -602,11 +610,14 @@ def handle_read_api_request(pathcomponents): # starting at 2 are parameters to previous index if pathcomponents == ['discovery', 'rescan']: return (msg.KeyValueData({'scanning': bool(scanner)}),) + if pathcomponents == ['discovery', 'alldata']: + return dump_discovery() subcats, queryparms, indexof, coll = _parameterize_path(pathcomponents[1:]) if len(pathcomponents) == 1: dirlist = [msg.ChildCollection(x + '/') for x in sorted(list(subcats))] dirlist.append(msg.ChildCollection('rescan')) dirlist.append(msg.ChildCollection('autosense')) + dirlist.append(msg.ChildCollection('alldata')) dirlist.append(msg.ChildCollection('subscriptions/')) return dirlist if not coll: