From 8eede5e9814f3305e0bb66eeb93623ba25b16e9a Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Wed, 22 May 2013 21:52:25 +0930 Subject: Catch InstanceNotFound in instance_actions GET Catch the InstanceNotFound exception in the instance_actions index function and handle the error gracefully so a stacktrace is not generated in the log files. This patch does not change the API Fixes bug 1182867 Change-Id: I0764f8abda7176deefe0d103bd86acd0af78780d --- nova/api/openstack/compute/contrib/instance_actions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/instance_actions.py b/nova/api/openstack/compute/contrib/instance_actions.py index 4eaa9a1ee..3b15de2ba 100644 --- a/nova/api/openstack/compute/contrib/instance_actions.py +++ b/nova/api/openstack/compute/contrib/instance_actions.py @@ -19,6 +19,7 @@ from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil from nova import compute +from nova import exception authorize_actions = extensions.extension_authorizer('compute', 'instance_actions') @@ -84,7 +85,10 @@ class InstanceActionsController(wsgi.Controller): def index(self, req, server_id): """Returns the list of actions recorded for a given instance.""" context = req.environ["nova.context"] - instance = self.compute_api.get(context, server_id) + try: + instance = self.compute_api.get(context, server_id) + except exception.InstanceNotFound as err: + raise exc.HTTPNotFound(explanation=err.format_message()) authorize_actions(context, target=instance) actions_raw = self.action_api.actions_get(context, instance) actions = [self._format_action(action) for action in actions_raw] -- cgit