diff options
author | Lee Yarwood <lyarwood@redhat.com> | 2022-01-25 16:58:23 +0000 |
---|---|---|
committer | melanie witt <melwittt@gmail.com> | 2022-08-16 08:08:21 +0000 |
commit | e2cf3ae9ab54f7aea1354de112f7a58ece135e9e (patch) | |
tree | b70ef8aaa2efcd8854170676b22a6471e41c5040 /nova/tests/unit/virt/libvirt/test_imagebackend.py | |
parent | 5c228e8d39a6bf6e0e4a4efbb8db3993a2dfb029 (diff) | |
download | nova-e2cf3ae9ab54f7aea1354de112f7a58ece135e9e.tar.gz |
imagebackend: Add disk_info_mapping as an optional attribute of Image
Change-Id: I67203a85b8030899514b80d26390d299f8619845
Diffstat (limited to 'nova/tests/unit/virt/libvirt/test_imagebackend.py')
-rw-r--r-- | nova/tests/unit/virt/libvirt/test_imagebackend.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_imagebackend.py b/nova/tests/unit/virt/libvirt/test_imagebackend.py index fdac091985..34f022700c 100644 --- a/nova/tests/unit/virt/libvirt/test_imagebackend.py +++ b/nova/tests/unit/virt/libvirt/test_imagebackend.py @@ -163,7 +163,13 @@ class _ImageTestCase(object): self.assertEqual(fs.source_file, image.path) def test_libvirt_info(self): - image = self.image_class(self.INSTANCE, self.NAME) + disk_info = { + 'bus': 'virtio', + 'dev': '/dev/vda', + 'type': 'cdrom', + } + image = self.image_class( + self.INSTANCE, self.NAME, disk_info_mapping=disk_info) extra_specs = { 'quota:disk_read_bytes_sec': 10 * units.Mi, 'quota:disk_read_iops_sec': 1 * units.Ki, @@ -172,15 +178,9 @@ class _ImageTestCase(object): 'quota:disk_total_bytes_sec': 30 * units.Mi, 'quota:disk_total_iops_sec': 3 * units.Ki, } - disk_info = { - 'bus': 'virtio', - 'dev': '/dev/vda', - 'type': 'cdrom', - } disk = image.libvirt_info( - disk_info, cache_mode="none", extra_specs=extra_specs, - boot_order="1") + cache_mode="none", extra_specs=extra_specs, boot_order="1") self.assertIsInstance(disk, vconfig.LibvirtConfigGuestDisk) self.assertEqual("/dev/vda", disk.target_dev) @@ -205,16 +205,18 @@ class _ImageTestCase(object): get_disk_size.assert_called_once_with(image.path) def _test_libvirt_info_scsi_with_unit(self, disk_unit): - # The address should be set if bus is scsi and unit is set. - # Otherwise, it should not be set at all. - image = self.image_class(self.INSTANCE, self.NAME) disk_info = { 'bus': 'scsi', 'dev': '/dev/sda', 'type': 'disk', } + # The address should be set if bus is scsi and unit is set. + # Otherwise, it should not be set at all. + image = self.image_class( + self.INSTANCE, self.NAME, disk_info_mapping=disk_info) + disk = image.libvirt_info( - disk_info, cache_mode='none', extra_specs={}, disk_unit=disk_unit) + cache_mode='none', extra_specs={}, disk_unit=disk_unit) if disk_unit: self.assertEqual(0, disk.device_addr.controller) self.assertEqual(disk_unit, disk.device_addr.unit) |