From: Steven Hardy Date: Fri, 28 Jun 2013 10:15:40 +0000 (+0100) Subject: api : Add actions resume support X-Git-Tag: 2014.1~405^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ba74d7a18c4ba70605fd923794054304504c5b1c;p=openstack-build%2Fheat-build.git api : Add actions resume support Add support for resume action using a similar interface to that provided by nova for the admin actions extension. So a body of {'resume': None} will suspend the stack, see http://api.openstack.org/api-ref.html Change-Id: I89bbafbe2f8b2503f241659a36b83ceab605e763 blueprint: stack-suspend-resume --- diff --git a/heat/api/openstack/v1/actions.py b/heat/api/openstack/v1/actions.py index acb74607..530951ba 100644 --- a/heat/api/openstack/v1/actions.py +++ b/heat/api/openstack/v1/actions.py @@ -27,7 +27,7 @@ class ActionController(object): Implements the API for stack actions """ - ACTIONS = (SUSPEND,) = ('suspend',) + ACTIONS = (SUSPEND, RESUME) = ('suspend', 'resume') def __init__(self, options): self.options = options @@ -55,6 +55,11 @@ class ActionController(object): res = self.engine.stack_suspend(req.context, identity) except rpc_common.RemoteError as ex: return util.remote_error(ex) + elif ac == self.RESUME: + try: + res = self.engine.stack_resume(req.context, identity) + except rpc_common.RemoteError as ex: + return util.remote_error(ex) else: raise exc.HTTPInternalServerError(_("Unexpected action %s") % ac) diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py index 64ff6484..f6c413f5 100644 --- a/heat/tests/test_api_openstack_v1.py +++ b/heat/tests/test_api_openstack_v1.py @@ -2139,6 +2139,30 @@ class ActionControllerTest(ControllerTest, HeatTestCase): self.assertEqual(result, None) self.m.VerifyAll() + def test_action_resume(self): + res_name = 'WikiDatabase' + stack_identity = identifier.HeatIdentifier(self.tenant, + 'wordpress', '1') + body = {'resume': None} + req = self._post(stack_identity._tenant_path() + '/actions', + data=json.dumps(body)) + + self.m.StubOutWithMock(rpc, 'call') + rpc.call(req.context, self.topic, + {'namespace': None, + 'method': 'stack_resume', + 'args': {'stack_identity': stack_identity}, + 'version': self.api_version}, + None).AndReturn(None) + self.m.ReplayAll() + + result = self.controller.action(req, tenant_id=self.tenant, + stack_name=stack_identity.stack_name, + stack_id=stack_identity.stack_id, + body=body) + self.assertEqual(result, None) + self.m.VerifyAll() + def test_action_badaction(self): res_name = 'WikiDatabase' stack_identity = identifier.HeatIdentifier(self.tenant,