diff --git a/nova/block_device.py b/nova/block_device.py index 7a036cd23edb..050393e1b8a3 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -86,7 +86,7 @@ class BlockDeviceDict(dict): self.update( dict((field, None) for field in self._fields - do_not_default)) - self.update(bdm_dict) + self.update(list(bdm_dict.iteritems())) def _validate(self, bdm_dict): """Basic data format validations.""" diff --git a/nova/tests/test_block_device.py b/nova/tests/test_block_device.py index 3ce1e9600d89..c1b5f1192696 100644 --- a/nova/tests/test_block_device.py +++ b/nova/tests/test_block_device.py @@ -423,6 +423,19 @@ class TestBlockDeviceDict(test.NoDBTestCase): for legacy, expected in zip(got_legacy, self.legacy_mapping): self.assertThat(expected, matchers.IsSubDictOf(legacy)) + def test_legacy_mapping_from_object_list(self): + bdm1 = block_device_obj.BlockDeviceMapping() + bdm1 = block_device_obj.BlockDeviceMapping._from_db_object( + None, bdm1, fake_block_device.FakeDbBlockDeviceDict( + self.new_mapping[0])) + bdm2 = block_device_obj.BlockDeviceMapping() + bdm2 = block_device_obj.BlockDeviceMapping._from_db_object( + None, bdm2, fake_block_device.FakeDbBlockDeviceDict( + self.new_mapping[1])) + bdmlist = block_device_obj.BlockDeviceMappingList() + bdmlist.objects = [bdm1, bdm2] + block_device.legacy_mapping(bdmlist) + def test_image_mapping(self): removed_fields = ['id', 'instance_uuid', 'connection_info', 'device_name', 'created_at', 'updated_at',