Skip to content

Instantly share code, notes, and snippets.

@pcn

pcn/code.md Secret

Last active February 7, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcn/e5a3036dfc48cc9bfd1e57011bd5f80a to your computer and use it in GitHub Desktop.
Save pcn/e5a3036dfc48cc9bfd1e57011bd5f80a to your computer and use it in GitHub Desktop.
example of using salt-api's runner_async

So with an active API connection (I'm using libpepper, but the args should be the same if you're curling the API directly):

In [46]: s.low([{"fun":'survey.hash', "args": ["tagwrite*", "healthcheck.dw"], "client": 'runner_async'}], path="/")
Out[46]: 
{u'return': [{u'jid': u'20170207151628727872',
   u'tag': u'salt/run/20170207151628727872'}]}

In [47]: s.low([{"client": "runner", "fun":'jobs.lookup_jid', "jid": "20170207151628727872"}], path="/")
Out[47]: 
{u'return': [{u'ip-172-26-204-6.us-west-2.compute.internal_master': {u'_stamp': u'2017-02-07T15:16:29.359782',
    u'fun': u'runner.survey.hash',
    u'fun_args': [u'tagwrite*', u'healthcheck.dw'],
    u'jid': u'20170207151628727872',
    u'return': [{u'pool': [u'tagwrite-1-dogfood',
       u'tagwrite-2-dogfood',
       u'tagwrite-3-dogfood',
       u'tagwrite-4-dogfood'],
      u'result': u"{'shard-0': {'healthy': True}, 'cassandra: datastax': {'healthy': True}, 'deadlocks': {'healthy': True}, 'maintenance': {'healthy': True}, 'usersdb': {'healthy': True}}"}],
    u'success': True,
    u'user': u'saltapi'}}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment