Fixes bug 1014194, metadata keys are incorrect for kernel-id and ramdisk-id

Kernel and ramdisk IDs are using currently being inserted in the metadata
using the keys aki-id and ari-id. They should be using the keys kernel-id
and ramdisk-id.
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html

This bug is in a block of code which did not previously have test coverage;
this change also adds that coverage.

Change-Id: I2ee3663169160c0e351e548d831fef2f34f9f2fd
This commit is contained in:
Steve Baker 2012-06-28 16:29:53 +12:00
parent b38840fdbd
commit ded5b51d3c
3 changed files with 24 additions and 2 deletions

View File

@ -201,6 +201,7 @@ Somik Behera <somikbehera@gmail.com>
Soren Hansen <soren.hansen@rackspace.com>
Stanislaw Pitucha <stanislaw.pitucha@hp.com>
Stephanie Reese <reese.sm@gmail.com>
Steve Baker <steve@stevebaker.org>
Sumit Naiksatam <snaiksat@cisco.com>
Thierry Carrez <thierry@openstack.org>
Tim Simpson <tim.simpson@rackspace.com>

View File

@ -96,9 +96,9 @@ class InstanceMetadata():
for image_type in ['kernel', 'ramdisk']:
if self.instance.get('%s_id' % image_type):
image_id = self.instance['%s_id' % image_type]
image_type = ec2utils.image_type(image_type)
ec2_image_type = ec2utils.image_type(image_type)
ec2_id = ec2utils.glance_id_to_ec2_id(ctxt, image_id,
image_type)
ec2_image_type)
self.ec2_ids['%s-id' % image_type] = ec2_id
self.address = address

View File

@ -20,6 +20,7 @@
import base64
from copy import copy
import re
import stubout
import webob
@ -190,6 +191,26 @@ class MetadataTestCase(test.TestCase):
self.assertEqual(base.ec2_md_print(pubkey_ent['0']['openssh-key']),
self.instance['key_data'])
def test_image_type_ramdisk(self):
inst = copy(self.instance)
inst['ramdisk_id'] = 'ari-853667c0'
md = fake_InstanceMetadata(self.stubs, inst)
data = md.get_ec2_metadata(version='latest')
self.assertTrue(data['meta-data']['ramdisk-id'] is not None)
self.assertTrue(re.match('ari-[0-9a-f]{8}',
data['meta-data']['ramdisk-id']))
def test_image_type_kernel(self):
inst = copy(self.instance)
inst['kernel_id'] = 'aki-c2e26ff2'
md = fake_InstanceMetadata(self.stubs, inst)
data = md.get_ec2_metadata(version='2009-04-04')
self.assertTrue(data['meta-data']['kernel-id'] is not None)
self.assertTrue(re.match('aki-[0-9a-f]{8}',
data['meta-data']['kernel-id']))
class MetadataHandlerTestCase(test.TestCase):
"""Test that metadata is returning proper values."""