From b96ba14622dfd50ebd55fce436cb4a11d76257c0 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 2 Nov 2012 13:48:15 -0700 Subject: [PATCH] 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/tests/test_xenapi.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 94daf0b5..404c183a 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1488,6 +1488,11 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase): instance = db.instance_update(self.context, instance['uuid'], {'instance_type_id': 5}) + # NOTE(danms): because we're stubbing out the instance_types from + # the database, our instance['instance_type'] doesn't get properly + # filled out here, so put what we need into it + instance['instance_type']['swap'] = 1024 + def fake_generate_swap(*args, **kwargs): self.called = True self.stubs.Set(vm_utils, 'generate_swap', fake_generate_swap) @@ -1500,6 +1505,11 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase): instance = db.instance_update(self.context, instance['uuid'], {'instance_type_id': 4}) + # NOTE(danms): because we're stubbing out the instance_types from + # the database, our instance['instance_type'] doesn't get properly + # filled out here, so put what we need into it + instance['instance_type']['ephemeral_gb'] = 160 + def fake_generate_ephemeral(*args): self.called = True self.stubs.Set(vm_utils, 'generate_ephemeral', fake_generate_ephemeral)