I am new to Salt. How do I get the output of state.highstate using python? Can I get the output display as a string using LocalClient? it seems like I need to call salt.output.highstate.output in Salt but how do I do that in python?
Here is what I have tried:
import salt.client
local = salt.client.LocalClient()
ret = local.cmd('*', 'output.highstate.output')
The return I got back was just saying output.highstate.output is not available. Is there any other way to get output from python code directly? Thanks.
There are a number of ways to interact with Salt from Python. In general it gives you a generator of dictionaries, it won't format it for you.
The alternate methods don't seem to be documented -- stick with local.cmd()
if you can.
Here's an example of cmd_full_return
(source):
from pprint import pprint
import salt.client
local = salt.client.LocalClient()
pprint( local.cmd_full_return(
'*', 'test.ping', verbose=True,
) )
Executing job with jid 20140825132240132013
-------------------------------------------
{'palabras': {'ret': True, 'success': True}}