def has_snapshot(self, vm_name, snapshot_title):
"""
Returns whether a particular virtual machine is currently protected
by a snapshot. This requires specifying a VM name.
:param vm_name: Name of a virtual machine
:type vm_name: str
:param snapshot_title: Snapshot title
:type snapshot_title: str
"""
try:
#find VM and get all snapshots
target_vm = self.SESSION.lookupByName(vm_name)
target_snapshots = target_vm.snapshotListNames(0)
if snapshot_title in target_snapshots:
return True
except libvirt.libvirtError as err:
self.LOGGER.error("Unable to determine snapshot: '{}'".format(err))
raise SessionException(err)
except Exception as err:
raise SessionException(err)
评论列表
文章目录