def __init__(self, instance=None, disk_name=None, path=None): self.ephemeral_key_uuid = instance.get('ephemeral_key_uuid') if self.ephemeral_key_uuid is not None: self.key_manager = keymgr.API(CONF) else: self.key_manager = None if path: if self.ephemeral_key_uuid is None: info = lvm.volume_info(path) self.vg = info['VG'] self.lv = info['LV'] else: self.vg = CONF.libvirt.images_volume_group 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)) if self.ephemeral_key_uuid is None: path = os.path.join('/dev', self.vg, self.lv) else: self.lv_path = os.path.join('/dev', self.vg, self.lv) path = '/dev/mapper/' + dmcrypt.volume_name(self.lv) super(Lvm, self).__init__(path, "block", "raw", instance, is_block_dev=True) # 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 not self.sparse: self.driver_io = "native"
def __init__(self, connection_info, **kwargs): self._key_manager = keymgr.API() self.encryption_key_id = kwargs.get('encryption_key_id')