mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-26 03:19:48 +00:00
Provide update status through API
Give visibility into the process.
This commit is contained in:
parent
a40f015076
commit
eb3f5a8bbc
@ -18,6 +18,7 @@
|
||||
# provide managing firmware update process and firmware repository if/when
|
||||
# the time comes
|
||||
|
||||
import confluent.exceptions as exc
|
||||
import confluent.messages as msg
|
||||
import eventlet
|
||||
|
||||
@ -35,15 +36,17 @@ class Updater(object):
|
||||
def __init__(self, node, handler, filename, tenant=None, name=None):
|
||||
self.node = node
|
||||
self.phase = 'initializing'
|
||||
self.detail = ''
|
||||
self.percent = 0.0
|
||||
self.updateproc = eventlet.spawn(execupdate, handler, filename, self)
|
||||
if (node, tenant) not in updatesbytarget:
|
||||
updatesbytarget[(node, tenant)] = {}
|
||||
if name is None:
|
||||
name = 1
|
||||
while name in updatesbytarget[(node, tenant)]:
|
||||
while '{0}'.format(name) in updatesbytarget[(node, tenant)]:
|
||||
name += 1
|
||||
updatesbytarget[(node, tenant)][name] = self
|
||||
self.name = '{0}'.format(name)
|
||||
updatesbytarget[(node, tenant)][self.name] = self
|
||||
|
||||
def handle_progress(self, progress):
|
||||
self.phase = progress['phase']
|
||||
@ -56,7 +59,18 @@ class Updater(object):
|
||||
'detail': self.detail}
|
||||
|
||||
|
||||
def list_updates(nodes, tenant=None):
|
||||
def list_updates(nodes, tenant, element):
|
||||
showmode = False
|
||||
if len(element) > 4:
|
||||
showmode = True
|
||||
upid = element[-1]
|
||||
for node in nodes:
|
||||
for updateid in updatesbytarget.get((node, None), {}):
|
||||
yield msg.ChildCollection(updateid)
|
||||
if showmode:
|
||||
try:
|
||||
updater = updatesbytarget[(node, tenant)][upid]
|
||||
except KeyError:
|
||||
raise exc.NotFoundException('No matching update process found')
|
||||
yield msg.KeyValueData(updater.progress, name=node)
|
||||
else:
|
||||
for updateid in updatesbytarget.get((node, tenant), {}):
|
||||
yield msg.ChildCollection(updateid)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Copyright 2014 IBM Corporation
|
||||
# Copyright 2015-2016 Lenovo
|
||||
# Copyright 2015-2017 Lenovo
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -433,8 +433,12 @@ class IpmiHandler(object):
|
||||
raise Exception('Not Implemented')
|
||||
|
||||
def handle_update(self):
|
||||
firmwaremanager.Updater(self.node, self.ipmicmd.update_firmware,
|
||||
self.inputdata.filename, self.tenant)
|
||||
u = firmwaremanager.Updater(self.node, self.ipmicmd.update_firmware,
|
||||
self.inputdata.filename, self.tenant)
|
||||
self.output.put(
|
||||
msg.CreatedResource(
|
||||
'nodes/{0}/inventory/firmware/updates/active/{1}'.format(
|
||||
self.node, u.name)))
|
||||
|
||||
|
||||
def handle_configuration(self):
|
||||
@ -970,14 +974,11 @@ def update(nodes, element, configmanager, inputdata):
|
||||
return create(nodes, element, configmanager, inputdata)
|
||||
|
||||
|
||||
def list_active_updates(nodes, configmanager):
|
||||
raise Exception('Not Implemented')
|
||||
|
||||
|
||||
def retrieve(nodes, element, configmanager, inputdata):
|
||||
initthread()
|
||||
if '/'.join(element).startswith('inventory/firmware/updates/active'):
|
||||
return firmwaremanager.list_updates(nodes, configmanager.tenant)
|
||||
return firmwaremanager.list_updates(nodes, configmanager.tenant,
|
||||
element)
|
||||
else:
|
||||
return perform_requests('read', nodes, element, configmanager, inputdata)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user