diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-10-17 17:36:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-10-17 17:36:31 +0000 |
| commit | ddb49f7929bf29d2003ffdd3a14831d36d2f9d07 (patch) | |
| tree | 23122ad9db5f27407fa8ffe4fa2240d3f6cfac1d | |
| parent | 1ebd98e3d20a35fc543800677cfe5e006a2f8cab (diff) | |
| parent | 261b4111d481562760321bfc83d64ba35e981b5b (diff) | |
| download | nova-ddb49f7929bf29d2003ffdd3a14831d36d2f9d07.tar.gz nova-ddb49f7929bf29d2003ffdd3a14831d36d2f9d07.tar.xz nova-ddb49f7929bf29d2003ffdd3a14831d36d2f9d07.zip | |
Merge "Explicit errors on confirm/revertResize failures"
| -rw-r--r-- | nova/api/openstack/servers.py | 6 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_server_actions.py | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 61cda6782..9cc0872c6 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -664,6 +664,9 @@ class Controller(object): def _action_confirm_resize(self, input_dict, req, id): try: self.compute_api.confirm_resize(req.environ['nova.context'], id) + except exception.MigrationNotFound: + msg = _("Instance has not been resized.") + raise exc.HTTPBadRequest(explanation=msg) except Exception, e: LOG.exception(_("Error in confirm-resize %s"), e) raise exc.HTTPBadRequest() @@ -672,6 +675,9 @@ class Controller(object): def _action_revert_resize(self, input_dict, req, id): try: self.compute_api.revert_resize(req.environ['nova.context'], id) + except exception.MigrationNotFound: + msg = _("Instance has not been resized.") + raise exc.HTTPBadRequest(explanation=msg) except Exception, e: LOG.exception(_("Error in revert-resize %s"), e) raise exc.HTTPBadRequest() diff --git a/nova/tests/api/openstack/test_server_actions.py b/nova/tests/api/openstack/test_server_actions.py index 816199904..d72d917f3 100644 --- a/nova/tests/api/openstack/test_server_actions.py +++ b/nova/tests/api/openstack/test_server_actions.py @@ -272,6 +272,20 @@ class ServerActionsTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 400) + def test_confirm_resize_migration_not_found(self): + req = self.webreq('/1/action', 'POST', dict(confirmResize=None)) + + def confirm_resize_mock(*args): + raise exception.MigrationNotFoundByStatus(instance_id=1, + status='finished') + + self.stubs.Set(nova.compute.api.API, + 'confirm_resize', + confirm_resize_mock) + + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 400) + def test_revert_resize_server(self): req = self.webreq('/1/action', 'POST', dict(revertResize=None)) @@ -299,6 +313,20 @@ class ServerActionsTest(test.TestCase): res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 400) + def test_revert_resize_migration_not_found(self): + req = self.webreq('/1/action', 'POST', dict(revertResize=None)) + + def revert_resize_mock(*args): + raise exception.MigrationNotFoundByStatus(instance_id=1, + status='finished') + + self.stubs.Set(nova.compute.api.API, + 'revert_resize', + revert_resize_mock) + + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 400) + def test_create_backup(self): """The happy path for creating backups""" self.flags(allow_admin_api=True) |
