Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions nova/tests/unit/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9242,7 +9242,7 @@ def test_unquiesce(self, mock_has_min_version):

def test_create_snapshot_metadata(self):
base = objects.ImageMeta.from_dict(
{'disk_format': 'raw'})
{'disk_format': 'qcow2'})
instance_data = {'kernel_id': 'kernel',
'project_id': 'prj_id',
'ramdisk_id': 'ram_id',
Expand Down Expand Up @@ -9274,10 +9274,12 @@ def test_create_snapshot_metadata(self):
{'disk_format': 'ami',
'container_format': 'test_container'})
expected['properties']['os_type'] = instance['os_type']
expected['disk_format'] = base.disk_format
# The disk_format of the snapshot should be the *actual* format of the
# thing we upload, regardless of what type of image we booted from.
expected['disk_format'] = img_fmt
expected['container_format'] = base.container_format
ret = drvr._create_snapshot_metadata(base, instance, img_fmt, snp_name)
self.assertEqual(ret, expected)
self.assertEqual(expected, ret)

def test_get_volume_driver(self):
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
Expand Down Expand Up @@ -28778,7 +28780,8 @@ def test_ami(self):
utils.get_system_metadata_from_image(
{'disk_format': 'ami'})

self._test_snapshot(disk_format='ami')
# If we're uploading a qcow2, we must set the disk_format as such
self._test_snapshot(disk_format='qcow2')

@mock.patch('nova.virt.libvirt.utils.get_disk_type_from_path',
new=mock.Mock(return_value=None))
Expand Down
5 changes: 5 additions & 0 deletions nova/tests/unit/virt/test_virt_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ def setUp(self):
# since we don't care about it.
self.stub_out('os_vif.unplug', lambda a, kw: None)
self.stub_out('nova.compute.utils.get_machine_ips', lambda: [])
self.stub_out('nova.virt.libvirt.utils.get_disk_size',
lambda *a, **k: 123456)
self.stub_out('nova.virt.libvirt.utils.get_disk_backing_file',
lambda *a, **k: None)
self.stub_out('nova.privsep.path.chown', lambda *a, **k: None)

def test_init_host_image_type_rbd_force_raw_images_true(self):
CONF.set_override('images_type', 'rbd', group='libvirt')
Expand Down
6 changes: 1 addition & 5 deletions nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2938,11 +2938,7 @@ def _create_snapshot_metadata(self, image_meta, instance,
if instance.os_type:
metadata['properties']['os_type'] = instance.os_type

# NOTE(vish): glance forces ami disk format to be ami
if image_meta.disk_format == 'ami':
metadata['disk_format'] = 'ami'
else:
metadata['disk_format'] = img_fmt
metadata['disk_format'] = img_fmt

if image_meta.obj_attr_is_set("container_format"):
metadata['container_format'] = image_meta.container_format
Expand Down