diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py index 61ecbdd4b35a..3366cd7ffa39 100644 --- a/nova/tests/virt/xenapi/test_xenapi.py +++ b/nova/tests/virt/xenapi/test_xenapi.py @@ -84,6 +84,7 @@ IMAGE_RAW = '4' IMAGE_VHD = '5' IMAGE_ISO = '6' IMAGE_IPXE_ISO = '7' +IMAGE_FROM_VOLUME = '8' IMAGE_FIXTURES = { IMAGE_MACHINE: { @@ -122,6 +123,10 @@ IMAGE_FIXTURES = { 'container_format': 'bare', 'properties': {'ipxe_boot': 'true'}}, }, + IMAGE_FROM_VOLUME: { + 'image_meta': {'name': 'fake_ipxe_iso', + 'properties': {'foo': 'bar'}}, + }, } @@ -885,9 +890,14 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): self._test_spawn(None, None, None, block_device_info=dev_info) + def test_spawn_boot_from_volume_no_glance_image_meta(self): + dev_info = get_fake_device_info() + self._test_spawn(IMAGE_FROM_VOLUME, None, None, + block_device_info=dev_info) + def test_spawn_boot_from_volume_with_image_meta(self): dev_info = get_fake_device_info() - self._test_spawn(None, None, None, + self._test_spawn(IMAGE_VHD, None, None, block_device_info=dev_info) def test_spawn_netinject_file(self): diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 6b7463f8cce1..9449d84edac6 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -1641,7 +1641,7 @@ def determine_disk_image_type(image_meta): 2. If we're not using Glance, then we need to deduce this based on whether a kernel_id is specified. """ - if not image_meta: + if not image_meta or 'disk_format' not in image_meta: return None disk_format = image_meta['disk_format']