diff --git a/heatclient/v1/actions.py b/heatclient/v1/actions.py new file mode 100644 index 00000000..b35a044a --- /dev/null +++ b/heatclient/v1/actions.py @@ -0,0 +1,50 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from heatclient.common import base +from heatclient.v1 import stacks + +DEFAULT_PAGE_SIZE = 20 + + +class Action(base.Resource): + def __repr__(self): + return "" % self._info + + def update(self, **fields): + self.manager.update(self, **fields) + + def delete(self): + return self.manager.delete(self) + + def data(self, **kwargs): + return self.manager.data(self, **kwargs) + + +class ActionManager(stacks.StackChildManager): + resource_class = Action + + def suspend(self, stack_id): + """Suspend a stack.""" + body = {'suspend': None} + resp, body = self.api.json_request('POST', + '/stacks/%s/actions' % stack_id, + body=body) + + def resume(self, stack_id): + """Resume a stack.""" + body = {'resume': None} + resp, body = self.api.json_request('POST', + '/stacks/%s/actions' % stack_id, + body=body) diff --git a/heatclient/v1/client.py b/heatclient/v1/client.py index f44208d4..48b0fbb9 100644 --- a/heatclient/v1/client.py +++ b/heatclient/v1/client.py @@ -14,6 +14,7 @@ # under the License. from heatclient.common import http +from heatclient.v1 import actions from heatclient.v1 import events from heatclient.v1 import resources from heatclient.v1 import stacks @@ -35,3 +36,4 @@ class Client(http.HTTPClient): self.stacks = stacks.StackManager(self) self.resources = resources.ResourceManager(self) self.events = events.EventManager(self) + self.actions = actions.ActionManager(self) diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 55595318..c9284834 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -166,6 +166,31 @@ def do_stack_delete(hc, args): do_stack_list(hc) +@utils.arg('id', metavar='', + help='Name or ID of stack to suspend.') +def do_action_suspend(hc, args): + '''Suspend the stack.''' + fields = {'stack_id': args.id} + try: + hc.actions.suspend(**fields) + except exc.HTTPNotFound: + raise exc.CommandError('Stack not found: %s' % args.id) + else: + do_stack_list(hc) + + +@utils.arg('id', metavar='', help='Name or ID of stack to resume.') +def do_action_resume(hc, args): + '''Resume the stack.''' + fields = {'stack_id': args.id} + try: + hc.actions.resume(**fields) + except exc.HTTPNotFound: + raise exc.CommandError('Stack not found: %s' % args.id) + else: + do_stack_list(hc) + + @utils.arg('id', metavar='', help='Name or ID of stack to describe.') def do_describe(hc, args):