From a42adb28c9817b96178617bba9c42dac18bfec24 Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Fri, 21 Jun 2013 14:40:37 +0800 Subject: Fix KeyError exception when scheduling to child cell. Fix typo 'security_group' and update related unit tests. Fix bug #1193233 Change-Id: I6d92759b0d7e2ce81c2065a4eada35c559ccbcd7 --- nova/cells/scheduler.py | 5 +++-- nova/tests/cells/test_cells_scheduler.py | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/nova/cells/scheduler.py b/nova/cells/scheduler.py index aa081a726..08f485189 100644 --- a/nova/cells/scheduler.py +++ b/nova/cells/scheduler.py @@ -175,9 +175,10 @@ class CellsScheduler(base.Base): """Attempt to build instance(s) or send msg to child cell.""" ctxt = message.ctxt instance_properties = build_inst_kwargs['instances'][0] - instance_type = build_inst_kwargs['instance_type'] + filter_properties = build_inst_kwargs['filter_properties'] + instance_type = filter_properties['instance_type'] image = build_inst_kwargs['image'] - security_groups = build_inst_kwargs['security_group'] + security_groups = build_inst_kwargs['security_groups'] block_device_mapping = build_inst_kwargs['block_device_mapping'] LOG.debug(_("Building instances with routing_path=%(routing_path)s"), diff --git a/nova/tests/cells/test_cells_scheduler.py b/nova/tests/cells/test_cells_scheduler.py index 600867f43..46be492cc 100644 --- a/nova/tests/cells/test_cells_scheduler.py +++ b/nova/tests/cells/test_cells_scheduler.py @@ -84,10 +84,9 @@ class CellsSchedulerTestCase(test.TestCase): 'block_device_mapping': 'fake_bdm'} self.build_inst_kwargs = { 'instances': self.instances, - 'instance_type': 'fake_type', 'image': 'fake_image', - 'filter_properties': {}, - 'security_group': 'fake_sec_groups', + 'filter_properties': {'instance_type': 'fake_type'}, + 'security_groups': 'fake_sec_groups', 'block_device_mapping': 'fake_bdm'} def test_create_instances_here(self): @@ -284,10 +283,11 @@ class CellsSchedulerTestCase(test.TestCase): self.assertEqual(self.instance_uuids, call_info['instance_uuids']) self.assertEqual(self.build_inst_kwargs['instances'][0], call_info['instance_properties']) - self.assertEqual(self.build_inst_kwargs['instance_type'], - call_info['instance_type']) + self.assertEqual( + self.build_inst_kwargs['filter_properties']['instance_type'], + call_info['instance_type']) self.assertEqual(self.build_inst_kwargs['image'], call_info['image']) - self.assertEqual(self.build_inst_kwargs['security_group'], + self.assertEqual(self.build_inst_kwargs['security_groups'], call_info['security_groups']) self.assertEqual(self.build_inst_kwargs['block_device_mapping'], call_info['block_device_mapping']) -- cgit