Add a block device for the image when using BDMv2

Right now the cli was already adding a block device when it was passed
an image_id to boot from and more than one block device mapping v2. This
is done because nova expects the image to be another block device
mapping and would ignore it otherwise.

This patch moves this functionality from the cli to the base module so
users of the module can benefit from this and also to prevent some
misunderstandings that may arise when using BDMv2 and the image gets
ignored by nova. In the future we should handle this in the nova side
assuming a new BDM when an image is provided.

Fixes bug #1225061

Change-Id: I29f31c24f958cfa8b68b33edc63e0d7031aa241f
This commit is contained in:
Xavier Queralt 2013-09-13 18:27:45 +02:00
parent 9a1304bfab
commit 2e8900b6dc
2 changed files with 7 additions and 7 deletions
novaclient

@ -366,6 +366,13 @@ class BootingManagerWithFind(ManagerWithFind):
body['server']['block_device_mapping'] = \
self._parse_block_device_mapping(block_device_mapping)
elif block_device_mapping_v2:
# Append the image to the list only if we have new style BDMs
if image:
bdm_dict = {'uuid': image.id, 'source_type': 'image',
'destination_type': 'local', 'boot_index': 0,
'delete_on_termination': True}
block_device_mapping_v2.insert(0, bdm_dict)
body['server']['block_device_mapping_v2'] = block_device_mapping_v2
if nics is not None:

@ -122,13 +122,6 @@ def _parse_block_device_mapping_v2(args, image):
'guest_format': 'swap', 'volume_size': args.swap}
bdm.append(bdm_dict)
# Append the image to the list only if we have new style BDMs
if bdm and not args.block_device_mapping and image:
bdm_dict = {'uuid': image.id, 'source_type': 'image',
'destination_type': 'local', 'boot_index': 0,
'delete_on_termination': True}
bdm.insert(0, bdm_dict)
return bdm