You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using salt API to run commands like cloud.list_locations using runner client. The output is perfectly accurate. My concern is with return value.
When I run the cloud.list_locations I get a list of locations with no other detail. Along with the output I want to know the return value the API call gives so that I can use it to determine whether the call was successful or not. I can then use it to update other integrated applications.
So doest salt API call give a return value? If yes how to access it?
Setup
(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)
Steps to Reproduce Issue
(Include debug logs if possible and relevant.)
Versions Report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
The exit code is not currently exposed by Salt's public-facing API methods. It is a newer addition and still unfinished and undocumented (see #18510), although it is still useful in it's current state and this is a recurring ask. We'll get it added.
Thanks for cross-linking those issues! This turned out to be much easier than I first thought. I tested this addition from salt-api and the extra return output Just Worked (TM). We might want a convenience in salt-api somewhere to avoid having to pass the extra kwarg all the time.
@whiteinge Can you give an example salt-api call to trigger the full_return=True functionality? In adding the bits from #39492 and then sending JSON like:
Activity
whiteinge commentedon Feb 16, 2017
The exit code is not currently exposed by Salt's public-facing API methods. It is a newer addition and still unfinished and undocumented (see #18510), although it is still useful in it's current state and this is a recurring ask. We'll get it added.
whiteinge commentedon Feb 18, 2017
PR above adds an initial implementation of how to expose this info.
mchugh19 commentedon Feb 18, 2017
Also looks like a start to resolve #37043
whiteinge commentedon Feb 18, 2017
Thanks for cross-linking those issues! This turned out to be much easier than I first thought. I tested this addition from salt-api and the extra return output Just Worked (TM). We might want a convenience in salt-api somewhere to avoid having to pass the extra kwarg all the time.
rbjorklin commentedon Apr 3, 2017
@whiteinge Have your additions been merged into 2016.11 or will they be released with the upcomming 2017.xx release?
whiteinge commentedon Apr 3, 2017
2017.xx (Nitrogen). Thanks for asking -- I forgot to add this to the upcoming release notes.
mchugh19 commentedon Apr 6, 2017
@whiteinge Can you give an example salt-api call to trigger the full_return=True functionality? In adding the bits from #39492 and then sending JSON like:
salt-api sends back
{"return": ["Exception occurred in runner salt.cmd: Traceback (most recent call last):\n File "/usr/lib/python2.7/dist-packages/salt/client/mixins.py", line 395, in _low\n data['return'] = self.functions[fun](*args, **kwargs)\n File "/usr/lib/python2.7/dist-packages/salt/runners/salt.py", line 67, in cmd\n utils=utils(opts)).get(fun)(*args, **kws)\nTypeError: ping() takes no arguments (1 given)\n"]}
While sending JSON for cmd.run, doesn't show the full_return functionality at all:
whiteinge commentedon Apr 6, 2017
The
argandkwargvalues are sent to the module that is being invoked but this addition is a kwarg on the class itself so it should be top-level: