diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-09-19 02:43:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-09-19 02:43:08 +0000 |
| commit | a47d9282b2ba75fa8692cc346d41385d2d51280e (patch) | |
| tree | d021fb1471ac444ea797a7479b784a03ad0eea6b | |
| parent | d79f5b87f8c584fc6dbc8d2a87cca9541ab691aa (diff) | |
| parent | e549c0ef6c1438a404c12e43bb6b2280d62bb313 (diff) | |
| download | python-heatclient-a47d9282b2ba75fa8692cc346d41385d2d51280e.tar.gz | |
Merge "Add 'cancel_update' action and command"
| -rw-r--r-- | heatclient/tests/test_shell.py | 28 | ||||
| -rw-r--r-- | heatclient/v1/actions.py | 7 | ||||
| -rw-r--r-- | heatclient/v1/shell.py | 13 |
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.') |
