我正在写一个自动生成快照的脚本,到目前为止工作得很好。我也希望能够使用我的脚本删除快照,但似乎没有记录的方法调用可以做到这一点。我已经发现,在rhev 3.3.0中,你必须关闭虚拟机才能删除它们,但我仍然无法删除快照。
这就是我到目前为止所知道的:
def deleteSnapshot(self):
VM = self.con.vms.get(self.hostname.replace('.','_'))
VM_status= VM.status.state
if VM_status == 'up':
self.stopVM()
time.sleep(10)
elif VM_status == 'down':
self.listSnapshotDescription() # This is where the deletion stuff should happen,但我仍然无法找到删除这些快照的方法。我还在网上搜索了一些关于这个主题的有用的Redhat文档,但没有找到任何有用的文档。
有没有人能给我一个提示或什么东西,让我找到正确的方向?提前谢谢你。
发布于 2014-05-28 17:49:46
我找到了解决方案
>>> mylist = connection.vms.get('host64').snapshots.list()
>>> for snapshot in mylist:
... if snapshot.description == "host64.bla":
... snapshot.delete() 此外,还必须关闭虚拟机才能删除快照
https://stackoverflow.com/questions/23905886
复制相似问题