Small fix-ups to convert objects to dicts, update volume details at the appropriate time, and remove unnecessary required argument logic

pull/18777/head
Matt Martz 10 years ago committed by Matt Clay
parent 19d99e0da6
commit 5ae50eb8cf

@ -90,11 +90,6 @@ except ImportError:
def cloud_block_storage_attachments(module, state, volume, server, device, def cloud_block_storage_attachments(module, state, volume, server, device,
wait, wait_timeout): 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 cbs = pyrax.cloud_blockstorage
cs = pyrax.cloudservers cs = pyrax.cloudservers
@ -133,7 +128,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
not key.startswith('_')): not key.startswith('_')):
instance[key] = value instance[key] = value
result = dict(changed=changed, volume=instance) result = dict(changed=changed)
if volume.status == 'error': if volume.status == 'error':
result['msg'] = '%s failed to build' % volume.id 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', pyrax.utils.wait_until(volume, 'status', 'in-use',
interval=5, attempts=attempts) interval=5, attempts=attempts)
volume.get()
result['volume'] = rax_to_dict(volume)
if 'msg' in result: if 'msg' in result:
module.fail_json(**result) module.fail_json(**result)
else: else:
@ -167,12 +165,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device,
elif volume.attachments: elif volume.attachments:
module.fail_json(msg='Volume is attached to another server') module.fail_json(msg='Volume is attached to another server')
for key, value in vars(volume).iteritems(): result = dict(changed=changed, volume=rax_to_dict(volume))
if (isinstance(value, NON_CALLABLES) and
not key.startswith('_')):
instance[key] = value
result = dict(changed=changed, volume=instance)
if volume.status == 'error': if volume.status == 'error':
result['msg'] = '%s failed to build' % volume.id result['msg'] = '%s failed to build' % volume.id

Loading…
Cancel
Save