1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

VMware: report failure if no snapshot exists on VM (#38651)

This fix add correct reporting of failure if VM does not contain
any snapshots for following operations - rename, remove and revert.

Fixes: #37906

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-05-07 12:41:49 +05:30 committed by ansibot
parent 1c8a7d06e5
commit d839746123

View file

@ -279,7 +279,7 @@ class PyVmomiHelper(PyVmomi):
def rename_snapshot(self, vm):
if vm.snapshot is None:
self.module.exit_json(msg="virtual machine - %s doesn't have any"
self.module.fail_json(msg="virtual machine - %s doesn't have any"
" snapshots" % (self.module.params.get('uuid') or self.module.params.get('name')))
snap_obj = self.get_snapshots_by_name_recursively(vm.snapshot.rootSnapshotList,
@ -303,8 +303,12 @@ class PyVmomiHelper(PyVmomi):
def remove_or_revert_snapshot(self, vm):
if vm.snapshot is None:
vm_name = (self.module.params.get('uuid') or self.module.params.get('name'))
if self.module.params.get('state') == 'revert':
self.module.fail_json(msg="virtual machine - %s does not"
" have any snapshots to revert to." % vm_name)
self.module.exit_json(msg="virtual machine - %s doesn't have any"
" snapshots" % (self.module.params.get('uuid') or self.module.params.get('name')))
" snapshots to remove." % vm_name)
snap_obj = self.get_snapshots_by_name_recursively(vm.snapshot.rootSnapshotList,
self.module.params["snapshot_name"])