2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-04-13 16:57:59 +00:00

Merge branch 'master' of github.com:jjohnson42/confluent

This commit is contained in:
Jarrod Johnson 2017-08-22 16:50:20 -04:00
commit d1bafa98bb
6 changed files with 17 additions and 7 deletions

View File

@ -460,7 +460,7 @@ def createresource(args):
if keydata is None:
return
targpath = fullpath_target(resname)
if targpath.startswitch('/noderange//'):
if targpath.startswith('/noderange//'):
collection = targpath
else:
collection, _, resname = targpath.rpartition('/')

View File

@ -66,7 +66,9 @@ def printfirm(node, prefix, data):
argparser = optparse.OptionParser(
usage="Usage: %prog <noderange> [update <file>]")
usage="Usage: %prog <noderange> [update [--backup <file>]")
argparser.add_option('-b', '--backup', action='store_true',
help='Target a backup bank rather than primary')
(options, args) = argparser.parse_args()
upfile = None
try:
@ -98,7 +100,10 @@ def update_firmware(session, filename):
filename = os.path.abspath(filename)
resource = '/noderange/{0}/inventory/firmware/updates/active'.format(
noderange)
for res in session.create(resource, {'filename': filename}):
upargs = {'filename': filename}
if options.backup:
upargs['bank'] = 'bank'
for res in session.create(resource, upargs):
watchurl = res['created']
currnode = watchurl.split('/')[1]
nodeurls[currnode] = '/' + watchurl

View File

@ -4,7 +4,7 @@ nodefirmware(8) -- Report firmware information on confluent nodes
## SYNOPSIS
`nodefirmware <noderange>`
`nodefirmware <noderange> update <filename>`
`nodefirmware <noderange> update [--backup] <filename>`
## DESCRIPTION

View File

@ -26,7 +26,8 @@ updatesbytarget = {}
def execupdate(handler, filename, updateobj):
try:
completion = handler(filename, progress=updateobj.handle_progress)
completion = handler(filename, progress=updateobj.handle_progress,
bank=updateobj.bank)
if completion is None:
completion = 'complete'
updateobj.handle_progress({'phase': completion, 'progress': 100.0})
@ -35,7 +36,9 @@ def execupdate(handler, filename, updateobj):
'detail': str(e)})
class Updater(object):
def __init__(self, node, handler, filename, tenant=None, name=None):
def __init__(self, node, handler, filename, tenant=None, name=None,
bank=None):
self.bank = bank
self.node = node
self.phase = 'initializing'
self.detail = ''

View File

@ -399,6 +399,7 @@ class InputFirmwareUpdate(ConfluentMessage):
def __init__(self, path, nodes, inputdata):
self.filename = inputdata['filename']
self.bank = inputdata.get('bank', None)
self.nodes = nodes

View File

@ -455,7 +455,8 @@ class IpmiHandler(object):
def handle_update(self):
u = firmwaremanager.Updater(self.node, self.ipmicmd.update_firmware,
self.inputdata.filename, self.tenant)
self.inputdata.filename, self.tenant,
bank=self.inputdata.bank)
self.output.put(
msg.CreatedResource(
'nodes/{0}/inventory/firmware/updates/active/{1}'.format(