summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2014-09-16 13:24:17 +1200
committerSteve Baker <sbaker@redhat.com>2014-09-18 15:22:15 +1200
commite549c0ef6c1438a404c12e43bb6b2280d62bb313 (patch)
treea3ef3af48e4c2f2b510f850235e6d98e7d74dc6f
parenta30d04d79e4e95b088e08e0a76c6e82bf8d2dd95 (diff)
downloadpython-heatclient-e549c0ef6c1438a404c12e43bb6b2280d62bb313.tar.gz
Add 'cancel_update' action and command
Change-Id: I66590110cc065622a8af03286c272a658bc12646 Implements: blueprint cancel-update-stack
-rw-r--r--heatclient/tests/test_shell.py28
-rw-r--r--heatclient/v1/actions.py7
-rw-r--r--heatclient/v1/shell.py13
3 files changed, 48 insertions, 0 deletions
diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py
index 77e3bd2..701bb65 100644
--- a/heatclient/tests/test_shell.py
+++ b/heatclient/tests/test_shell.py
@@ -1595,6 +1595,34 @@ class ShellTestUserPass(ShellBase):
self.assertRegexpMatches(update_text, r)
@httpretty.activate
+ def test_stack_cancel_update(self):
+ self.register_keystone_auth_fixture()
+ expected_data = {'cancel_update': None}
+ resp = fakes.FakeHTTPResponse(
+ 202,
+ 'Accepted',
+ {},
+ 'The request is accepted for processing.')
+ http.HTTPClient.json_request(
+ 'POST', '/stacks/teststack2/actions',
+ data=expected_data
+ ).AndReturn((resp, None))
+ fakes.script_heat_list()
+
+ self.m.ReplayAll()
+
+ update_text = self.shell('stack-cancel-update teststack2')
+
+ required = [
+ 'stack_name',
+ 'id',
+ 'teststack2',
+ '1'
+ ]
+ for r in required:
+ self.assertRegexpMatches(update_text, r)
+
+ @httpretty.activate
def test_stack_delete(self):
self.register_keystone_auth_fixture()
resp = fakes.FakeHTTPResponse(
diff --git a/heatclient/v1/actions.py b/heatclient/v1/actions.py
index afae9a6..9c7028f 100644
--- a/heatclient/v1/actions.py
+++ b/heatclient/v1/actions.py
@@ -46,3 +46,10 @@ class ActionManager(stacks.StackChildManager):
resp, body = self.client.json_request('POST',
'/stacks/%s/actions' % stack_id,
data=body)
+
+ def cancel_update(self, stack_id):
+ """Cancel running update of a stack."""
+ body = {'cancel_update': None}
+ resp, body = self.client.json_request('POST',
+ '/stacks/%s/actions' % stack_id,
+ data=body)
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 93b5d61..5f728f4 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -464,6 +464,19 @@ def do_stack_update(hc, args):
do_stack_list(hc)
+@utils.arg('id', metavar='<NAME or ID>',
+ help='Name or ID of stack to cancel update for.')
+def do_stack_cancel_update(hc, args):
+ '''Cancel currently running update of the stack.'''
+ fields = {'stack_id': args.id}
+ try:
+ hc.actions.cancel_update(**fields)
+ except exc.HTTPNotFound:
+ raise exc.CommandError('Stack not found: %s' % args.id)
+ else:
+ do_stack_list(hc)
+
+
def do_list(hc):
'''DEPRECATED! Use stack-list instead.'''
logger.warning('DEPRECATED! Use stack-list instead.')