From 6e26b19c6783be88b37da71c9e56c94db8e95401 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 4 Apr 2019 09:49:02 -0400 Subject: [PATCH] Autofill collective.manager on discovery if not set To improve the ease of use, if an administrator has a collective but does not designate a collective.manager for a node being discovered, default to the collective member that executes the discovery. --- confluent_server/confluent/discovery/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 0b445d64..10db839b 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -63,6 +63,7 @@ import base64 import confluent.config.configmanager as cfm +import confluent.collective.manager as collective import confluent.discovery.protocols.pxe as pxe #import confluent.discovery.protocols.ssdp as ssdp import confluent.discovery.protocols.slp as slp @@ -1055,6 +1056,14 @@ def discover_node(cfg, handler, info, nodename, manual): traceback.print_exc() return False newnodeattribs = {} + if cfm.list_collective(): + # We are in a collective, check collective.manager + cmc = cfg.get_node_attributes(nodename, 'collective.manager') + cm = cmc.get(nodename, {}).get('collective.manager', {}).get('value', None) + if not cm: + # Node is being discovered in collective, but no collective.manager, default + # to the collective member actually able to execute the discovery + newnodeattribs['collective.manager'] = collective.get_myname() if 'uuid' in info: newnodeattribs['id.uuid'] = info['uuid'] if 'serialnumber' in info: