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
This commit is contained in:
Dan Smith
2012-11-02 13:48:15 -07:00
parent f88670faae
commit b96ba14622

View File

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