Do not specify device_name when creating server with BFV

When creating a server using an existing volume or volume snapshot,
horizon specified a device_name 'vda'.
However the device name depends on bus type or something and
this causes incorrect volume information in the instance detail page
(and nova volume-attachments CLI output).
For detail background, see bug 1560965.

block_device_mapping v1 required device_name but it is no longer
required to specify device_name 'vda' in block_device_mapping v2
in Nova create-server API.

This commit changes to use block_device_mapping v2 so that
we can avoid specifying device_name.

Change-Id: Ice1a6bb2dcddab0a89c99f345d1f2cd101955b28
Partial-Bug: #1560965
This commit is contained in:
Akihiro Motoki 2019-03-28 15:33:51 +09:00
parent 4788c4d2f5
commit 5ab15c49da
2 changed files with 13 additions and 14 deletions

View File

@ -205,8 +205,6 @@
// REQUIRED for JS logic
hide_create_volume: false,
vol_create: false,
// May be null
vol_device_name: 'vda',
vol_delete_on_instance_delete: false,
vol_size: 1
};
@ -750,10 +748,10 @@
setFinalSpecBootImageToVolume(finalSpec);
break;
case bootSourceTypes.VOLUME:
setFinalSpecBootFromVolumeDevice(finalSpec, 'vol');
setFinalSpecBootFromVolumeDevice(finalSpec, 'volume');
break;
case bootSourceTypes.VOLUME_SNAPSHOT:
setFinalSpecBootFromVolumeDevice(finalSpec, 'snap');
setFinalSpecBootFromVolumeDevice(finalSpec, 'snapshot');
break;
default:
$log.error("Unknown source type: " + finalSpec.source_type);
@ -765,7 +763,6 @@
// at launch time.
delete finalSpec.source_type;
delete finalSpec.vol_create;
delete finalSpec.vol_device_name;
delete finalSpec.vol_delete_on_instance_delete;
delete finalSpec.vol_size;
}
@ -789,14 +786,16 @@
}
function setFinalSpecBootFromVolumeDevice(finalSpec, sourceType) {
finalSpec.block_device_mapping = {};
finalSpec.block_device_mapping[finalSpec.vol_device_name] = [
finalSpec.source_id,
':',
sourceType,
'::',
finalSpec.vol_delete_on_instance_delete
].join('');
finalSpec.block_device_mapping_v2 = [];
finalSpec.block_device_mapping_v2.push(
{
'source_type': sourceType,
'destination_type': bootSourceTypes.VOLUME,
'delete_on_termination': finalSpec.vol_delete_on_instance_delete,
'uuid': finalSpec.source_id,
'boot_index': '0'
}
);
// Source ID must be empty for API
finalSpec.source_id = '';

View File

@ -841,7 +841,7 @@
// This is here to ensure that as people add/change items, they
// don't forget to implement tests for them.
it('has the right number of properties', function() {
expect(Object.keys(model.newInstanceSpec).length).toBe(23);
expect(Object.keys(model.newInstanceSpec).length).toBe(22);
});
it('sets availability zone to null', function() {