From 587197e9345263617364c58184e4dbf9c5d38948 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 2 Oct 2020 11:45:50 -0400 Subject: [PATCH] Refresh chained SMM discovery for SMMv2 Additionally, amend overall discovery to force chain validation rather than theoretically accepting a low mac count match. --- confluent_server/confluent/discovery/core.py | 12 +++++++++++- confluent_server/confluent/networking/lldp.py | 9 ++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 9d436427..862b88f2 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -772,12 +772,14 @@ def get_chained_smm_name(nodename, cfg, handler, nl=None, checkswitch=True): 'extend a single enclosure') cd = cfg.get_node_attributes(nodename, ['hardwaremanagement.manager', 'pubkeys.tls_hardwaremanager']) - smmaddr = cd[nodename]['hardwaremanagement.manager']['value'] pkey = cd[nodename].get('pubkeys.tls_hardwaremanager', {}).get( 'value', None) if not pkey: # We cannot continue through a break in the chain return None, False + smmaddr = cd.get(nodename, {}).get('hardwaremanagement.manager', {}.get('value', None) + if not smmaddr: + return None, False if pkey: cv = util.TLSCertVerifier( cfg, nodename, 'pubkeys.tls_hardwaremanager').verify_cert @@ -855,6 +857,14 @@ def get_nodename(cfg, handler, info): # while this started by switch, it was disambiguated info['verified'] = v return newnodename, None + else: + errorstr = 'Attempt to discover SMM in chain but ' + 'unable to follow chain to the specific ' + 'SMM, it may be waiting on an upstream ' + 'SMM, 'chain starts with {0}'.format( + nodename) + log.log({'error': errorstr}) + return None, None if (nodename and not handler.discoverable_by_switch(macinfo['maccount'])): if handler.devname == 'SMM': diff --git a/confluent_server/confluent/networking/lldp.py b/confluent_server/confluent/networking/lldp.py index dc1b3e32..910bb7de 100644 --- a/confluent_server/confluent/networking/lldp.py +++ b/confluent_server/confluent/networking/lldp.py @@ -148,11 +148,10 @@ def get_fingerprint(switch, port, configmanager, portmatch): def _extract_extended_desc(info, source, integritychecked): source = str(source) info['verified'] = bool(integritychecked) - if source.startswith('Lenovo SMM;'): - info['peerdescription'] = 'Lenovo SMM' - if ';S2=' in source: - info['peersha256fingerprint'] = source.replace('Lenovo SMM;S2=', - '') + if source.startswith('Lenovo ') and ';S2=' in source: + desc, fprint = source.split(';S2=', 1) + info['peerdescription'] = desc + info['peersha256fingerprint'] = fprint else: info['peerdescription'] = source