Merge pull request #16331 from whiteinge/wrap-runner-master_call

Fix the call to RunnerClient().master_call()
This commit is contained in:
Thomas S Hatch 2014-10-02 14:28:39 -06:00
commit 505b2e476d
4 changed files with 35 additions and 3 deletions

View File

@ -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 '

View File

@ -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
View File

@ -0,0 +1,10 @@
def arg(*args, **kwargs):
'''
Output the given args and kwargs
'''
ret = {
'args': args,
'kwargs': kwargs,
}
print ret
return ret

View File

@ -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