Merge pull request #27417 from whiteinge/bp-25243

Backport #25243 into 2015.8
This commit is contained in:
Mike Place 2015-09-28 13:15:53 -06:00
commit aefe6d794a
4 changed files with 28 additions and 27 deletions

View file

@ -262,7 +262,7 @@ def parse_args_and_kwargs(func, args, data=None):
return load_args_and_kwargs(func, args, data=data)
def load_args_and_kwargs(func, args, data=None):
def load_args_and_kwargs(func, args, data=None, ignore_invalid=False):
'''
Detect the args and kwargs that need to be passed to a function call, and
check them against what was passed.
@ -316,7 +316,7 @@ def load_args_and_kwargs(func, args, data=None):
else:
_args.append(arg)
if invalid_kwargs:
if invalid_kwargs and not ignore_invalid:
salt.utils.invalid_kwargs(invalid_kwargs)
if argspec.keywords and isinstance(data, dict):

View file

@ -141,10 +141,6 @@ class NetapiClient(object):
:return: Returns the result from the runner module
'''
kwargs['fun'] = fun
if 'kwargs' not in kwargs:
kwargs['kwargs'] = {}
if 'args' not in kwargs:
kwargs['args'] = []
runner = salt.runner.RunnerClient(self.opts)
return runner.cmd_sync(kwargs, timeout=timeout)
@ -160,10 +156,6 @@ class NetapiClient(object):
:return: event data and a job ID for the executed function.
'''
kwargs['fun'] = fun
if 'kwargs' not in kwargs:
kwargs['kwargs'] = {}
if 'args' not in kwargs:
kwargs['args'] = []
runner = salt.runner.RunnerClient(self.opts)
return runner.cmd_async(kwargs)

View file

@ -1142,25 +1142,18 @@ class Jobs(LowDataAdapter):
- 2
- 6.9141387939453125e-06
'''
timeout = int(timeout) if timeout.isdigit() else None
lowstate = [{
'client': 'runner',
'fun': 'jobs.lookup_jid' if jid else 'jobs.list_jobs',
'jid': jid,
}]
if jid:
lowstate = [{
'client': 'runner',
'fun': 'jobs.lookup_jid',
'args': (jid,),
'timeout': timeout,
}, {
lowstate.append({
'client': 'runner',
'fun': 'jobs.list_job',
'args': (jid,),
'timeout': timeout,
}]
else:
lowstate = [{
'client': 'runner',
'fun': 'jobs.list_jobs',
'timeout': timeout,
}]
'jid': jid,
})
cherrypy.request.lowstate = lowstate
job_ret_info = list(self.exec_lowstate(

View file

@ -59,8 +59,24 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
auth_creds = dict([(i, low.pop(i)) for i in [
'username', 'password', 'eauth', 'token', 'client',
] if i in low])
reformatted_low = {'fun': low.pop('fun')}
fun = low.pop('fun')
reformatted_low = {'fun': fun}
reformatted_low.update(auth_creds)
# Support old style calls where arguments could be specified in 'low' top level
if not low.get('args') and not low.get('kwargs'): # not specified or empty
verify_fun(self.functions, fun)
args, kwargs = salt.minion.load_args_and_kwargs(
self.functions[fun],
salt.utils.args.condition_input([], low),
self.opts,
ignore_invalid=True
)
low['args'] = args
low['kwargs'] = kwargs
if 'kwargs' not in low:
low['kwargs'] = {}
if 'args' not in low:
low['args'] = []
reformatted_low['kwarg'] = low
return reformatted_low