diff options
author | Yaguang Tang <yaguang.tang@canonical.com> | 2013-06-26 15:11:54 +0800 |
---|---|---|
committer | Yaguang Tang <yaguang.tang@canonical.com> | 2013-06-26 15:18:09 +0800 |
commit | ea6d089d196e2d71eac17a1b0079788a71522cfd (patch) | |
tree | e5bff91d3871461b1c02ecb69a43cd3447c2f4ae | |
parent | d30de7b13d413f3f4585a6b1d194833e22ceeeaf (diff) | |
download | nova-ea6d089d196e2d71eac17a1b0079788a71522cfd.tar.gz nova-ea6d089d196e2d71eac17a1b0079788a71522cfd.tar.xz nova-ea6d089d196e2d71eac17a1b0079788a71522cfd.zip |
Update instance properties values in child cells to create instance.
When using nova cells, in child cell, instance properties dict received
from API cell is returned by database that contains instance['name']. We
need to pop this from dict before creating a instance entry in child cell.
The system metadata also need to be recreated in child cell because instance
properties dict is converted to primitive which makes instance['system_metadata']
a list of dicts.
Fix bug #1193552
Change-Id: I43a8b4c1673a831b0c87881004eb0a7e5b149d9e
-rw-r--r-- | nova/cells/scheduler.py | 5 | ||||
-rw-r--r-- | nova/tests/cells/test_cells_scheduler.py | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/nova/cells/scheduler.py b/nova/cells/scheduler.py index 08f485189..c2b3ff2b7 100644 --- a/nova/cells/scheduler.py +++ b/nova/cells/scheduler.py @@ -24,6 +24,7 @@ from oslo.config import cfg from nova.cells import filters from nova.cells import weights from nova import compute +from nova.compute import flavors from nova.compute import instance_actions from nova.compute import utils as compute_utils from nova.compute import vm_states @@ -80,6 +81,10 @@ class CellsScheduler(base.Base): def _create_instances_here(self, ctxt, instance_uuids, instance_properties, instance_type, image, security_groups, block_device_mapping): instance_values = copy.copy(instance_properties) + sys_metadata = flavors.save_flavor_info(dict(), instance_type) + instance_values['system_metadata'] = sys_metadata + instance_values.pop('name') + num_instances = len(instance_uuids) for i, instance_uuid in enumerate(instance_uuids): instance_values['uuid'] = instance_uuid diff --git a/nova/tests/cells/test_cells_scheduler.py b/nova/tests/cells/test_cells_scheduler.py index 46be492cc..38076fb0c 100644 --- a/nova/tests/cells/test_cells_scheduler.py +++ b/nova/tests/cells/test_cells_scheduler.py @@ -94,7 +94,8 @@ class CellsSchedulerTestCase(test.TestCase): inst_type = db.instance_type_get(self.ctxt, 1) image = {'properties': {}} instance_uuids = self.instance_uuids - instance_props = {'hostname': 'meow', + instance_props = {'name': 'instance-00000001', + 'hostname': 'meow', 'display_name': 'moo', 'image_ref': 'fake_image_ref', 'user_id': self.ctxt.user_id, |