2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-06-19 01:50:46 +00:00

Provide support for removing update

This allows for cancelling and cleanup after reporting.
This commit is contained in:
Jarrod Johnson
2017-07-26 14:10:04 -04:00
parent eb3f5a8bbc
commit b5f016ad50
2 changed files with 22 additions and 0 deletions
@@ -53,12 +53,31 @@ class Updater(object):
self.percent = float(progress['progress'])
self.detail = progress.get('detail', '')
def cancel(self):
self.updateproc.kill()
@property
def progress(self):
return {'phase': self.phase, 'progress': self.percent,
'detail': self.detail}
def remove_updates(nodes, tenant, element):
if len(element) < 5:
raise exc.InvalidArgumentException()
upid = element[-1]
for node in nodes:
try:
upd = updatesbytarget[(node, tenant)][upid]
except KeyError:
raise exc.NotFoundException('No active update matches request')
upd.cancel()
del updatesbytarget[(node, tenant)][upid]
yield msg.DeletedResource(
'nodes/{0}/inventory/firmware/updates/active/{1}'.format(
node, upid))
def list_updates(nodes, tenant, element):
showmode = False
if len(element) > 4:
@@ -984,5 +984,8 @@ def retrieve(nodes, element, configmanager, inputdata):
def delete(nodes, element, configmanager, inputdata):
initthread()
if '/'.join(element).startswith('inventory/firmware/updates/active'):
return firmwaremanager.remove_updates(nodes, configmanager.tenant,
element)
return perform_requests(
'delete', nodes, element, configmanager, inputdata)