libvirtutil.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:lib9 作者: Jumpscale 项目源码 文件源码
def delete_machine(self, id):
        if self.isCurrentStorageAction(id):
            raise Exception("Can't delete a locked machine")

        domain = self._get_domain(id)
        if domain:
            if domain.state(0)[0] != libvirt.VIR_DOMAIN_SHUTOFF:
                domain.destroy()
            domain.undefineFlags(
                libvirt.VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA)

        poolpath = os.path.join(self.basepath, id)
        try:
            diskpool = self.connection.storagePoolLookupByName(id)
            for vol in diskpool.listAllVolumes():
                vol.delete()
            diskpool.destroy()
        except BaseException:
            pass
        if os.path.exists(poolpath):
            shutil.rmtree(poolpath)

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号