@@ -50,13 +50,29 @@ def output(self):
5050 def __call__ (self ):
5151 try :
5252 for exit_code , result in self .cli .run ():
53- if HAS_SALT and not self .cli .options .userun and self .opts :
54- logger .info ('Use Salt outputters' )
55- for ret in json .loads (result )['return' ]:
53+ if HAS_SALT and self .opts :
54+ logger .debug ('Use Salt outputters' )
55+ result = json .loads (result )
56+
57+ if 'return' in result :
58+ result = result ['return' ]
59+
60+ for ret in result :
5661 if isinstance (ret , dict ):
57- if self .cli .options .client == 'local' :
62+ if self .cli .options .client . startswith ( 'local' ) :
5863 for minionid , minionret in ret .items ():
59- if isinstance (minionret , dict ) and 'ret' in minionret :
64+ # rest_tornado doesnt return full_return directly
65+ # it will always be from get_event, so the output differs slightly
66+ logger .error (minionret )
67+ if isinstance (minionret , dict ) and 'return' in minionret :
68+ # version >= 2017.7
69+ salt .output .display_output (
70+ {minionid : minionret ['return' ]},
71+ self .cli .options .output or minionret .get ('out' , None ) or 'nested' ,
72+ opts = self .opts
73+ )
74+ # cherrypy returns with ret via full_return
75+ elif isinstance (minionret , dict ) and 'ret' in minionret :
6076 # version >= 2017.7
6177 salt .output .display_output (
6278 {minionid : minionret ['ret' ]},
@@ -95,7 +111,7 @@ def __call__(self):
95111 print (result )
96112 if exit_code is not None :
97113 if exit_code == 0 :
98- return PepperRetcode ().validate (self .cli .options , json . loads ( result )[ 'return' ] )
114+ return PepperRetcode ().validate (self .cli .options , result )
99115 return exit_code
100116 except (PepperException , PepperAuthException , PepperArgumentsException ) as exc :
101117 print ('Pepper error: {0}' .format (exc ), file = sys .stderr )
0 commit comments