Fix disk deleting logic for permanently deleting from recycle bin
This commit is contained in:
@@ -520,6 +520,9 @@ def main():
|
|||||||
elif decon.disk_info['status'] == "DELETED":
|
elif decon.disk_info['status'] == "DELETED":
|
||||||
if amodule.params['state'] in ('present'):
|
if amodule.params['state'] in ('present'):
|
||||||
decon.action(restore=True)
|
decon.action(restore=True)
|
||||||
|
elif (amodule.params['state'] == 'absent' and
|
||||||
|
amodule.params['permanently']):
|
||||||
|
decon.delete()
|
||||||
else:
|
else:
|
||||||
decon.nop()
|
decon.nop()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -2859,10 +2859,18 @@ class DecortController(object):
|
|||||||
return 0, None
|
return 0, None
|
||||||
elif name:
|
elif name:
|
||||||
if account_id:
|
if account_id:
|
||||||
api_params = dict(accountId=account_id,name=name)
|
api_params = {
|
||||||
|
'accountId': account_id,
|
||||||
|
'name': name,
|
||||||
|
'show_all': True
|
||||||
|
}
|
||||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/search", api_params)
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/search", api_params)
|
||||||
|
disks_list = api_resp.json()
|
||||||
|
# Filtering disks by status
|
||||||
|
excluded_statuses = ('PURGED', 'DESTROYED')
|
||||||
|
filter_f = lambda x: x.get('status') not in excluded_statuses
|
||||||
|
disks_list = [d for d in disks_list if filter_f(d)]
|
||||||
# the above call may return more than one matching disk
|
# the above call may return more than one matching disk
|
||||||
disks_list = json.loads(api_resp.content.decode('utf8'))
|
|
||||||
if len(disks_list) == 0:
|
if len(disks_list) == 0:
|
||||||
return 0, None
|
return 0, None
|
||||||
elif len(disks_list) > 1:
|
elif len(disks_list) > 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user