diff options
| author | Eoghan Glynn <eglynn@redhat.com> | 2012-07-14 21:30:43 +0100 |
|---|---|---|
| committer | Eoghan Glynn <eglynn@redhat.com> | 2012-07-17 18:29:22 +0100 |
| commit | b898badbbc237cceb8ced9d89f4c53e2df98ee4d (patch) | |
| tree | 7ab32eaa45f5ea175fe1347e1ac04d1f035d363d | |
| parent | 8600394ec4dd4f800d774e4ed0c24fe087d8e1d3 (diff) | |
| download | nova-b898badbbc237cceb8ced9d89f4c53e2df98ee4d.tar.gz nova-b898badbbc237cceb8ced9d89f4c53e2df98ee4d.tar.xz nova-b898badbbc237cceb8ced9d89f4c53e2df98ee4d.zip | |
EC2 DescribeImages reports correct rootDeviceType
Fixes LP 1024354
A root device type of instance-store was incorrectly reported for
boot-from-volume images (i.e. the analogue of EBS-backed AMIs).
When comparing the block device mapping device name with the root
device name, we now tolerate a missing leading '/dev/' path.
Change-Id: I1d3bda780deee52f5d41e3af041aba7e6305dfde
| -rw-r--r-- | nova/api/ec2/cloud.py | 4 | ||||
| -rw-r--r-- | nova/block_device.py | 2 | ||||
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index af74e75b8..3807ff323 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1303,8 +1303,10 @@ class CloudController(object): properties = image['properties'] root_device_name = block_device.properties_root_device_name(properties) root_device_type = 'instance-store' + for bdm in properties.get('block_device_mapping', []): - if (bdm.get('device_name') == root_device_name and + if (block_device.strip_dev(bdm.get('device_name')) == + block_device.strip_dev(root_device_name) and ('snapshot_id' in bdm or 'volume_id' in bdm) and not bdm.get('no_device')): root_device_type = 'ebs' diff --git a/nova/block_device.py b/nova/block_device.py index caa521e83..aec981933 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -71,7 +71,7 @@ _dev = re.compile('^/dev/') def strip_dev(device_name): """remove leading '/dev/'""" - return _dev.sub('', device_name) + return _dev.sub('', device_name) if device_name else device_name _pref = re.compile('^((x?v|s)d)') diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index b1de3c78a..1a0f429cb 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -2178,6 +2178,7 @@ class CloudTestCase(test.TestCase): delete_on_termination=False)] props = dict(kernel_id='cedef40a-ed67-4d10-800e-17455edce175', ramdisk_id='76fa36fc-c930-4bf3-8c8a-ea2a2420deb6', + root_device_name='/dev/vda', block_device_mapping=bdm) return dict(id=id, properties=props, @@ -2223,6 +2224,7 @@ class CloudTestCase(test.TestCase): 'snap-%08x' % snapshots[0]) self.assertEquals(created_image.get('kernelId'), 'aki-00000001') self.assertEquals(created_image.get('ramdiskId'), 'ari-00000002') + self.assertEquals(created_image.get('rootDeviceType'), 'ebs') self.cloud.terminate_instances(self.context, [ec2_instance_id]) for vol in volumes: |
