cloudstack: cs_volume: simplify detach on state=absent

reviewable/pr18780/r1
Rene Moser 9 years ago
parent c6829752d8
commit 56fb7abc65
No known key found for this signature in database
GPG Key ID: 8306965BE6D6331D

@ -392,18 +392,15 @@ class AnsibleCloudStackVolume(AnsibleCloudStack):
volume = self.get_volume()
if volume:
if 'attached' in volume:
if self.module.param.get('force'):
self.detached_volume()
else:
self.module.fail_json(msg="Volume '%s' is attached, use force=true for detaching and removing the volume." % volume.get('name'))
if 'attached' in volume and not self.module.param.get('force'):
self.module.fail_json(msg="Volume '%s' is attached, use force=true for detaching and removing the volume." % volume.get('name'))
self.result['changed'] = True
if not self.module.check_mode:
volume = self.detached_volume()
res = self.cs.deleteVolume(id=volume['id'])
if 'errortext' in volume:
if 'errortext' in res:
self.module.fail_json(msg="Failed: '%s'" % res['errortext'])
poll_async = self.module.params.get('poll_async')
if poll_async:

Loading…
Cancel
Save