From e9ecfdce11850037c823374cee6167391e8c7fb7 Mon Sep 17 00:00:00 2001 From: Andrew Laski Date: Wed, 16 Sep 2015 16:11:54 -0400 Subject: [PATCH] Xenapi: Don't access image_meta.id when booting from a volume When a request is made to boot from a preexisting volume, rather than asking Nova to create a volume from an image, there is no image id field in the image_meta that's passed in to the virt driver. This would be fine except that there was an attempt to access image_meta.id in the boot from volume case where it is not necessary. This change moves that access to a point where it is known that this is not an attempt to boot from a volume and that field should be set. Change-Id: I9dab14762f5d331ef2e36f617f7f66c3d771f32d Closes-bug: 1496557 --- nova/tests/unit/virt/xenapi/test_vmops.py | 2 +- nova/virt/xenapi/vmops.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/tests/unit/virt/xenapi/test_vmops.py b/nova/tests/unit/virt/xenapi/test_vmops.py index 1e4e526b23..e5a0e1cc7f 100644 --- a/nova/tests/unit/virt/xenapi/test_vmops.py +++ b/nova/tests/unit/virt/xenapi/test_vmops.py @@ -349,7 +349,7 @@ class SpawnTestCase(VMOpsTestBase): if include_root_vdi: vdis["root"] = {"ref": "fake_ref"} self.vmops._get_vdis_for_instance(context, instance, - name_label, "image_id", di_type, + name_label, image_meta, di_type, block_device_info).AndReturn(vdis) self.vmops._resize_up_vdis(instance, vdis) step += 1 diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 148cb2a02b..06b2761e1b 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -347,7 +347,7 @@ class VMOps(object): bad_volumes_callback(bad_devices) def _get_vdis_for_instance(self, context, instance, name_label, - image_id, image_type, block_device_info): + image_meta, image_type, block_device_info): """Create or connect to all virtual disks for this instance.""" vdis = self._connect_cinder_volumes(instance, block_device_info) @@ -356,7 +356,7 @@ class VMOps(object): # then use the Glance image as the root device if 'root' not in vdis: create_image_vdis = vm_utils.create_image(context, self._session, - instance, name_label, image_id, image_type) + instance, name_label, image_meta.id, image_type) vdis.update(create_image_vdis) # Fetch VDI refs now so we don't have to fetch the ref multiple times @@ -416,7 +416,7 @@ class VMOps(object): def create_disks_step(undo_mgr, disk_image_type, image_meta, name_label): vdis = self._get_vdis_for_instance(context, instance, name_label, - image_meta.id, disk_image_type, + image_meta, disk_image_type, block_device_info) def undo_create_disks():