Fix "revertResize/confirmResize" for V2.1 API
"revertResize/confirmResize" server actions were missed for V2.1 API. This patch converts "revertResize/confirmResize" server action for V2.1 API The differences between v2 and v3 are described on the wiki page https://wiki.openstack.org/wiki/NovaAPIv2tov3. Change-Id: I24bdb5b28fafeb60ea7b4ff044b12a519498e592 Closes-Bug: #1367642
This commit is contained in:
parent
42cec80e6c
commit
61b2824a1f
@ -1,3 +1,3 @@
|
||||
{
|
||||
"confirm_resize" : null
|
||||
"confirmResize" : null
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"revert_resize" : null
|
||||
"revertResize" : null
|
||||
}
|
@ -681,9 +681,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)
|
||||
@ -696,11 +699,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)
|
||||
@ -716,7 +719,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))
|
||||
|
@ -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',
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"confirm_resize" : null
|
||||
"confirmResize" : null
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"revert_resize" : null
|
||||
"revertResize" : null
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user