Skip to content

Commit d0acba1

Browse files
authored
Merge pull request #95 from stackhpc/upstream/zed-2024-08-08
Synchronise zed with upstream
2 parents 5841659 + e6f4503 commit d0acba1

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9242,7 +9242,7 @@ def test_unquiesce(self, mock_has_min_version):
92429242

92439243
def test_create_snapshot_metadata(self):
92449244
base = objects.ImageMeta.from_dict(
9245-
{'disk_format': 'raw'})
9245+
{'disk_format': 'qcow2'})
92469246
instance_data = {'kernel_id': 'kernel',
92479247
'project_id': 'prj_id',
92489248
'ramdisk_id': 'ram_id',
@@ -9274,10 +9274,12 @@ def test_create_snapshot_metadata(self):
92749274
{'disk_format': 'ami',
92759275
'container_format': 'test_container'})
92769276
expected['properties']['os_type'] = instance['os_type']
9277-
expected['disk_format'] = base.disk_format
9277+
# The disk_format of the snapshot should be the *actual* format of the
9278+
# thing we upload, regardless of what type of image we booted from.
9279+
expected['disk_format'] = img_fmt
92789280
expected['container_format'] = base.container_format
92799281
ret = drvr._create_snapshot_metadata(base, instance, img_fmt, snp_name)
9280-
self.assertEqual(ret, expected)
9282+
self.assertEqual(expected, ret)
92819283

92829284
def test_get_volume_driver(self):
92839285
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
@@ -28778,7 +28780,8 @@ def test_ami(self):
2877828780
utils.get_system_metadata_from_image(
2877928781
{'disk_format': 'ami'})
2878028782

28781-
self._test_snapshot(disk_format='ami')
28783+
# If we're uploading a qcow2, we must set the disk_format as such
28784+
self._test_snapshot(disk_format='qcow2')
2878228785

2878328786
@mock.patch('nova.virt.libvirt.utils.get_disk_type_from_path',
2878428787
new=mock.Mock(return_value=None))

nova/tests/unit/virt/test_virt_drivers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,11 @@ def setUp(self):
838838
# since we don't care about it.
839839
self.stub_out('os_vif.unplug', lambda a, kw: None)
840840
self.stub_out('nova.compute.utils.get_machine_ips', lambda: [])
841+
self.stub_out('nova.virt.libvirt.utils.get_disk_size',
842+
lambda *a, **k: 123456)
843+
self.stub_out('nova.virt.libvirt.utils.get_disk_backing_file',
844+
lambda *a, **k: None)
845+
self.stub_out('nova.privsep.path.chown', lambda *a, **k: None)
841846

842847
def test_init_host_image_type_rbd_force_raw_images_true(self):
843848
CONF.set_override('images_type', 'rbd', group='libvirt')

nova/virt/libvirt/driver.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,11 +2938,7 @@ def _create_snapshot_metadata(self, image_meta, instance,
29382938
if instance.os_type:
29392939
metadata['properties']['os_type'] = instance.os_type
29402940

2941-
# NOTE(vish): glance forces ami disk format to be ami
2942-
if image_meta.disk_format == 'ami':
2943-
metadata['disk_format'] = 'ami'
2944-
else:
2945-
metadata['disk_format'] = img_fmt
2941+
metadata['disk_format'] = img_fmt
29462942

29472943
if image_meta.obj_attr_is_set("container_format"):
29482944
metadata['container_format'] = image_meta.container_format

0 commit comments

Comments
 (0)