From c1e793f3b81403d32d665679001264716aa38505 Mon Sep 17 00:00:00 2001 From: Crag Wolfe Date: Sat, 28 Jan 2017 00:37:47 -0500 Subject: Don't always resolve outputs when showing a stack * Whenever a stack is created/updated/adopted, a call to show the stack is made. Do not resolve the outputs when showing the stack in this case because: * If we are not waiting (there is no --wait arg) for the stack to complete after a create/update/adopt command and immediately showing the stack, resolving the outputs is just incurring a pointless processing hit on the server (ultimately heat-engine) and delaying a response to the client. * Whether we --wait or or not, we only show "short" stack info which doesn't include outputs anyway. So, let's avoid the processing/time overhead of resolving the outputs. (In theory, with --wait we might want to show "long" output with stack outputs afterwards, but that would be additional functionality that should be handled in a different patch) * Add the --no-resolve-outputs option to "stack show" which already exists in the legacy heat stack-show command. Change-Id: Id0661b11fd3cece0df3981488de6976219556d7e Closes-Bug: #1659896 Closes-Bug: #1659899 --- heatclient/osc/v1/stack.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'heatclient/osc') diff --git a/heatclient/osc/v1/stack.py b/heatclient/osc/v1/stack.py index cf03cec..f8cf9e3 100644 --- a/heatclient/osc/v1/stack.py +++ b/heatclient/osc/v1/stack.py @@ -380,19 +380,28 @@ class ShowStack(command.ShowOne): metavar='', help='Stack to display (name or ID)', ) + parser.add_argument( + '--no-resolve-outputs', action="store_true", + help=_('Do not resolve outputs of the stack.') + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)", parsed_args) heat_client = self.app.client_manager.orchestration - return _show_stack(heat_client, stack_id=parsed_args.stack, - format=parsed_args.formatter) + return _show_stack( + heat_client, stack_id=parsed_args.stack, + format=parsed_args.formatter, + resolve_outputs=(not parsed_args.no_resolve_outputs)) -def _show_stack(heat_client, stack_id, format='', short=False): +def _show_stack(heat_client, stack_id, format='', short=False, + resolve_outputs=True): try: - data = heat_client.stacks.get(stack_id=stack_id) + _resolve_outputs = not short and resolve_outputs + data = heat_client.stacks.get(stack_id=stack_id, + resolve_outputs=_resolve_outputs) except heat_exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % stack_id) else: @@ -408,11 +417,10 @@ def _show_stack(heat_client, stack_id, format='', short=False): ] if not short: - columns += [ - 'parameters', - 'outputs', - 'links', - ] + columns.append('parameters') + if _resolve_outputs: + columns.append('outputs') + columns.append('links') exclude_columns = ('template_description',) for key in data.to_dict(): -- cgit v1.2.1