Merge "Rename Raw backend to Flat"
This commit is contained in:
commit
7dc5d7222c
@ -220,7 +220,8 @@ libvirt_general_opts = [
|
||||
libvirt_imagebackend_opts = [
|
||||
cfg.StrOpt('images_type',
|
||||
default='default',
|
||||
choices=('raw', 'qcow2', 'lvm', 'rbd', 'ploop', 'default'),
|
||||
choices=('raw', 'flat', 'qcow2', 'lvm', 'rbd', 'ploop',
|
||||
'default'),
|
||||
help='VM Images format. If default is specified, then'
|
||||
' use_cow_images flag is used instead of this one.'),
|
||||
cfg.StrOpt('images_volume_group',
|
||||
|
@ -193,14 +193,15 @@ class _ImageTestCase(object):
|
||||
get_disk_size.assert_called_once_with(image.path)
|
||||
|
||||
|
||||
class RawTestCase(_ImageTestCase, test.NoDBTestCase):
|
||||
class FlatTestCase(_ImageTestCase, test.NoDBTestCase):
|
||||
|
||||
SIZE = 1024
|
||||
|
||||
def setUp(self):
|
||||
self.image_class = imagebackend.Raw
|
||||
super(RawTestCase, self).setUp()
|
||||
self.stubs.Set(imagebackend.Raw, 'correct_format', lambda _: None)
|
||||
self.image_class = imagebackend.Flat
|
||||
super(FlatTestCase, self).setUp()
|
||||
self.stubs.Set(imagebackend.Flat, 'correct_format',
|
||||
lambda _: None)
|
||||
|
||||
def prepare_mocks(self):
|
||||
fn = self.mox.CreateMockAnything()
|
||||
@ -1669,24 +1670,25 @@ class BackendTestCase(test.NoDBTestCase):
|
||||
assertIsInstance(image1, image_not_cow)
|
||||
assertIsInstance(image2, image_cow)
|
||||
|
||||
def test_image_raw(self):
|
||||
self._test_image('raw', imagebackend.Raw, imagebackend.Raw)
|
||||
def test_image_flat(self):
|
||||
self._test_image('raw', imagebackend.Flat, imagebackend.Flat)
|
||||
|
||||
def test_image_raw_preallocate_images(self):
|
||||
def test_image_flat_preallocate_images(self):
|
||||
flags = ('space', 'Space', 'SPACE')
|
||||
for f in flags:
|
||||
self.flags(preallocate_images=f)
|
||||
raw = imagebackend.Raw(self.INSTANCE, 'fake_disk', '/tmp/xyz')
|
||||
raw = imagebackend.Flat(self.INSTANCE, 'fake_disk',
|
||||
'/tmp/xyz')
|
||||
self.assertTrue(raw.preallocate)
|
||||
|
||||
def test_image_raw_preallocate_images_bad_conf(self):
|
||||
def test_image_flat_preallocate_images_bad_conf(self):
|
||||
self.flags(preallocate_images='space1')
|
||||
raw = imagebackend.Raw(self.INSTANCE, 'fake_disk', '/tmp/xyz')
|
||||
raw = imagebackend.Flat(self.INSTANCE, 'fake_disk', '/tmp/xyz')
|
||||
self.assertFalse(raw.preallocate)
|
||||
|
||||
def test_image_raw_native_io(self):
|
||||
def test_image_flat_native_io(self):
|
||||
self.flags(preallocate_images="space")
|
||||
raw = imagebackend.Raw(self.INSTANCE, 'fake_disk', '/tmp/xyz')
|
||||
raw = imagebackend.Flat(self.INSTANCE, 'fake_disk', '/tmp/xyz')
|
||||
self.assertEqual(raw.driver_io, "native")
|
||||
|
||||
def test_image_qcow2(self):
|
||||
@ -1732,4 +1734,4 @@ class BackendTestCase(test.NoDBTestCase):
|
||||
self._test_image('rbd', imagebackend.Rbd, imagebackend.Rbd)
|
||||
|
||||
def test_image_default(self):
|
||||
self._test_image('default', imagebackend.Raw, imagebackend.Qcow2)
|
||||
self._test_image('default', imagebackend.Flat, imagebackend.Qcow2)
|
||||
|
@ -5410,7 +5410,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
|
||||
if (dest_check_data.is_shared_instance_path and
|
||||
self.image_backend.backend().is_file_in_instance_path()):
|
||||
# NOTE(angdraug): file based image backends (Raw, Qcow2)
|
||||
# NOTE(angdraug): file based image backends (Flat, Qcow2)
|
||||
# place block device files under the instance path
|
||||
return True
|
||||
|
||||
|
@ -430,10 +430,15 @@ class Image(object):
|
||||
pass
|
||||
|
||||
|
||||
class Raw(Image):
|
||||
class Flat(Image):
|
||||
"""The Flat backend uses either raw or qcow2 storage. It never uses
|
||||
a backing store, so when using qcow2 it copies an image rather than
|
||||
creating an overlay. By default it creates raw files, but will use qcow2
|
||||
when creating a disk from a qcow2 if force_raw_images is not set in config.
|
||||
"""
|
||||
def __init__(self, instance=None, disk_name=None, path=None):
|
||||
self.disk_name = disk_name
|
||||
super(Raw, self).__init__("file", "raw", is_block_dev=False)
|
||||
super(Flat, self).__init__("file", "raw", is_block_dev=False)
|
||||
|
||||
self.path = (path or
|
||||
os.path.join(libvirt_utils.get_instance_path(instance),
|
||||
@ -459,11 +464,11 @@ class Raw(Image):
|
||||
|
||||
def _supports_encryption(self):
|
||||
# NOTE(dgenin): Kernel, ramdisk and disk.config are fetched using
|
||||
# the Raw backend regardless of which backend is configured for
|
||||
# ephemeral storage. Encryption for the Raw backend is not yet
|
||||
# the Flat backend regardless of which backend is configured for
|
||||
# ephemeral storage. Encryption for the Flat backend is not yet
|
||||
# implemented so this loophole is necessary to allow other
|
||||
# backends already supporting encryption to function. This can
|
||||
# be removed once encryption for Raw is implemented.
|
||||
# be removed once encryption for Flat is implemented.
|
||||
if self.disk_name not in ['kernel', 'ramdisk', 'disk.config']:
|
||||
return False
|
||||
else:
|
||||
@ -480,7 +485,6 @@ class Raw(Image):
|
||||
def copy_raw_image(base, target, size):
|
||||
libvirt_utils.copy_image(base, target)
|
||||
if size:
|
||||
# class Raw is misnamed, format may not be 'raw' in all cases
|
||||
image = imgmodel.LocalFileImage(target,
|
||||
self.driver_format)
|
||||
disk.extend(image, size)
|
||||
@ -1069,12 +1073,13 @@ class Ploop(Image):
|
||||
class Backend(object):
|
||||
def __init__(self, use_cow):
|
||||
self.BACKEND = {
|
||||
'raw': Raw,
|
||||
'raw': Flat,
|
||||
'flat': Flat,
|
||||
'qcow2': Qcow2,
|
||||
'lvm': Lvm,
|
||||
'rbd': Rbd,
|
||||
'ploop': Ploop,
|
||||
'default': Qcow2 if use_cow else Raw
|
||||
'default': Qcow2 if use_cow else Flat
|
||||
}
|
||||
|
||||
def backend(self, image_type=None):
|
||||
|
@ -158,7 +158,7 @@ nova.tests.unit.virt.libvirt.test_fakelibvirt.FakeLibvirtTests.test_numa_topolog
|
||||
nova.tests.unit.virt.libvirt.test_firewall.IptablesFirewallTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagebackend.EncryptedLvmTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagebackend.LvmTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagebackend.RawTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagebackend.FlatTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagebackend.RbdTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagecache.ImageCacheManagerTestCase
|
||||
nova.tests.unit.virt.libvirt.test_imagecache.VerifyChecksumTestCase
|
||||
|
Loading…
Reference in New Issue
Block a user