diff options
| author | Rick Harris <rick.harris@rackspace.com> | 2011-01-25 21:59:18 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-01-25 21:59:18 +0000 |
| commit | 7ff50565f33f3e854fe6261bb6c7be36f1ddbd9b (patch) | |
| tree | 2c9fb564896647b3c25627a4b27682bd7530fb53 | |
| parent | 705cbaa3d311c21cf2a7318e52a60eeadebb435a (diff) | |
| parent | 9fac0cefb1ba4d7ffa85315a3843ef70ce37691c (diff) | |
| download | nova-7ff50565f33f3e854fe6261bb6c7be36f1ddbd9b.tar.gz nova-7ff50565f33f3e854fe6261bb6c7be36f1ddbd9b.tar.xz nova-7ff50565f33f3e854fe6261bb6c7be36f1ddbd9b.zip | |
This patch:
1. Removes the krm.json file which maps machine images to kernel and ramdisks
2. Adds support to pull kernel_id and ramdisk_id directly from Glance image record.
Note: This patch is dependent upon this bug in Glance being fixed: https://bugs.launchpad.net/glance/+bug/706192
| -rw-r--r-- | krm_mapping.json.sample | 3 | ||||
| -rw-r--r-- | nova/api/openstack/__init__.py | 3 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 28 |
3 files changed, 17 insertions, 17 deletions
diff --git a/krm_mapping.json.sample b/krm_mapping.json.sample deleted file mode 100644 index 1ecfba635..000000000 --- a/krm_mapping.json.sample +++ /dev/null @@ -1,3 +0,0 @@ -{ - "machine" : ["kernel", "ramdisk"] -} diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index f2caac483..c70bb39ed 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -38,9 +38,6 @@ from nova.api.openstack import shared_ip_groups LOG = logging.getLogger('nova.api.openstack') FLAGS = flags.FLAGS -flags.DEFINE_string('os_krm_mapping_file', - 'krm_mapping.json', - 'Location of OpenStack Flavor/OS:EC2 Kernel/Ramdisk/Machine JSON file.') flags.DEFINE_bool('allow_admin_api', False, 'When True, this API service will accept admin operations.') diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 22b4797c9..9d308ea24 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -124,17 +124,22 @@ class Controller(wsgi.Controller): return faults.Fault(exc.HTTPNotFound()) return exc.HTTPAccepted() - def _get_kernel_ramdisk_from_image(self, image_id): - mapping_filename = FLAGS.os_krm_mapping_file - - with open(mapping_filename) as f: - mapping = json.load(f) - if image_id in mapping: - return mapping[image_id] + def _get_kernel_ramdisk_from_image(self, req, image_id): + """ + Machine images are associated with Kernels and Ramdisk images via + metadata stored in Glance as 'image_properties' + """ + def lookup(param): + _image_id = image_id + try: + return image['properties'][param] + except KeyError: + raise exception.NotFound( + _("%(param)s property not found for image %(_image_id)s") % + locals()) - msg = _("No entry for image '%(image_id)s'" - " in mapping file '%(mapping_filename)s'") % locals() - raise exception.NotFound(msg) + image = self._image_service.show(req.environ['nova.context'], image_id) + return lookup('kernel_id'), lookup('ramdisk_id') def create(self, req): """ Creates a new server for a given user """ @@ -146,7 +151,8 @@ class Controller(wsgi.Controller): req.environ['nova.context'])[0] image_id = common.get_image_id_from_image_hash(self._image_service, req.environ['nova.context'], env['server']['imageId']) - kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(image_id) + kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image( + req, image_id) instances = self.compute_api.create( req.environ['nova.context'], instance_types.get_by_flavor_id(env['server']['flavorId']), |
