Remove _instance_update usage in _build_instance

The _build_instance method has an instance object so
just call instance.save() rather than _instance_update
which does a separate call to conductor to update the
instance updates the resource tracker, which is
unnecessary in this case. Compare to the _build_resources
method.

Part of blueprint compute-manager-objects-juno

Change-Id: Ic350a424f83638e8129d55dda168913798ebc31a
This commit is contained in:
Matt Riedemann
2014-08-13 14:27:22 -07:00
parent 938398d2f4
commit 8a862715bf
2 changed files with 6 additions and 8 deletions

View File

@@ -1340,10 +1340,9 @@ class ComputeManager(manager.Manager):
instance, requested_networks, macs, security_groups,
dhcp_options)
self._instance_update(
context, instance.uuid,
vm_state=vm_states.BUILDING,
task_state=task_states.BLOCK_DEVICE_MAPPING)
instance.vm_state = vm_states.BUILDING
instance.task_state = task_states.BLOCK_DEVICE_MAPPING
instance.save()
# Verify that all the BDMs have a device_name set and assign a
# default to the ones missing it with the help of the driver.

View File

@@ -107,7 +107,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(self.compute, '_get_resource_tracker')
self.mox.StubOutWithMock(self.compute, '_allocate_network')
self.mox.StubOutWithMock(self.compute, '_instance_update')
self.mox.StubOutWithMock(objects.BlockDeviceMappingList,
'get_by_instance_uuid')
@@ -134,17 +133,17 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
self.compute._allocate_network(mox.IgnoreArg(), instance,
mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(),
mox.IgnoreArg()).WithSideEffects(fake_allocate)
self.compute._instance_update(self.context, instance.uuid,
system_metadata={'network_allocated': 'True'})
self.mox.ReplayAll()
self.compute._build_instance(self.context, {}, {},
instance, nw_info = self.compute._build_instance(self.context, {}, {},
None, None, None, True,
node, instance,
{}, False)
self.assertFalse(self.admin_context,
"_allocate_network called with admin context")
self.assertEqual(vm_states.BUILDING, instance.vm_state)
self.assertEqual(task_states.BLOCK_DEVICE_MAPPING, instance.task_state)
def test_allocate_network_fails(self):
self.flags(network_allocate_retries=0)