From 065e24d10145cf5abe6712708014c970485b68f9 Mon Sep 17 00:00:00 2001 From: Seth House Date: Fri, 17 Feb 2017 19:03:09 -0700 Subject: [PATCH] Add full_return support to RunnerClient.cmd_sync to expose exit code --- salt/client/mixins.py | 4 ++-- salt/netapi/__init__.py | 4 ++-- salt/runner.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/salt/client/mixins.py b/salt/client/mixins.py index 13041c4e03..7e815ce8b1 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -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): ''' diff --git a/salt/netapi/__init__.py b/salt/netapi/__init__.py index 49cab3c439..830f287e05 100644 --- a/salt/netapi/__init__.py +++ b/salt/netapi/__init__.py @@ -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 ` 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): ''' diff --git a/salt/runner.py b/salt/runner.py index fd16f21aba..f0f9b919c8 100644 --- a/salt/runner.py +++ b/salt/runner.py @@ -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): '''