From fa3a402708f2f3d8e2285f373350cf4ef160dd00 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 12 Apr 2016 15:18:31 -0400 Subject: [PATCH] Provide some shortcuts for nodelist Allow nodelist to request view of a category at a time. Also recognize 'hm' as shorthand for 'hardwaremanagement'. --- confluent_client/bin/nodelist | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodelist b/confluent_client/bin/nodelist index fdd354f7..14b3fc87 100644 --- a/confluent_client/bin/nodelist +++ b/confluent_client/bin/nodelist @@ -27,6 +27,20 @@ if path.startswith('/opt'): sys.path.append(path) import confluent.client as client + + +def attrrequested(attr, attrlist, seenattributes): + for candidate in attrlist: + truename = candidate + if candidate.startswith('hm'): + candidate = candidate.replace('hm', 'hardwaremanagement', 1) + if candidate == attr: + seenattributes.add(truename) + return True + elif '.' not in candidate and attr.startswith(candidate + '.'): + seenattributes.add(truename) + return True + return False argparser = optparse.OptionParser( usage="Usage: %prog [options] noderange [list of attributes") argparser.add_option('-b', '--blame', action='store_true', @@ -50,7 +64,7 @@ if len(args) > 1: for attr in res['databynode'][node]: seenattributes.add(attr) currattr = res['databynode'][node][attr] - if attr in args[1:]: + if attrrequested(attr, args[1:], seenattributes): if 'value' in currattr: if currattr['value'] is not None: attrout = '{0}: {1}: {2}'.format(