From 0fd2d26f820062b70c448ebd51033bf264681382 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Feb 2018 14:38:20 -0500 Subject: [PATCH] Add access to nodefirmware shortcut The nodefirmware can now request firmware more selectively. --- confluent_client/bin/nodefirmware | 38 +++++++++++-------- .../plugins/hardwaremanagement/ipmi.py | 6 ++- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/confluent_client/bin/nodefirmware b/confluent_client/bin/nodefirmware index 61e7a2f9..a151ba8d 100755 --- a/confluent_client/bin/nodefirmware +++ b/confluent_client/bin/nodefirmware @@ -64,9 +64,10 @@ def printfirm(node, prefix, data): version = ' '.join(builddesc) print('{0}: {1}: {2}'.format(node, prefix, version)) +components = ['all'] argparser = optparse.OptionParser( - usage="Usage: %prog [update [--backup ]") + usage="Usage: %prog [update [--backup ]]|[]") argparser.add_option('-b', '--backup', action='store_true', help='Target a backup bank rather than primary') (options, args) = argparser.parse_args() @@ -74,10 +75,13 @@ upfile = None try: noderange = args[0] if len(args) > 1: - if args[1] != 'update': - argparser.print_help() - sys.exit(1) - upfile = args[2] + if args[1] == ['update']: + upfile = args[2] + else: + components = [] + for arg in args[1:]: + components += arg.split(',') + except IndexError: argparser.print_help() sys.exit(1) @@ -135,18 +139,20 @@ def update_firmware(session, filename): sys.stderr.write('{0}: {1}\n'.format(node, noderrs[node])) def show_firmware(session): - for res in session.read('/noderange/{0}/inventory/firmware/all/all'.format( - noderange)): - printerror(res) - if 'databynode' not in res: - continue - for node in res['databynode']: - printerror(res['databynode'][node], node) - if 'firmware' not in res['databynode'][node]: + for component in components: + for res in session.read( + '/noderange/{0}/inventory/firmware/all/{1}'.format( + noderange, component)): + printerror(res) + if 'databynode' not in res: continue - for inv in res['databynode'][node]['firmware']: - for prefix in inv: - printfirm(node, prefix, inv[prefix]) + for node in res['databynode']: + printerror(res['databynode'][node], node) + if 'firmware' not in res['databynode'][node]: + continue + for inv in res['databynode'][node]['firmware']: + for prefix in inv: + printfirm(node, prefix, inv[prefix]) try: diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 38845ec2..0750694a 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -745,8 +745,10 @@ class IpmiHandler(object): items = [] errorneeded = False try: - for id, data in self.ipmicmd.get_firmware(): - if component == 'all' or component == simplify_name(id): + complist = () if component == 'all' else (component,) + for id, data in self.ipmicmd.get_firmware(complist): + if (component in ('core', 'all') or + component == simplify_name(id)): items.append({id: data}) except ssl.SSLEOFError: errorneeded = msg.ConfluentNodeError(