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:
1
Authors
1
Authors
@@ -201,6 +201,7 @@ Somik Behera <somikbehera@gmail.com>
|
|||||||
Soren Hansen <soren.hansen@rackspace.com>
|
Soren Hansen <soren.hansen@rackspace.com>
|
||||||
Stanislaw Pitucha <stanislaw.pitucha@hp.com>
|
Stanislaw Pitucha <stanislaw.pitucha@hp.com>
|
||||||
Stephanie Reese <reese.sm@gmail.com>
|
Stephanie Reese <reese.sm@gmail.com>
|
||||||
|
Steve Baker <steve@stevebaker.org>
|
||||||
Sumit Naiksatam <snaiksat@cisco.com>
|
Sumit Naiksatam <snaiksat@cisco.com>
|
||||||
Thierry Carrez <thierry@openstack.org>
|
Thierry Carrez <thierry@openstack.org>
|
||||||
Tim Simpson <tim.simpson@rackspace.com>
|
Tim Simpson <tim.simpson@rackspace.com>
|
||||||
|
@@ -96,9 +96,9 @@ class InstanceMetadata():
|
|||||||
for image_type in ['kernel', 'ramdisk']:
|
for image_type in ['kernel', 'ramdisk']:
|
||||||
if self.instance.get('%s_id' % image_type):
|
if self.instance.get('%s_id' % image_type):
|
||||||
image_id = self.instance['%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,
|
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.ec2_ids['%s-id' % image_type] = ec2_id
|
||||||
|
|
||||||
self.address = address
|
self.address = address
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
import re
|
||||||
|
|
||||||
import stubout
|
import stubout
|
||||||
import webob
|
import webob
|
||||||
@@ -190,6 +191,26 @@ class MetadataTestCase(test.TestCase):
|
|||||||
self.assertEqual(base.ec2_md_print(pubkey_ent['0']['openssh-key']),
|
self.assertEqual(base.ec2_md_print(pubkey_ent['0']['openssh-key']),
|
||||||
self.instance['key_data'])
|
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):
|
class MetadataHandlerTestCase(test.TestCase):
|
||||||
"""Test that metadata is returning proper values."""
|
"""Test that metadata is returning proper values."""
|
||||||
|
Reference in New Issue
Block a user