mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #16331 from whiteinge/wrap-runner-master_call
Fix the call to RunnerClient().master_call()
This commit is contained in:
commit
505b2e476d
@ -1002,8 +1002,7 @@ class LocalFuncs(object):
|
||||
runner_client = salt.runner.RunnerClient(self.opts)
|
||||
return runner_client.async(
|
||||
fun,
|
||||
# load.get('kwarg', {}),
|
||||
load,
|
||||
load.get('kwarg', {}),
|
||||
token['name'])
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while '
|
||||
|
@ -174,7 +174,18 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
|
||||
self.opts['sock_dir'],
|
||||
self.opts['transport'],
|
||||
opts=self.opts)
|
||||
job = self.master_call(**low)
|
||||
|
||||
# The master_call function here has a different function signature than
|
||||
# on WheelClient. So extract all the eauth keys and the fun key and
|
||||
# assume everything else is a kwarg to pass along to the runner
|
||||
# function to be called.
|
||||
auth_creds = dict([(i, low.pop(i))
|
||||
for i in ['username', 'password', 'eauth', 'token'] if i in low])
|
||||
reformatted_low = {'fun': low.pop('fun')}
|
||||
reformatted_low.update(auth_creds)
|
||||
reformatted_low['kwarg'] = low
|
||||
|
||||
job = self.master_call(**reformatted_low)
|
||||
ret_tag = tagify('ret', base=job['tag'])
|
||||
|
||||
timelimit = time.time() + (timeout or 300)
|
||||
|
10
salt/runners/test.py
Normal file
10
salt/runners/test.py
Normal file
@ -0,0 +1,10 @@
|
||||
def arg(*args, **kwargs):
|
||||
'''
|
||||
Output the given args and kwargs
|
||||
'''
|
||||
ret = {
|
||||
'args': args,
|
||||
'kwargs': kwargs,
|
||||
}
|
||||
print ret
|
||||
return ret
|
@ -77,6 +77,18 @@ class RunnerModuleTest(integration.ClientCase):
|
||||
|
||||
self.runner.cmd_async(low)
|
||||
|
||||
def test_cmd_sync_w_arg(self):
|
||||
low = {
|
||||
'fun': 'test.arg',
|
||||
'foo': 'Foo!',
|
||||
'bar': 'Bar!',
|
||||
}
|
||||
low.update(self.eauth_creds)
|
||||
|
||||
ret = self.runner.cmd_sync(low)
|
||||
self.assertEqual(ret['kwargs']['foo'], 'Foo!')
|
||||
self.assertEqual(ret['kwargs']['bar'], 'Bar!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
Loading…
Reference in New Issue
Block a user