Honor Nova's restriction for bdm fields

Nova does not allow None values for bdm fields. However it stores them
in image metadata for volume bdm during snapshot operation of volume
backed instance. Ec2Api sends them back to Nova during run instance
operation, which violates Nova's restriction.

Here we cut out None values from image bdms before use it.

Change-Id: Ice913c935e288f1cb615443324c05ca3c31efca6
This commit is contained in:
Feodor Tersin 2016-12-29 12:24:28 +03:00
parent ea53c13767
commit 239464ab74
2 changed files with 4 additions and 1 deletions

View File

@ -1003,6 +1003,8 @@ def _build_block_device_mapping(context, block_device_mapping, os_image):
_populate_parsed_bdm_parameter(bdm, short_root_device_name)
else:
image_bdm = {k: v for k, v in six.iteritems(image_bdm)
if v is not None}
image_bdm.update(bdm)
bdm = image_bdm

View File

@ -1508,7 +1508,8 @@ class InstancePrivateTestCase(test_base.BaseTestCase):
'device_name': '/dev/vda',
'source_type': 'snapshot',
'snapshot_id': fakes.ID_OS_SNAPSHOT_1,
'delete_on_termination': True},
'delete_on_termination': True,
'disk_bus': None},
{'device_name': 'vdb',
'source_type': 'snapshot',
'snapshot_id': fakes.random_os_id(),