Merge "Make conductor create InstanceAction in the proper cell"

This commit is contained in:
Jenkins 2017-02-24 00:43:35 +00:00 committed by Gerrit Code Review
commit 52913418de
2 changed files with 16 additions and 4 deletions

View File

@ -918,11 +918,10 @@ class ComputeTaskManager(base.Base):
notifications.send_update_with_states(context, instance, None,
vm_states.BUILDING, None, None, service="conductor")
objects.InstanceAction.action_start(
context, instance.uuid, instance_actions.CREATE,
want_result=False)
with obj_target_cell(instance, cell):
objects.InstanceAction.action_start(
context, instance.uuid, instance_actions.CREATE,
want_result=False)
instance_bdms = self._create_block_device_mapping(
instance.flavor, instance.uuid, block_device_mapping)

View File

@ -1459,6 +1459,19 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
self.assertEqual(1, ephemeral[0].volume_size)
cells = objects.CellMappingList.get_all(self.context)
# NOTE(danms): Assert that we created the InstanceAction in the
# correct cell
for cell in cells:
with context.target_cell(self.context, cell):
actions = objects.InstanceActionList.get_by_instance_uuid(
self.context, instance_uuid)
if cell.name == 'cell1':
self.assertEqual(1, len(actions))
else:
self.assertEqual(0, len(actions))
@mock.patch('nova.compute.rpcapi.ComputeAPI.build_and_run_instance')
@mock.patch('nova.scheduler.rpcapi.SchedulerAPI.select_destinations')
@mock.patch('nova.objects.HostMapping.get_by_host')