From 327a45ef333bb8b738ed48483c41207f0d2686fd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 3 Nov 2022 10:49:58 -0400 Subject: [PATCH] WIP toward rescan hitting the renotify on subscripbed switches --- confluent_server/confluent/core.py | 3 ++- confluent_server/confluent/discovery/core.py | 9 ++++++++- .../confluent/plugins/hardwaremanagement/affluent.py | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 604bb20e..1952e562 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -138,6 +138,7 @@ def load_plugins(): plugins.clear() # restore path to not include the plugindir sys.path.pop(1) + disco.register_affluent(pluginmap['affluent']) def _register_resource(plugin): @@ -1239,7 +1240,7 @@ def handle_path(path, operation, configmanager, inputdata=None, autostrip=True): operation, pathcomponents, autostrip) elif pathcomponents[0] == 'discovery': return disco.handle_api_request( - configmanager, inputdata, operation, pathcomponents, pluginmap['affluent']) + configmanager, inputdata, operation, pathcomponents) elif pathcomponents[0] == 'networking': return macmap.handle_api_request( configmanager, inputdata, operation, pathcomponents) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 59fd44e4..a7cef05e 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -186,6 +186,10 @@ pending_nodes = {} pending_by_uuid = {} +def register_affluent(affluenthdl): + global affluent + affluent = affluenthdl + def enrich_pxe_info(info): sn = None mn = None @@ -438,7 +442,7 @@ def save_subscriptions(subs): with open('/etc/confluent/discovery_subscriptions.json', 'w') as dso: dso.write(json.dumps(subs)) -def handle_api_request(configmanager, inputdata, operation, pathcomponents, affluent=None): +def handle_api_request(configmanager, inputdata, operation, pathcomponents): if pathcomponents == ['discovery', 'autosense']: return handle_autosense_config(operation, inputdata) if operation == 'retrieve' and pathcomponents[:2] == ['discovery', 'subscriptions']: @@ -1446,6 +1450,9 @@ def rescan(): return else: scanner = eventlet.spawn(blocking_scan) + for remagent in get_subscriptions(): + affluent. + def blocking_scan(): diff --git a/confluent_server/confluent/plugins/hardwaremanagement/affluent.py b/confluent_server/confluent/plugins/hardwaremanagement/affluent.py index b0501339..3de25907 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/affluent.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/affluent.py @@ -54,6 +54,12 @@ class WebClient(object): return rsp +def renotify_me(node, configmanager, myname): + creds = configmanager.get_node_attributes( + node, ['secret.hardwaremanagementuser', 'secret.hardwaremanagementpassword'], decrypt=True) + wc = WebClient(node, configmanager, creds) + wc.wc.grab_json_response('/affluent/cert_authorities/{0}'.format(myname), cacert) + def subscribe_discovery(node, configmanager, myname): creds = configmanager.get_node_attributes( node, ['secret.hardwaremanagementuser', 'secret.hardwaremanagementpassword'], decrypt=True)