summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMotoKen <motokentsai@gmail.com>2012-07-24 16:27:45 +0800
committerMotoKen <motokentsai@gmail.com>2012-07-25 10:33:38 +0800
commit7ea62897626546d330c3458bba4112f52882f313 (patch)
tree4ea4d60e228d6165ff97e22fe4cf2679d3489387 /nova/api
parent9468508efe36097e422bf3b43d586ff962b8f4b2 (diff)
downloadnova-7ea62897626546d330c3458bba4112f52882f313.tar.gz
nova-7ea62897626546d330c3458bba4112f52882f313.tar.xz
nova-7ea62897626546d330c3458bba4112f52882f313.zip
EC2 DescribeImageAttribute by kernel/ramdisk.
Fixes bug 1026898. Supports kernel/ramdisk attributes for EC2 DescribeImageAttribute API to display the ID of the kernel/ramdisk associated with the AMI. And adds test cases to verify this behavior. Change-Id: I3ea91b95812dcec349b4ff6dc889645a57975278
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 8a9f5f158..e723176f2 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -1389,10 +1389,26 @@ class CloudController(object):
if result['rootDeviceName'] is None:
result['rootDeviceName'] = block_device.DEFAULT_ROOT_DEV_NAME
+ def _kernel_attribute(image, result):
+ kernel_id = image['properties'].get('kernel_id')
+ if kernel_id:
+ result['kernel'] = {
+ 'value': ec2utils.image_ec2_id(kernel_id, 'aki')
+ }
+
+ def _ramdisk_attribute(image, result):
+ ramdisk_id = image['properties'].get('ramdisk_id')
+ if ramdisk_id:
+ result['ramdisk'] = {
+ 'value': ec2utils.image_ec2_id(ramdisk_id, 'ari')
+ }
+
supported_attributes = {
'blockDeviceMapping': _block_device_mapping_attribute,
'launchPermission': _launch_permission_attribute,
'rootDeviceName': _root_device_name_attribute,
+ 'kernel': _kernel_attribute,
+ 'ramdisk': _ramdisk_attribute,
}
fn = supported_attributes.get(attribute)