Add publish.runner wrapper function for salt-ssh

This commit is contained in:
Colton Myers 2014-12-16 16:09:06 -07:00
parent 215a4d0e89
commit 8d8b1be86b

View File

@ -12,8 +12,10 @@ No access control is needed because calls cannot originate from the minions.
# Import python libs
import copy
import logging
# Import salt libs
import salt.client.ssh
import salt.runner
log = logging.getLogger(__name__)
@ -206,3 +208,27 @@ def full_data(tgt,
timeout=timeout,
form='full',
roster=roster)
def runner(fun, arg=None, timeout=5):
'''
Execute a runner on the master and return the data from the runnr function
CLI Example:
.. code-block:: bash
salt-ssh '*' publish.runner jobs.lookup_jid 20140916125524463507
'''
# Form args as list
if not isinstance(arg, list):
arg = [salt.utils.args.yamlify_arg(arg)]
else:
arg = [salt.utils.args.yamlify_arg(x) for x in arg]
if len(arg) == 1 and arg[0] is None:
arg = []
# Create and run the runner
runner = salt.runner.RunnerClient(__opts__['__master_opts__'])
return runner.cmd(fun, arg)