Backwards compatibility with args as well.

With format_call you can pass in positional args as kwargs with the key being the name of the variable in the function call.
This commit is contained in:
Thomas Jackson 2015-01-01 10:48:51 -08:00
parent 82521ea205
commit 14efa520f7

View File

@ -218,7 +218,14 @@ class SyncClientMixin(object):
# from that since the caller knows what is an arg vs a kwarg, but
# while we make the transition we will load "kwargs" using format_call
# if there are no kwargs in the low object passed in
f_call = None
if 'args' not in low:
f_call = salt.utils.format_call(self.functions[fun], low)
args = f_call.get('args', ())
else:
args = low['args']
if 'kwargs' not in low:
if f_call is None:
f_call = salt.utils.format_call(self.functions[fun], low)
kwargs = f_call.get('kwargs', {})
@ -232,7 +239,7 @@ class SyncClientMixin(object):
else:
kwargs = low['kwargs']
data['return'] = self.functions[fun](*low.get('args', ()), **kwargs)
data['return'] = self.functions[fun](*args, **kwargs)
data['success'] = True
except Exception as exc:
data['return'] = 'Exception occurred in {0} {1}: {2}: {3}'.format(