snapshot: Copy some missing attrs to the snapshot bdms

The following commit: 33e3d4c6b9 wrongly
drops some of the block device mapping information that is needed to
fully describe the block device mapping. In addition - EC2 API needs
this information to be able to format the output.

Change-Id: I18a0aab1dd966f28973e1f3705f263cb46a42639
Partial-bug: #1370177
This commit is contained in:
Nikola Dipanov 2015-05-29 21:12:16 +01:00
parent aa2f5dcc5f
commit a7de013891
2 changed files with 6 additions and 2 deletions

View File

@ -277,7 +277,8 @@ def create_image_bdm(image_ref, boot_index=0):
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']
copy_from_template = ('disk_bus', 'device_type', 'boot_index',
'delete_on_termination', 'volume_size')
snapshot_dict = {'source_type': 'snapshot',
'destination_type': 'volume',
'snapshot_id': snapshot_id}

View File

@ -631,12 +631,15 @@ class TestBlockDeviceDict(test.NoDBTestCase):
self.assertEqual(snapshot['snapshot_id'], 'new-snapshot-id')
self.assertEqual(snapshot['source_type'], 'snapshot')
self.assertEqual(snapshot['destination_type'], 'volume')
self.assertEqual(template.volume_size, snapshot['volume_size'])
self.assertEqual(template.delete_on_termination,
snapshot['delete_on_termination'])
for key in ['disk_bus', 'device_type', 'boot_index']:
self.assertEqual(snapshot[key], template[key])
def test_snapshot_from_bdm(self):
for bdm in self.new_mapping:
self._test_snapshot_from_bdm(bdm)
self._test_snapshot_from_bdm(objects.BlockDeviceMapping(**bdm))
def test_snapshot_from_object(self):
for bdm in self.new_mapping[:-1]: