Add full_return support to RunnerClient.cmd_sync to expose exit code

This commit is contained in:
Seth House 2017-02-17 19:03:09 -07:00
parent e444e7da62
commit 065e24d101
3 changed files with 6 additions and 6 deletions

View File

@ -138,7 +138,7 @@ class SyncClientMixin(object):
salt.utils.error.raise_error(**ret['error'])
return ret
def cmd_sync(self, low, timeout=None):
def cmd_sync(self, low, timeout=None, full_return=False):
'''
Execute a runner function synchronously; eauth is respected
@ -166,7 +166,7 @@ class SyncClientMixin(object):
"RunnerClient job '{0}' timed out".format(job['jid']),
jid=job['jid'])
return ret['data']['return']
return ret if full_return else ret['data']['return']
def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):
'''

View File

@ -125,7 +125,7 @@ class NetapiClient(object):
disable_custom_roster=True)
return ssh_client.cmd_sync(kwargs)
def runner(self, fun, timeout=None, **kwargs):
def runner(self, fun, timeout=None, full_return=False, **kwargs):
'''
Run `runner modules <all-salt.runners>` synchronously
@ -138,7 +138,7 @@ class NetapiClient(object):
'''
kwargs['fun'] = fun
runner = salt.runner.RunnerClient(self.opts)
return runner.cmd_sync(kwargs, timeout=timeout)
return runner.cmd_sync(kwargs, timeout=timeout, full_return=full_return)
def runner_async(self, fun, **kwargs):
'''

View File

@ -113,7 +113,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
return mixins.AsyncClientMixin.cmd_async(self, reformatted_low)
def cmd_sync(self, low, timeout=None):
def cmd_sync(self, low, timeout=None, full_return=False):
'''
Execute a runner function synchronously; eauth is respected
@ -130,7 +130,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
})
'''
reformatted_low = self._reformat_low(low)
return mixins.SyncClientMixin.cmd_sync(self, reformatted_low, timeout)
return mixins.SyncClientMixin.cmd_sync(self, reformatted_low, timeout, full_return)
def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):
'''