From 481a70c304c574cc0eae1c4ed2858306299d7265 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 24 Feb 2021 16:39:01 -0500 Subject: [PATCH] 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