diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-22 14:45:48 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-22 14:45:48 +0000 |
| commit | 05be719ec76adf60a151b56d695c59fd832cb22b (patch) | |
| tree | 748bdee48399176b284a8bf02444c345157269b1 /nova | |
| parent | 719ec4725eb7ae458810cbd2be0eb4a2cb5edf9d (diff) | |
| parent | 8eede5e9814f3305e0bb66eeb93623ba25b16e9a (diff) | |
Merge "Catch InstanceNotFound in instance_actions GET"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/openstack/compute/contrib/instance_actions.py | 6 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_instance_actions.py | 8 |
2 files changed, 13 insertions, 1 deletions
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] diff --git a/nova/tests/api/openstack/compute/contrib/test_instance_actions.py b/nova/tests/api/openstack/compute/contrib/test_instance_actions.py index 573385a52..871b831ac 100644 --- a/nova/tests/api/openstack/compute/contrib/test_instance_actions.py +++ b/nova/tests/api/openstack/compute/contrib/test_instance_actions.py @@ -178,6 +178,14 @@ class InstanceActionsTest(test.TestCase): self.assertRaises(exc.HTTPNotFound, self.controller.show, req, FAKE_UUID, FAKE_REQUEST_ID) + def test_instance_not_found(self): + def fake_get(self, context, instance_uuid): + raise exception.InstanceNotFound(instance_id=instance_uuid) + self.stubs.Set(compute_api.API, 'get', fake_get) + req = fakes.HTTPRequest.blank('/v2/123/servers/12/os-instance-actions') + self.assertRaises(exc.HTTPNotFound, self.controller.index, req, + FAKE_UUID) + class InstanceActionsSerializerTest(test.TestCase): def setUp(self): |
