示例#1
0
    def __init__(self, instance=None, disk_name=None, path=None,
                 snapshot_name=None):
        super(Lvm, self).__init__("block", "raw", is_block_dev=True)

        if path:
            info = libvirt_utils.logical_volume_info(path)
            self.vg = info['VG']
            self.lv = info['LV']
            self.path = path
        else:
            if not CONF.libvirt_images_volume_group:
                raise RuntimeError(_('You should specify'
                                     ' libvirt_images_volume_group'
                                     ' flag to use LVM images.'))
            self.vg = CONF.libvirt_images_volume_group
            self.lv = '%s_%s' % (self.escape(instance['name']),
                                 self.escape(disk_name))
            self.path = os.path.join('/dev', self.vg, self.lv)

        # TODO(pbrady): possibly deprecate libvirt_sparse_logical_volumes
        # for the more general preallocate_images
        self.sparse = CONF.libvirt_sparse_logical_volumes
        self.preallocate = not self.sparse

        if snapshot_name:
            self.snapshot_name = snapshot_name
            self.snapshot_path = os.path.join('/dev', self.vg,
                                              self.snapshot_name)
示例#2
0
    def __init__(self,
                 instance=None,
                 disk_name=None,
                 path=None,
                 snapshot_name=None):
        super(Lvm, self).__init__("block", "raw", is_block_dev=True)

        if path:
            info = libvirt_utils.logical_volume_info(path)
            self.vg = info['VG']
            self.lv = info['LV']
            self.path = path
        else:
            if not CONF.libvirt_images_volume_group:
                raise RuntimeError(
                    _('You should specify'
                      ' libvirt_images_volume_group'
                      ' flag to use LVM images.'))
            self.vg = CONF.libvirt_images_volume_group
            self.lv = '%s_%s' % (self.escape(
                instance['name']), self.escape(disk_name))
            self.path = os.path.join('/dev', self.vg, self.lv)

        # TODO(pbrady): possibly deprecate libvirt_sparse_logical_volumes
        # for the more general preallocate_images
        self.sparse = CONF.libvirt_sparse_logical_volumes
        self.preallocate = not self.sparse

        if snapshot_name:
            self.snapshot_name = snapshot_name
            self.snapshot_path = os.path.join('/dev', self.vg,
                                              self.snapshot_name)
示例#3
0
    def __init__(self, instance=None, name=None, path=None):
        super(Lvm, self).__init__("block", "raw", is_block_dev=True)

        if path:
            info = libvirt_utils.logical_volume_info(path)
            self.vg = info['VG']
            self.lv = info['LV']
            self.path = path
        else:
            if not CONF.libvirt_images_volume_group:
                raise RuntimeError(_('You should specify'
                                     ' libvirt_images_volume_group'
                                     ' flag to use LVM images.'))
            self.vg = CONF.libvirt_images_volume_group
            self.lv = '%s_%s' % (self.escape(instance),
                                 self.escape(name))
            self.path = os.path.join('/dev', self.vg, self.lv)

        self.sparse = CONF.libvirt_sparse_logical_volumes
示例#4
0
    def __init__(self, instance=None, name=None, path=None):
        super(Lvm, self).__init__("block", "raw", is_block_dev=True)

        if path:
            info = libvirt_utils.logical_volume_info(path)
            self.vg = info['VG']
            self.lv = info['LV']
            self.path = path
        else:
            if not CONF.libvirt_images_volume_group:
                raise RuntimeError(_('You should specify'
                                     ' libvirt_images_volume_group'
                                     ' flag to use LVM images.'))
            self.vg = CONF.libvirt_images_volume_group
            self.lv = '%s_%s' % (self.escape(instance['name']),
                                 self.escape(name))
            self.path = os.path.join('/dev', self.vg, self.lv)

        self.sparse = CONF.libvirt_sparse_logical_volumes
示例#5
0
    def __init__(self, instance=None, disk_name=None, path=None):
        super(Lvm, self).__init__("block", "raw", is_block_dev=True)

        if path:
            info = libvirt_utils.logical_volume_info(path)
            self.vg = info["VG"]
            self.lv = info["LV"]
            self.path = path
        else:
            if not CONF.libvirt.images_volume_group:
                raise RuntimeError(_("You should specify" " images_volume_group" " flag to use LVM images."))
            self.vg = CONF.libvirt.images_volume_group
            self.lv = "%s_%s" % (instance["uuid"], self.escape(disk_name))
            self.path = os.path.join("/dev", self.vg, self.lv)

        # TODO(pbrady): possibly deprecate libvirt.sparse_logical_volumes
        # for the more general preallocate_images
        self.sparse = CONF.libvirt.sparse_logical_volumes
        self.preallocate = not self.sparse