2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Add access to nodefirmware shortcut

The nodefirmware can now request firmware more selectively.
This commit is contained in:
Jarrod Johnson 2018-02-14 14:38:20 -05:00
parent 453f6d8016
commit 0fd2d26f82
2 changed files with 26 additions and 18 deletions

View File

@ -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 <noderange> [update [--backup <file>]")
usage="Usage: %prog <noderange> [update [--backup <file>]]|[<components>]")
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:

View File

@ -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(