From b415d675f544d8cffed8f82dac9d251fd5620cb1 Mon Sep 17 00:00:00 2001 From: Hendrik Volkmer Date: Fri, 2 Nov 2012 12:23:13 +0000 Subject: Removes unnecessary db query for instance type The instance type information is already available in the instance hash. This removes a db query and also reduces the likelyhood of a race condtion where the instance type could change between the point where boot API call was made and the request hits the compute node. blueprint no-db-compute Change-Id: I8372a8c88049a8dacef86a7034c6df94c40c3001 --- nova/virt/libvirt/driver.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'nova') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index c59876d95..c37211eb8 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -57,7 +57,6 @@ from xml.dom import minidom from nova.api.metadata import base as instance_metadata from nova import block_device -from nova.compute import instance_types from nova.compute import power_state from nova.compute import vm_mode from nova import config @@ -1311,8 +1310,7 @@ class LibvirtDriver(driver.ComputeDriver): root_fname = hashlib.sha1(str(disk_images['image_id'])).hexdigest() size = instance['root_gb'] * 1024 * 1024 * 1024 - inst_type_id = instance['instance_type_id'] - inst_type = instance_types.get_instance_type(inst_type_id) + inst_type = instance['instance_type'] if size == 0 or suffix == '.rescue': size = None @@ -1678,10 +1676,7 @@ class LibvirtDriver(driver.ComputeDriver): 'ramdisk_id' if a ramdisk is needed for the rescue image and 'kernel_id' if a kernel is needed for the rescue image. """ - # FIXME(vish): stick this in db - inst_type_id = instance['instance_type_id'] - inst_type = instance_types.get_instance_type(inst_type_id, - inactive=True) + inst_type = instance['instance_type'] guest = vconfig.LibvirtConfigGuest() guest.virt_type = CONF.libvirt_type -- cgit