diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py index 7a94144c..735b0879 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 7be7621e..d8576027 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'))