From 2915e6ba054b1f4100f788603358ea5b2b8220d5 Mon Sep 17 00:00:00 2001 From: Ahmad Hassan Date: Wed, 5 Oct 2011 17:02:45 +0100 Subject: Make sure unknown extensions return 404 At the moment, if an extension doens't exist and we call a show method with wrong id then the exception is not captured. There is a need to return NOTFOUND exception. Fixes bug 869153. Change-Id: Ie0b2c2e87c5a61f6db74bb10a4740add2ab8ea27 --- nova/api/openstack/extensions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index fae2bb1b1..43bc06014 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -197,8 +197,12 @@ class ExtensionsResource(wsgi.Resource): return dict(extensions=extensions) def show(self, req, id): - # NOTE(dprince): the extensions alias is used as the 'id' for show - ext = self.extension_manager.extensions[id] + try: + # NOTE(dprince): the extensions alias is used as the 'id' for show + ext = self.extension_manager.extensions[id] + except KeyError: + return faults.Fault(webob.exc.HTTPNotFound()) + return dict(extension=self._translate(ext)) def delete(self, req, id): -- cgit