Merge "Fix booting from volume when using api v3"

This commit is contained in:
Jenkins 2014-07-25 12:57:02 +00:00 committed by Gerrit Code Review
commit 8f53274ac6
3 changed files with 16 additions and 5 deletions

View File

@ -204,11 +204,15 @@ class BootingManagerWithFind(ManagerWithFind):
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:

View File

@ -266,7 +266,10 @@ class ShellTest(utils.TestCase):
{
'volume_id': 'blah',
'delete_on_termination': '0',
'device_name': 'vda'
'device_name': 'vda',
'uuid': 'blah',
'boot_index': 0,
'source_type': ''
}
],
'imageRef': '',

View File

@ -329,7 +329,10 @@ class ShellTest(utils.TestCase):
{
'volume_id': 'blah',
'delete_on_termination': '0',
'device_name': 'vda'
'device_name': 'vda',
'boot_index': 0,
'uuid': 'blah',
'source_type': ''
}
],
'image_ref': '',
@ -344,15 +347,16 @@ class ShellTest(utils.TestCase):
'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,