From ee498f86c0dec0830938784b459a0af93f9f304f Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Tue, 12 Mar 2019 14:07:20 -0400 Subject: [PATCH] make outputter behave more like salt runner output should be identical now --- pepper/cli.py | 4 ++-- pepper/script.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pepper/cli.py b/pepper/cli.py index f831661..76bc617 100644 --- a/pepper/cli.py +++ b/pepper/cli.py @@ -600,7 +600,7 @@ def poll_for_returns(self, api, load): exit_code = exit_code if self.options.fail_if_minions_dont_respond else 0 failed = list(set(ret_nodes) ^ set(nodes)) if failed: - yield exit_code, {'Failed': failed} + yield exit_code, [{'Failed': failed}] def login(self, api): login = api.token if self.options.userun else api.login @@ -664,7 +664,7 @@ def run(self): load = self.parse_cmd(api) for entry in load: - if entry.get('client', '').startswith('local'): + if not entry.get('client', '').startswith('wheel'): entry['full_return'] = True if self.options.fail_if_minions_dont_respond: diff --git a/pepper/script.py b/pepper/script.py index 322cb99..21afe63 100755 --- a/pepper/script.py +++ b/pepper/script.py @@ -54,6 +54,7 @@ def __call__(self): logger.debug('Use Salt outputters') result = json.loads(result) + # unwrap ret in some cases if 'return' in result: result = result['return'] @@ -63,7 +64,6 @@ def __call__(self): for minionid, minionret in ret.items(): # rest_tornado doesnt return full_return directly # it will always be from get_event, so the output differs slightly - logger.error(minionret) if isinstance(minionret, dict) and 'return' in minionret: # version >= 2017.7 salt.output.display_output( @@ -86,9 +86,13 @@ def __call__(self): opts=self.opts ) elif 'data' in ret: + # unfold runners + outputter = ret.get('outputter', 'nested') + if isinstance(ret['data'], dict) and 'return' in ret['data']: + ret = ret['data']['return'] salt.output.display_output( - ret['data'], - self.cli.options.output or ret.get('outputter', 'nested'), + ret, + self.cli.options.output or outputter, opts=self.opts ) else: @@ -100,7 +104,7 @@ def __call__(self): else: salt.output.display_output( {self.cli.options.client: ret}, - 'nested', + self.cli.options.output or 'nested', opts=self.opts, ) else: