diff --git a/doc/v3/api_samples/servers/server-action-confirm-resize.json b/doc/v3/api_samples/servers/server-action-confirm-resize.json index 493a9ffe865c..2940d2a3925a 100644 --- a/doc/v3/api_samples/servers/server-action-confirm-resize.json +++ b/doc/v3/api_samples/servers/server-action-confirm-resize.json @@ -1,3 +1,3 @@ { - "confirm_resize" : null + "confirmResize" : null } \ No newline at end of file diff --git a/doc/v3/api_samples/servers/server-action-revert-resize.json b/doc/v3/api_samples/servers/server-action-revert-resize.json index 1d9e562e03ab..76c460242cc2 100644 --- a/doc/v3/api_samples/servers/server-action-revert-resize.json +++ b/doc/v3/api_samples/servers/server-action-revert-resize.json @@ -1,3 +1,3 @@ { - "revert_resize" : null + "revertResize" : null } \ No newline at end of file diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index 20a0e403596f..0f533f89a949 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -683,9 +683,12 @@ class ServersController(wsgi.Controller): msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) + # NOTE(gmann): Returns 204 for backwards compatibility but should be 202 + # for representing async API as this API just accepts the request and + # request hypervisor driver to complete the same in async mode. @extensions.expected_errors((400, 404, 409)) - @wsgi.response(202) - @wsgi.action('confirm_resize') + @wsgi.response(204) + @wsgi.action('confirmResize') def _action_confirm_resize(self, req, id, body): context = req.environ['nova.context'] instance = self._get_server(context, req, id) @@ -698,11 +701,11 @@ class ServersController(wsgi.Controller): raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, - 'confirm_resize') + 'confirmResize') @extensions.expected_errors((400, 404, 409)) @wsgi.response(202) - @wsgi.action('revert_resize') + @wsgi.action('revertResize') def _action_revert_resize(self, req, id, body): context = req.environ['nova.context'] instance = self._get_server(context, req, id) @@ -718,7 +721,7 @@ class ServersController(wsgi.Controller): raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, - 'revert_resize') + 'revertResize') return webob.Response(status_int=202) @extensions.expected_errors((400, 404, 409)) diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py b/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py index 32ace8ac0824..46878e0d4d8a 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_server_actions.py @@ -149,22 +149,26 @@ class ServerActionsControllerTest(test.TestCase): self.mox.UnsetStubs() def test_actions_with_locked_instance(self): - actions = ['resize', 'confirm_resize', 'revert_resize', 'reboot', + actions = ['resize', 'confirmResize', 'revertResize', 'reboot', 'rebuild'] + method_translations = {'confirmResize': 'confirm_resize', + 'revertResize': 'revert_resize'} + body_map = {'resize': {'flavorRef': '2'}, 'reboot': {'type': 'HARD'}, 'rebuild': {'imageRef': self.image_uuid, 'adminPass': 'TNc53Dr8s7vw'}} args_map = {'resize': (('2'), {}), - 'confirm_resize': ((), {}), + 'confirmResize': ((), {}), 'reboot': (('HARD',), {}), 'rebuild': ((self.image_uuid, 'TNc53Dr8s7vw'), {})} for action in actions: - self.mox.StubOutWithMock(compute_api.API, action) - self._test_locked_instance(action, method=None, + method = method_translations.get(action) + self.mox.StubOutWithMock(compute_api.API, method or action) + self._test_locked_instance(action, method=method, body_map=body_map, compute_api_args_map=args_map) @@ -715,7 +719,7 @@ class ServerActionsControllerTest(test.TestCase): req, FAKE_UUID, body) def test_confirm_resize_server(self): - body = dict(confirm_resize=None) + body = dict(confirmResize=None) self.confirm_resize_called = False @@ -730,7 +734,7 @@ class ServerActionsControllerTest(test.TestCase): self.assertEqual(self.confirm_resize_called, True) def test_confirm_resize_migration_not_found(self): - body = dict(confirm_resize=None) + body = dict(confirmResize=None) def confirm_resize_mock(*args): raise exception.MigrationNotFoundByStatus(instance_id=1, @@ -746,7 +750,7 @@ class ServerActionsControllerTest(test.TestCase): req, FAKE_UUID, body) def test_confirm_resize_raises_conflict_on_invalid_state(self): - body = dict(confirm_resize=None) + body = dict(confirmResize=None) def fake_confirm_resize(*args, **kwargs): raise exception.InstanceInvalidState(attr='fake_attr', diff --git a/nova/tests/integrated/v3/api_samples/servers/server-action-confirm-resize.json.tpl b/nova/tests/integrated/v3/api_samples/servers/server-action-confirm-resize.json.tpl index 1a3a9a4ef857..432f6126e906 100644 --- a/nova/tests/integrated/v3/api_samples/servers/server-action-confirm-resize.json.tpl +++ b/nova/tests/integrated/v3/api_samples/servers/server-action-confirm-resize.json.tpl @@ -1,3 +1,3 @@ { - "confirm_resize" : null + "confirmResize" : null } diff --git a/nova/tests/integrated/v3/api_samples/servers/server-action-revert-resize.json.tpl b/nova/tests/integrated/v3/api_samples/servers/server-action-revert-resize.json.tpl index a86efc1506d3..2ddf6e5ab09e 100644 --- a/nova/tests/integrated/v3/api_samples/servers/server-action-revert-resize.json.tpl +++ b/nova/tests/integrated/v3/api_samples/servers/server-action-revert-resize.json.tpl @@ -1,3 +1,3 @@ { - "revert_resize" : null + "revertResize" : null } diff --git a/nova/tests/integrated/v3/test_servers.py b/nova/tests/integrated/v3/test_servers.py index 612a86ad909e..04a169ed7da4 100644 --- a/nova/tests/integrated/v3/test_servers.py +++ b/nova/tests/integrated/v3/test_servers.py @@ -152,13 +152,14 @@ class ServersActionsJsonTest(ServersSampleBase): def test_server_revert_resize(self): uuid = self.test_server_resize() - self._test_server_action(uuid, "revert_resize", + self._test_server_action(uuid, "revertResize", 'server-action-revert-resize') def test_server_confirm_resize(self): uuid = self.test_server_resize() - self._test_server_action(uuid, "confirm_resize", - 'server-action-confirm-resize') + self._test_server_action(uuid, "confirmResize", + 'server-action-confirm-resize', + code=204) def test_server_create_image(self): uuid = self._post_server()