libvirtutil.py 文件源码

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

项目:lib9 作者: Jumpscale 项目源码 文件源码
def backup_machine_to_filesystem(self, machineid, backuppath):
        from shutil import make_archive
        if self.isCurrentStorageAction(machineid):
            raise Exception("Can't delete a locked machine")
        domain = self.connection.lookupByUUIDString(machineid)
        diskfiles = self._get_domain_disk_file_names(domain)
        if domain.state(0)[0] != libvirt.VIR_DOMAIN_SHUTOFF:
            domain.destroy()
        for diskfile in diskfiles:
            if os.path.exists(diskfile):
                try:
                    vol = self.connection.storageVolLookupByPath(diskfile)
                except BaseException:
                    continue
                poolpath = os.path.join(self.basepath, domain.name())
                if os.path.exists(poolpath):
                    archive_name = os.path.join(
                        backuppath, 'vm-%04x' % machineid)
                    root_dir = poolpath
                    make_archive(archive_name, gztar, root_dir)
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号