snapshot: Add device_name to the snapshot bdms

33e3d4c6b9 drops device names - at the
time of writing, the idea was that Nova should collect all the block
device information and decide on device names with the help of the
hypervisor.

It turns out that as well meaning as that change was - it also removed
the ability to do some of the things that the EC2 API needs device names
for (see the linked bug for a more detailed explanation). An example is
overriding some of the attributes of a block device entry in the image.

The only "indexable" property of a block device from EC2 POV is device
name so we need to put it back even though they may be overriden by the
virt layer upon a successful intance boot.

Change-Id: Ib1ba130042aabbbe7bb8d60fc212c66e446c1d73
Related-bug: #1370177
Related-bug: #1370250
This commit is contained in:
Nikola Dipanov
2015-06-08 15:03:02 +01:00
parent a8b5028bbd
commit 0e367d2248
4 changed files with 8 additions and 6 deletions

View File

@@ -241,7 +241,7 @@ class BlockDeviceDict(dict):
return legacy_block_device
def get_image_mapping(self):
drop_fields = (set(['connection_info', 'device_name']) |
drop_fields = (set(['connection_info']) |
self._db_only_fields)
mapping_dict = dict(self)
for fld in drop_fields:
@@ -292,7 +292,8 @@ def snapshot_from_bdm(snapshot_id, template):
"""Create a basic volume snapshot BDM from a given template bdm."""
copy_from_template = ('disk_bus', 'device_type', 'boot_index',
'delete_on_termination', 'volume_size')
'delete_on_termination', 'volume_size',
'device_name')
snapshot_dict = {'source_type': 'snapshot',
'destination_type': 'volume',
'snapshot_id': snapshot_id}