VMware: Additional check for RootSnapshot (#36001)

This fix adds an additional check if there is no snapshot available
in VM. `rootSnapshotList` is None, if no snapshot is taken.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-02-10 21:11:11 +05:30 committed by GitHub
parent 1d0fd49a33
commit 52f79fa5a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,11 +241,13 @@ class PyVmomiHelper(PyVmomi):
memory_dump = False
quiesce = False
# Check if there is a latest snapshot already present as specified by user
snap_obj = self.get_snapshots_by_name_recursively(vm.snapshot.rootSnapshotList,
self.module.params["snapshot_name"])
if snap_obj:
# Snapshot already exists, do not anything.
self.module.exit_json(changed=False, msg="Snapshot named [%(snapshot_name)s] already exists." % self.module.params)
if vm.snapshot is not None:
snap_obj = self.get_snapshots_by_name_recursively(vm.snapshot.rootSnapshotList,
self.module.params["snapshot_name"])
if snap_obj:
# Snapshot already exists, do not anything.
self.module.exit_json(changed=False,
msg="Snapshot named [%(snapshot_name)s] already exists and is current." % self.module.params)
# Check if Virtual Machine provides capabilities for Quiesce and Memory Snapshots
if vm.capability.quiescedSnapshotsSupported:
quiesce = self.module.params['quiesce']