From 368666823faf0d83c8ec73e53b6a2ee8955a9e06 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 15 Sep 2017 12:00:10 -0400 Subject: [PATCH] Modify get_nodename to search by uuid Instead of *just* being able to search by uuid for pxe, add the ability to search by uuid for https things, if no fingerprint match. This allows remote xcc setup to follow in the wake of a pxe attempt. --- confluent_server/confluent/discovery/core.py | 33 +++++++++----------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index f15cb31f..fd69b28a 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -613,25 +613,22 @@ def detected(info): def get_nodename(cfg, handler, info): - if not handler.https_supported: - curruuid = info['uuid'] - nodename = nodes_by_uuid.get(curruuid, None) - if nodename is None: - _map_unique_ids() - nodename = nodes_by_uuid.get(curruuid, None) - if nodename is None: - # TODO: if there are too many matches on port for a - # given type, error! Can't just arbitarily limit, - # shared nic with vms is possible and valid - nodename = macmap.find_node_by_mac(info['hwaddr'], cfg) - return nodename - currcert = handler.https_cert - if not currcert: - info['discofailure'] = 'nohttps' - return None - currprint = util.get_fingerprint(currcert) - nodename = nodes_by_fprint.get(currprint, None) + nodename = None + if handler.https_supported: + currcert = handler.https_cert + if not currcert: + info['discofailure'] = 'nohttps' + return None + currprint = util.get_fingerprint(currcert) + nodename = nodes_by_fprint.get(currprint, None) if not nodename: + curruuid = info.get('uuid', None) + if uuid_is_valid(curruuid): + nodename = nodes_by_uuid.get(curruuid, None) + if nodename is None: + _map_unique_ids() + nodename = nodes_by_uuid.get(curruuid, None) + if not nodename: # as a last resort, search switch for info nodename = macmap.find_node_by_mac(info['hwaddr'], cfg) return nodename