]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
api : Add actions resume support
authorSteven Hardy <shardy@redhat.com>
Fri, 28 Jun 2013 10:15:40 +0000 (11:15 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 1 Jul 2013 10:35:50 +0000 (11:35 +0100)
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

heat/api/openstack/v1/actions.py
heat/tests/test_api_openstack_v1.py

index acb746074c9932ee741e7b4f1e242c30bf23f578..530951ba4d5afef4352d5e812a00f95edcdb3f29 100644 (file)
@@ -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)
 
index 64ff64847450162f6cc28ad175c27b735807bef9..f6c413f5ec765b51c4e967c7275530234ca0d2ef 100644 (file)
@@ -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,