summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2012-11-02 13:48:15 -0700
committerDan Smith <danms@us.ibm.com>2012-11-02 13:48:15 -0700
commit8b283c2f83ebd11b5920e28036ca1aa4bea63df4 (patch)
treecfa4e9ea8d7393b1b8e9cdbfa21fc3d56aa12a5e /nova/virt
parent8a134759982a497118acbee328a01b00e9cb2a44 (diff)
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
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/vmops.py7
1 files changed, 3 insertions, 4 deletions
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,