From 481a70c304c574cc0eae1c4ed2858306299d7265 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 24 Feb 2021 16:39:01 -0500 Subject: [PATCH 1/4] Fix traceback when multiple criteria have no matches When a parent criteria has no match, then the api returns a 404 as there is no parent. Handle this by only listing positively matched items. --- confluent_client/bin/nodediscover | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index 257b0fcb..947ca914 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -263,7 +263,11 @@ def list_matching_macs(options, session, node=None, checknode=True): return [options.mac.replace(':', '-')] else: path += 'by-mac/' - return [x['item']['href'] for x in session.read(path)] + ret = [] + for x in session.read(path): + if 'item' in x and 'href' in x['item']: + ret.append(x['item', 'href']) + return ret def assign_discovery(options, session, needid=True): abort = False From 0fbe39690e21825c29d7a22a5a6860bf964f42cf Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 26 Feb 2021 12:39:13 -0500 Subject: [PATCH 2/4] Improve concurrency of SLP During a scan, unicast TCP interrogation of candidates was done serially. Do this concurrently so that poorly behaving targets do not prolong a scan. --- confluent_server/confluent/discovery/protocols/slp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/discovery/protocols/slp.py b/confluent_server/confluent/discovery/protocols/slp.py index a2c8a220..e5ef080f 100644 --- a/confluent_server/confluent/discovery/protocols/slp.py +++ b/confluent_server/confluent/discovery/protocols/slp.py @@ -19,6 +19,7 @@ import confluent.util as util import confluent.log as log import os import random +import eventlet.greenpool import eventlet.green.select as select import eventlet.green.socket as socket import struct @@ -590,6 +591,8 @@ def scan(srvtypes=_slp_services, addresses=None, localonly=False): # reduced chance of many responses overwhelming receive buffer. _grab_rsps((net, net4), rsps, 1, xidmap) # now to analyze and flesh out the responses + handleids = set([]) + gp = eventlet.greenpool.GreenPool(128) for id in rsps: for srvurl in rsps[id].get('urls', ()): if len(srvurl) > 4: @@ -604,7 +607,10 @@ def scan(srvtypes=_slp_services, addresses=None, localonly=False): break else: continue - _add_attributes(rsps[id]) + gp.spawn_n(_add_attributes, rsps[id]) + handleids.add(id) + gp.waitall() + for id in handleids: if 'service:lighttpd' in rsps[id]['services']: currinf = rsps[id] curratt = currinf.get('attributes', {}) From e24852c480c9adb15c7efc4db283a159735ad92f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 27 Feb 2021 20:53:33 -0500 Subject: [PATCH 3/4] Fix chained discovery of DWC SMMv2 SMMv2 for DWC has more ports. Make the code not care about which port is which for checking for matching smm fingerprints. --- confluent_server/confluent/discovery/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index ff1350cd..461ce8bb 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -814,10 +814,10 @@ def get_smm_neighbor_fingerprints(smmaddr, cv): neighs = wc.grab_json_response('/scripts/neighdata.json') if not neighs: return - for idx in (4, 5): - if 'sha256' not in neighs[idx]: + for neigh in neighs: + if 'sha256' not in neigh: continue - yield 'sha256$' + b64tohex(neighs[idx]['sha256']) + yield 'sha256$' + b64tohex(neigh['sha256']) def get_nodename(cfg, handler, info): From f176ebe4c2b6f0a02e3cdb0651d14f97464ace60 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 1 Mar 2021 10:31:28 -0500 Subject: [PATCH 4/4] Fix typo in confluentdbutil The restore function would fail to chown directories due to typo --- confluent_server/bin/confluentdbutil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confluent_server/bin/confluentdbutil b/confluent_server/bin/confluentdbutil index 884a1b8f..be35e5aa 100755 --- a/confluent_server/bin/confluentdbutil +++ b/confluent_server/bin/confluentdbutil @@ -74,7 +74,7 @@ if args[0] == 'restore': for targdir in os.walk('/etc/confluent'): os.chown(targdir[0], owner, group) for f in targdir[2]: - os.chown(os.patht.join(targdir[0], f), owner, group) + os.chown(os.path.join(targdir[0], f), owner, group) except Exception as e: print(str(e)) sys.exit(1)