示例#1
0
    def snapshot_delete(self, instance_name, snapshot_name, metadata=False):
        """delete the snapshot
        Todo: use virDomainXXX instead of virsh

        :param instance: instance of snapshot
        :param snapshot_name: Name of snapshot
        :param metadata: If True, delete the metadata only
        """
        virsh_cmd = ['virsh', 'snapshot-delete', instance_name, snapshot_name]
        if metadata:
            virsh_cmd = virsh_cmd + ['--metadata']
        utils.execute(*virsh_cmd, run_as_root=True)
示例#2
0
    def snapshot_delete(self, instance_name, snapshot_name, metadata = False):
        """delete the snapshot
        Todo: use virDomainXXX instead of virsh

        :param instance: instance of snapshot
        :param snapshot_name: Name of snapshot
        :param metadata: If True, delete the metadata only
        """
        virsh_cmd = ['virsh', 'snapshot-delete', instance_name, snapshot_name] 
        if metadata :
            virsh_cmd = virsh_cmd + ['--metadata']
        utils.execute(*virsh_cmd, run_as_root=True)
示例#3
0
 def rebase(self, backing_file_base, backing_file_top):
     """rebase the backing_file_top to backing_file_base using unsafe mode
     :param backing_file_base: backing file to rebase to
     :param backing_file_top: top file to rebase
     """
     utils.execute('qemu-img',
                   'rebase',
                   '-u',
                   '-b',
                   backing_file_base,
                   backing_file_top,
                   run_as_root=True)
示例#4
0
    def blockcommit(self, instance, dev, backing_file_base, backing_file_top):
        """block commit the changes from top to base
        Todo: use virDomainXXX instead of virsh

        :param instance: instance to blockcommit
        :param dev: block device name
        :param backing_file_base: base to commit into
        :param backing_file_top: top file to commit from
        """

        virsh_cmd = ['virsh', 'blockcommit', '--domain', 
                     instance, dev, '--wait', '--base', backing_file_base, 
                     '--top', backing_file_top]

        utils.execute(*virsh_cmd, run_as_root=True)
示例#5
0
    def blockcommit(self, instance, dev, backing_file_base, backing_file_top):
        """block commit the changes from top to base
        Todo: use virDomainXXX instead of virsh

        :param instance: instance to blockcommit
        :param dev: block device name
        :param backing_file_base: base to commit into
        :param backing_file_top: top file to commit from
        """

        virsh_cmd = [
            'virsh', 'blockcommit', '--domain', instance, dev, '--wait',
            '--base', backing_file_base, '--top', backing_file_top
        ]

        utils.execute(*virsh_cmd, run_as_root=True)
示例#6
0
def qemu_img_info(path):
    """Return an object containing the parsed output from qemu-img info."""
    if not os.path.exists(path):
        return QemuImgInfo()

    out, err = utils.execute('env', 'LC_ALL=C', 'LANG=C',
                             'qemu-img', 'info', path)
    return QemuImgInfo(out)
示例#7
0
文件: images.py 项目: v12aml/raksha
def qemu_img_info(path):
    """Return an object containing the parsed output from qemu-img info."""
    if not os.path.exists(path):
        return QemuImgInfo()

    out, err = utils.execute('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info',
                             path)
    return QemuImgInfo(out)
示例#8
0
    def snapshot_create_as(self, instance_name, snapshot_name, snapshot_description, dev_snapshot_disk_paths):
        """Atomic disk only external snapshots of an instance
        Todo: use virDomainSnapshotCreateXML instead of virsh

        :param instance: instance to snapshot
        :param snapshot_name: Name of snapshot
        :param snapshot_description: Description of snapshot
        :param snapshot_disk_paths: list of the new snapshot_disk_paths
        """
        diskspecs = []
        for dev, snapshot in dev_snapshot_disk_paths.iteritems():
            diskspecs = diskspecs + ['--diskspec', dev + ',snapshot=external,file=' + snapshot]

        virsh_cmd = ['virsh', 'snapshot-create-as', 
                     instance_name, snapshot_name, 
                     snapshot_description, 
                     '--disk-only', '--atomic'] + diskspecs

        utils.execute(*virsh_cmd, run_as_root=True)
示例#9
0
    def snapshot_create_as(self, instance_name, snapshot_name,
                           snapshot_description, dev_snapshot_disk_paths):
        """Atomic disk only external snapshots of an instance
        Todo: use virDomainSnapshotCreateXML instead of virsh

        :param instance: instance to snapshot
        :param snapshot_name: Name of snapshot
        :param snapshot_description: Description of snapshot
        :param snapshot_disk_paths: list of the new snapshot_disk_paths
        """
        diskspecs = []
        for dev, snapshot in dev_snapshot_disk_paths.iteritems():
            diskspecs = diskspecs + [
                '--diskspec', dev + ',snapshot=external,file=' + snapshot
            ]

        virsh_cmd = [
            'virsh', 'snapshot-create-as', instance_name, snapshot_name,
            snapshot_description, '--disk-only', '--atomic'
        ] + diskspecs

        utils.execute(*virsh_cmd, run_as_root=True)
示例#10
0
 def commit(self, backing_file_top):
     """rebase the backing_file_top to backing_file_base
      :param backing_file_top: top file to commit from to its base
     """
     utils.execute('qemu-img', 'commit', backing_file_top, run_as_root=True)        
示例#11
0
 def rebase(self, backing_file_base, backing_file_top):
     """rebase the backing_file_top to backing_file_base using unsafe mode
     :param backing_file_base: backing file to rebase to
     :param backing_file_top: top file to rebase
     """
     utils.execute('qemu-img', 'rebase', '-u', '-b', backing_file_base, backing_file_top, run_as_root=True)   
示例#12
0
 def commit(self, backing_file_top):
     """rebase the backing_file_top to backing_file_base
      :param backing_file_top: top file to commit from to its base
     """
     utils.execute('qemu-img', 'commit', backing_file_top, run_as_root=True)
示例#13
0
def convert_image(source, dest, out_format, run_as_root=False):
    """Convert image to other format."""
    cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
    utils.execute(*cmd, run_as_root=run_as_root)
示例#14
0
文件: images.py 项目: v12aml/raksha
def convert_image(source, dest, out_format, run_as_root=False):
    """Convert image to other format."""
    cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
    utils.execute(*cmd, run_as_root=run_as_root)