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
This commit is contained in:
Andrew Laski 2015-09-16 16:11:54 -04:00
parent a095196230
commit e9ecfdce11
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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():