Skip to content

Commit

Permalink
Fix booting from volume when using api v3
Browse files Browse the repository at this point in the history
The current code in novaclient/base.py, class BootingManagerWithFind
do not take in account the differences required to boot an instance from
a volume in API v3. V3 expects UUID as volume id and also the source type
to be set.

Change-Id: Id8cfb2d7811aead27cb26cf7ff615c7a9ed05d54
Close-bug: 1325303
  • Loading branch information
liyingjun committed Jun 25, 2014
1 parent 7d9d15e commit 58cdcab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions novaclient/base.py
Expand Up @@ -204,11 +204,15 @@ def _parse_block_device_mapping(self, block_device_mapping):

mapping_parts = mapping.split(':')
source_id = mapping_parts[0]
bdm_dict['uuid'] = source_id
bdm_dict['boot_index'] = 0
if len(mapping_parts) == 1:
bdm_dict['volume_id'] = source_id
bdm_dict['source_type'] = 'volume'

elif len(mapping_parts) > 1:
source_type = mapping_parts[1]
bdm_dict['source_type'] = source_type
if source_type.startswith('snap'):
bdm_dict['snapshot_id'] = source_id
else:
Expand Down
5 changes: 4 additions & 1 deletion novaclient/tests/v1_1/test_shell.py
Expand Up @@ -266,7 +266,10 @@ def test_boot_no_image_bdms(self):
{
'volume_id': 'blah',
'delete_on_termination': '0',
'device_name': 'vda'
'device_name': 'vda',
'uuid': 'blah',
'boot_index': 0,
'source_type': ''
}
],
'imageRef': '',
Expand Down
12 changes: 8 additions & 4 deletions novaclient/tests/v3/test_shell.py
Expand Up @@ -329,7 +329,10 @@ def test_boot_no_image_bdms(self):
{
'volume_id': 'blah',
'delete_on_termination': '0',
'device_name': 'vda'
'device_name': 'vda',
'boot_index': 0,
'uuid': 'blah',
'source_type': ''
}
],
'image_ref': '',
Expand All @@ -344,15 +347,16 @@ def test_boot_image_bdms(self):
'source=volume,dest=volume,device=vda,size=1,format=ext4,'
'type=disk,shutdown=preserve some-server'
)
id = ('fake-id,source=volume,dest=volume,device=vda,size=1,'
'format=ext4,type=disk,shutdown=preserve')
self.assert_called_anytime(
'POST', '/servers',
{'server': {
'flavor_ref': '1',
'name': 'some-server',
'os-block-device-mapping:block_device_mapping': [
{'device_name': 'id', 'volume_id':
'fake-id,source=volume,dest=volume,device=vda,size=1,'
'format=ext4,type=disk,shutdown=preserve'}],
{'device_name': 'id', 'volume_id': id,
'source_type': 'volume', 'boot_index': 0, 'uuid': id}],
'image_ref': '1',
'os-multiple-create:min_count': 1,
'os-multiple-create:max_count': 1,
Expand Down

0 comments on commit 58cdcab

Please sign in to comment.