2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-29 04:50:21 +00:00

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
This commit is contained in:
Jarrod Johnson 2023-01-23 11:47:33 -05:00
parent 792e6472e4
commit 2e059b5887

View File

@ -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: