From 73a0d69ce110000086004c90da7579c91042c17b Mon Sep 17 00:00:00 2001 From: Oleksii Chuprykov Date: Tue, 12 Jan 2016 15:05:06 +0200 Subject: [PATCH] Add resolve_outputs parameter to stack get method Also add --no-resolve-outputs parameter to heat stack-show command to let user get stack without outputs. @APIImpact, @DOCImpact Depends-On: I03104efc535a7bd4326cbec56c01cd887db38ab6 Change-Id: I6c715fe90e42259e744b76924673194d0a81c07e --- heatclient/tests/unit/test_shell.py | 40 +++++++++++++++++++++++++++++ heatclient/v1/shell.py | 5 +++- heatclient/v1/stacks.py | 9 +++++-- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py index 908f4b7a..e3008ddf 100644 --- a/heatclient/tests/unit/test_shell.py +++ b/heatclient/tests/unit/test_shell.py @@ -784,6 +784,46 @@ class ShellTestUserPass(ShellBase): for r in required: self.assertRegexpMatches(list_text, r) + def test_stack_show_without_outputs(self): + self.register_keystone_auth_fixture() + resp_dict = {"stack": { + "id": "1", + "stack_name": "teststack", + "stack_status": 'CREATE_COMPLETE', + "creation_time": "2012-10-25T01:58:47Z" + }} + resp = fakes.FakeHTTPResponse( + 200, + 'OK', + {'content-type': 'application/json'}, + jsonutils.dumps(resp_dict)) + params = {'resolve_outputs': False} + if self.client == http.SessionClient: + self.client.request( + '/stacks/teststack/1', + 'GET', params=params).AndReturn(resp) + else: + self.client.json_request( + 'GET', '/stacks/teststack/1', params=params + ).AndReturn((resp, resp_dict)) + + self.m.ReplayAll() + + list_text = self.shell( + 'stack-show teststack/1 --no-resolve-outputs') + + required = [ + 'id', + 'stack_name', + 'stack_status', + 'creation_time', + 'teststack', + 'CREATE_COMPLETE', + '2012-10-25T01:58:47Z' + ] + for r in required: + self.assertRegexpMatches(list_text, r) + def _output_fake_response(self, output_key): outputs = [ diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 1e8a69af..998065f4 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -387,9 +387,12 @@ def do_action_check(hc, args): @utils.arg('id', metavar='', help=_('Name or ID of stack to describe.')) +@utils.arg('--no-resolve-outputs', action="store_true", + help='Do not resolve outputs of the stack.') def do_stack_show(hc, args): '''Describe the stack.''' - fields = {'stack_id': args.id} + fields = {'stack_id': args.id, + 'resolve_outputs': not args.no_resolve_outputs} _do_stack_show(hc, fields) diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index bd1cf805..5a4f9c59 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -252,12 +252,17 @@ class StackManager(StackChildManager): body = utils.get_response_body(resp) return body - def get(self, stack_id): + def get(self, stack_id, resolve_outputs=True): """Get the metadata for a specific stack. :param stack_id: Stack ID to lookup + :param resolve_outputs: If True, then outputs for this + stack will be resolved """ - resp = self.client.get('/stacks/%s' % stack_id) + kwargs = {} + if not resolve_outputs: + kwargs['params'] = {"resolve_outputs": False} + resp = self.client.get('/stacks/%s' % stack_id, **kwargs) body = utils.get_response_body(resp) return Stack(self, body.get('stack'))