Explicitly handle exception ConsoleTypeUnavailable for v2 consoles

In v3 remote_console extension, the exception ConsoleTypeUnavailable
is catched by explicitly. This patch changes the v2 api as same way,
and backport v3 unittest into v2 api.

Change-Id: I14f74e4a4b4ee84713b48cfc00d3f132726f9316
This commit is contained in:
He Jie Xu
2014-08-12 10:15:04 +08:00
parent 0e4fc86b46
commit 562f98594e
2 changed files with 57 additions and 0 deletions

View File

@@ -48,6 +48,8 @@ class ConsolesController(wsgi.Controller):
except exception.InstanceNotReady as e:
raise webob.exc.HTTPConflict(
explanation=_('Instance not yet ready'))
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except NotImplementedError:
msg = _("Unable to get vnc console, functionality not implemented")
raise webob.exc.HTTPNotImplemented(explanation=msg)
@@ -68,6 +70,8 @@ class ConsolesController(wsgi.Controller):
output = self.compute_api.get_spice_console(context,
instance,
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceNotReady as e:
@@ -93,6 +97,8 @@ class ConsolesController(wsgi.Controller):
output = self.compute_api.get_rdp_console(context,
instance,
console_type)
except exception.ConsoleTypeUnavailable as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
except exception.InstanceNotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.format_message())
except exception.InstanceNotReady as e: