summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohan Rhishikesh Kanade <rohan.kanade@nttdata.com>2012-12-12 05:25:43 -0800
committerRohan Rhishikesh Kanade <rohan.kanade@nttdata.com>2012-12-12 06:08:45 -0800
commit4339ecbb4f62a8de5048867262db75f17a8bf5a8 (patch)
treed008225372200903c8b4fb1fb2431515d7cd1133
parent235239c97bc3bd948f1e4a50b69986e741c53e19 (diff)
downloadnova-4339ecbb4f62a8de5048867262db75f17a8bf5a8.tar.gz
nova-4339ecbb4f62a8de5048867262db75f17a8bf5a8.tar.xz
nova-4339ecbb4f62a8de5048867262db75f17a8bf5a8.zip
Fix for correctly parsing snapshot uuid in ec2api
* EC2 snapshot id correctly translated instead of volume uuid. * Add unit tests changes for the existing test. Fixes LP Bug #1089371 Change-Id: Id650ba53dc6cda946531493e3887a01fc5d9bda4
-rw-r--r--nova/api/ec2/cloud.py5
-rw-r--r--nova/tests/test_bdm.py16
2 files changed, 13 insertions, 8 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 796505b57..2ee8fa157 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -131,11 +131,10 @@ def _parse_block_device_mapping(bdm):
if ebs:
ec2_id = ebs.pop('snapshot_id', None)
if ec2_id:
- id = ec2utils.ec2_vol_id_to_uuid(ec2_id)
if ec2_id.startswith('snap-'):
- bdm['snapshot_id'] = id
+ bdm['snapshot_id'] = ec2utils.ec2_snap_id_to_uuid(ec2_id)
elif ec2_id.startswith('vol-'):
- bdm['volume_id'] = id
+ bdm['volume_id'] = ec2utils.ec2_vol_id_to_uuid(ec2_id)
ebs.setdefault('delete_on_termination', True)
bdm.update(ebs)
return bdm
diff --git a/nova/tests/test_bdm.py b/nova/tests/test_bdm.py
index 2d0349534..558eeeb66 100644
--- a/nova/tests/test_bdm.py
+++ b/nova/tests/test_bdm.py
@@ -29,14 +29,18 @@ class BlockDeviceMappingEc2CloudTestCase(test.TestCase):
"""Test Case for Block Device Mapping"""
def fake_ec2_vol_id_to_uuid(obj, ec2_id):
+ if ec2_id == 'vol-87654321':
+ return '22222222-3333-4444-5555-666666666666'
+ elif ec2_id == 'vol-98765432':
+ return '77777777-8888-9999-0000-aaaaaaaaaaaa'
+ else:
+ return 'OhNoooo'
+
+ def fake_ec2_snap_id_to_uuid(obj, ec2_id):
if ec2_id == 'snap-12345678':
return '00000000-1111-2222-3333-444444444444'
elif ec2_id == 'snap-23456789':
return '11111111-2222-3333-4444-555555555555'
- elif ec2_id == 'vol-87654321':
- return '22222222-3333-4444-5555-666666666666'
- elif ec2_id == 'vol-98765432':
- return '77777777-8888-9999-0000-aaaaaaaaaaaa'
else:
return 'OhNoooo'
@@ -48,7 +52,9 @@ class BlockDeviceMappingEc2CloudTestCase(test.TestCase):
self.stubs.Set(ec2utils,
'ec2_vol_id_to_uuid',
self.fake_ec2_vol_id_to_uuid)
-
+ self.stubs.Set(ec2utils,
+ 'ec2_snap_id_to_uuid',
+ self.fake_ec2_snap_id_to_uuid)
bdm_list = [
({'device_name': '/dev/fake0',
'ebs': {'snapshot_id': 'snap-12345678',