2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-03-19 01:47:45 +00:00

Add ability to clear upload progress tracking

Remote media uploads could not be cleared, add the ability to do so.
This commit is contained in:
Jarrod Johnson 2017-12-08 18:58:04 -05:00
parent 6845f64d46
commit 0d40a0cac6
2 changed files with 11 additions and 4 deletions

View File

@ -83,17 +83,21 @@ class Updater(object):
'detail': self.detail}
def remove_updates(nodes, tenant, element):
if len(element) < 5:
def remove_updates(nodes, tenant, element, type='firmware'):
if len(element) < 5 and element[:2] != ['media', 'uploads']:
raise exc.InvalidArgumentException()
upid = element[-1]
if type == 'firmware':
myparty = updatesbytarget
else:
myparty = uploadsbytarget
for node in nodes:
try:
upd = updatesbytarget[(node, tenant)][upid]
upd = myparty[(node, tenant)][upid]
except KeyError:
raise exc.NotFoundException('No active update matches request')
upd.cancel()
del updatesbytarget[(node, tenant)][upid]
del myparty[(node, tenant)][upid]
yield msg.DeletedResource(
'nodes/{0}/inventory/firmware/updates/active/{1}'.format(
node, upid))

View File

@ -1057,5 +1057,8 @@ def delete(nodes, element, configmanager, inputdata):
if '/'.join(element).startswith('inventory/firmware/updates/active'):
return firmwaremanager.remove_updates(nodes, configmanager.tenant,
element)
elif '/'.join(element).startswith('media/uploads'):
return firmwaremanager.remove_updates(nodes, configmanager.tenant,
element, type='mediaupload')
return perform_requests(
'delete', nodes, element, configmanager, inputdata)