summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMartin Packman <martin.packman@canonical.com>2012-06-21 01:29:20 +0100
committerMartin Packman <martin.packman@canonical.com>2012-06-21 10:40:50 +0100
commit65bff9b98471bfd09cee2c24aba7f2e5d0f0cacd (patch)
treea4803edc7be54f6fbeceadff6badb9466f1480ac /nova/api
parentc9b88b8c50ca9dd13bef6206cfc004c9b23d24b6 (diff)
downloadnova-65bff9b98471bfd09cee2c24aba7f2e5d0f0cacd.tar.gz
nova-65bff9b98471bfd09cee2c24aba7f2e5d0f0cacd.tar.xz
nova-65bff9b98471bfd09cee2c24aba7f2e5d0f0cacd.zip
Tidy up exception handling in contrib api consoles
Removes redundant exception handling from VNC consoles extension api module. Both NotAuthorized and Invalid subclasses are already handled at the wsgi application layer. Also gives a better message, including the id, when an instance is not found. Includes tweaks suggested by Vish in review. Change-Id: Iefa4deeb46e4a12d012e7abe3c73d7d9c18afeff
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/consoles.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/nova/api/openstack/compute/contrib/consoles.py b/nova/api/openstack/compute/contrib/consoles.py
index 712cda87b..915ca5c87 100644
--- a/nova/api/openstack/compute/contrib/consoles.py
+++ b/nova/api/openstack/compute/contrib/consoles.py
@@ -38,26 +38,16 @@ class ConsolesController(wsgi.Controller):
context = req.environ['nova.context']
authorize(context)
+ # If type is not supplied or unknown, get_vnc_console below will cope
console_type = body['os-getVNCConsole'].get('type')
- if not console_type:
- raise webob.exc.HTTPBadRequest(_('Missing type specification'))
-
try:
instance = self.compute_api.get(context, id)
- except exception.NotFound:
- raise webob.exc.HTTPNotFound(_('Instance not found'))
-
- try:
output = self.compute_api.get_vnc_console(context,
instance,
console_type)
- except exception.ConsoleTypeInvalid, e:
- raise webob.exc.HTTPBadRequest(_('Invalid type specification'))
- except exception.NotAuthorized:
- raise webob.exc.HTTPUnauthorized()
- except exception.NotFound:
- raise webob.exc.HTTPNotFound(_('Instance not found'))
+ except exception.InstanceNotFound as e:
+ raise webob.exc.HTTPNotFound(explanation=unicode(e))
return {'console': {'type': console_type, 'url': output['url']}}