mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Small fix-ups to convert objects to dicts, update volume details at the appropriate time, and remove unnecessary required argument logic
This commit is contained in:
parent
19d99e0da6
commit
5ae50eb8cf
1 changed files with 5 additions and 12 deletions
|
@ -90,11 +90,6 @@ except ImportError:
|
|||
|
||||
def cloud_block_storage_attachments(module, state, volume, server, device,
|
||||
wait, wait_timeout):
|
||||
for arg in (state, volume, server, device):
|
||||
if not arg:
|
||||
module.fail_json(msg='%s is required for rax_cbs_attachments' %
|
||||
arg)
|
||||
|
||||
cbs = pyrax.cloud_blockstorage
|
||||
cs = pyrax.cloudservers
|
||||
|
||||
|
@ -133,7 +128,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
|
|||
not key.startswith('_')):
|
||||
instance[key] = value
|
||||
|
||||
result = dict(changed=changed, volume=instance)
|
||||
result = dict(changed=changed)
|
||||
|
||||
if volume.status == 'error':
|
||||
result['msg'] = '%s failed to build' % volume.id
|
||||
|
@ -142,6 +137,9 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
|
|||
pyrax.utils.wait_until(volume, 'status', 'in-use',
|
||||
interval=5, attempts=attempts)
|
||||
|
||||
volume.get()
|
||||
result['volume'] = rax_to_dict(volume)
|
||||
|
||||
if 'msg' in result:
|
||||
module.fail_json(**result)
|
||||
else:
|
||||
|
@ -167,12 +165,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
|
|||
elif volume.attachments:
|
||||
module.fail_json(msg='Volume is attached to another server')
|
||||
|
||||
for key, value in vars(volume).iteritems():
|
||||
if (isinstance(value, NON_CALLABLES) and
|
||||
not key.startswith('_')):
|
||||
instance[key] = value
|
||||
|
||||
result = dict(changed=changed, volume=instance)
|
||||
result = dict(changed=changed, volume=rax_to_dict(volume))
|
||||
|
||||
if volume.status == 'error':
|
||||
result['msg'] = '%s failed to build' % volume.id
|
||||
|
|
Loading…
Reference in a new issue