Skip to content

Commit

Permalink
make outputter behave more like salt
Browse files Browse the repository at this point in the history
runner output should be identical now
  • Loading branch information
mattp- committed Mar 12, 2019
1 parent c4790e7 commit ee498f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pepper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions pepper/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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(
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit ee498f8

Please sign in to comment.