Clean up arg parsing in runner client

This commit is contained in:
Thomas Jackson 2014-12-31 16:48:14 -08:00
parent 9c983c3cb4
commit 15c3637828

View File

@ -91,31 +91,12 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'kwarg must be formatted as a dictionary'
)
arglist = salt.utils.args.parse_input(arg)
def _append_kwarg(arglist, kwarg):
'''
Append the kwarg dict to the arglist
'''
# if you were passed kwarg, add it to arglist
if kwarg:
kwarg['__kwarg__'] = True
arglist.append(kwarg)
if kwarg:
try:
if isinstance(arglist[-1], dict) \
and '__kwarg__' in arglist[-1]:
for key, val in six.iteritems(kwarg):
if key in arglist[-1]:
log.warning(
'Overriding keyword argument {0!r}'.format(key)
)
arglist[-1][key] = val
else:
# No kwargs yet present in arglist
_append_kwarg(arglist, kwarg)
except IndexError:
# arglist is empty, just append
_append_kwarg(arglist, kwarg)
self._verify_fun(fun)
args, kwargs = salt.minion.load_args_and_kwargs(
self.functions[fun], arglist, pub_data
)
@ -230,9 +211,9 @@ class Runner(RunnerClient):
else:
try:
low = {'fun': self.opts['fun']}
arglist = salt.utils.args.parse_input(self.opts['arg'])
args, kwargs = salt.minion.load_args_and_kwargs(
self.functions[low['fun']], arglist
self.functions[low['fun']],
salt.utils.args.parse_input(self.opts['arg']),
)
low['args'] = args
low.update(kwargs)