From 8b283c2f83ebd11b5920e28036ca1aa4bea63df4 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 2 Nov 2012 13:48:15 -0700 Subject: Remove unnecessary db call from xenapi/vmops There are two db.instance_type_get() calls in xenapi that don't need to be there. By fetching the info out of the instance['instance_type'] field, we can avoid the lookup (and adding interfaces to support this in VirtAPI). Note that the tests require a little extra fakeage to replicate what is happening in the real db driver. Change-Id: I727c98fe18ca28f1db62ece2abfd50b4e13852ba --- nova/virt/xenapi/vmops.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 7ccb23283..3f742ebcd 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -466,7 +466,7 @@ class VMOps(object): def _attach_disks(self, instance, vm_ref, name_label, vdis, disk_image_type): ctx = nova_context.get_admin_context() - instance_type = db.instance_type_get(ctx, instance['instance_type_id']) + instance_type = instance['instance_type'] # DISK_ISO needs two VBDs: the ISO disk and a blank RW disk if disk_image_type == vm_utils.ImageType.DISK_ISO: @@ -475,7 +475,7 @@ class VMOps(object): cd_vdi = vdis.pop('root') root_vdi = vm_utils.fetch_blank_disk(self._session, - instance['instance_type_id']) + instance_type['id']) vdis['root'] = root_vdi vm_utils.create_vbd(self._session, vm_ref, root_vdi['ref'], @@ -570,8 +570,7 @@ class VMOps(object): agent.resetnetwork() # Set VCPU weight - inst_type = db.instance_type_get(ctx, instance['instance_type_id']) - vcpu_weight = inst_type['vcpu_weight'] + vcpu_weight = instance['instance_type']['vcpu_weight'] if vcpu_weight is not None: LOG.debug(_("Setting VCPU weight"), instance=instance) self._session.call_xenapi('VM.add_to_VCPUs_params', vm_ref, -- cgit