summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-09-19 02:43:08 +0000
committerGerrit Code Review <review@openstack.org>2014-09-19 02:43:08 +0000
commita47d9282b2ba75fa8692cc346d41385d2d51280e (patch)
treed021fb1471ac444ea797a7479b784a03ad0eea6b
parentd79f5b87f8c584fc6dbc8d2a87cca9541ab691aa (diff)
parente549c0ef6c1438a404c12e43bb6b2280d62bb313 (diff)
downloadpython-heatclient-a47d9282b2ba75fa8692cc346d41385d2d51280e.tar.gz
Merge "Add 'cancel_update' action and command"
-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.')