Merge remote-tracking branch 'upstream/2014.7' into develop

This commit is contained in:
Seth House 2014-10-08 14:40:32 -06:00
commit b0615f9bbf
10 changed files with 91 additions and 54 deletions

View File

@ -359,7 +359,7 @@ components.
# standard declaration
<ID Declaration>:
<State Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Function Arg>
@ -373,7 +373,7 @@ components.
# inline function and names
<ID Declaration>:
<State Declaration>.<Function>:
<State Module>.<Function>:
- <Function Arg>
- <Function Arg>
- <Function Arg>
@ -385,17 +385,17 @@ components.
- <Requisite Reference>
- <Requisite Reference>
# multiple states for single id
<ID Declaration>:
<State Declaration>:
- <Function>
<State Module>:
- <Function>
- <Function Arg>
- <Name>: <name>
- <Requisite Declaration>:
- <Requisite Reference>
<State Declaration>:
<State Module>:
- <Function>
- <Function Arg>
- <Names>:

View File

@ -1924,7 +1924,7 @@ class ClearFuncs(object):
good = self.ckminions.wheel_check(
self.opts['external_auth'][clear_load['eauth']][name]
if name in self.opts['external_auth'][clear_load['eauth']]
else self.opts['external_auth'][token['eauth']]['*'],
else self.opts['external_auth'][clear_load['eauth']]['*'],
clear_load['fun'])
if not good:
msg = ('Authentication failure of type "eauth" occurred for '

View File

@ -1858,7 +1858,7 @@ def seek_read(path, size, offset):
'''
.. versionadded:: 2014.1.0
Seek to a position on a file and write to it
Seek to a position on a file and read it
path
path to file

View File

@ -91,7 +91,7 @@ def _get_proc_pid(proc):
It's backward compatible with < 2.0 versions of psutil.
'''
return proc.pid() if PSUTIL2 else proc.pid
return proc.pid
def top(num_processes=5, interval=3):

View File

@ -117,7 +117,7 @@ class NetapiClient(object):
'''
kwargs['fun'] = fun
wheel = salt.wheel.WheelClient(self.opts)
return wheel.master_call(**kwargs)
return wheel.cmd_sync(kwargs)
def wheel_async(self, fun, **kwargs):
'''

View File

@ -136,6 +136,23 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
raise_error(**ret['error'])
return ret
def _reformat_low(self, low):
'''
Format the low data for RunnerClient()'s master_call() function
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', 'client',
] if i in low])
reformatted_low = {'fun': low.pop('fun')}
reformatted_low.update(auth_creds)
reformatted_low['kwarg'] = low
return reformatted_low
def cmd_async(self, low):
'''
Execute a runner function asynchronously; eauth is respected
@ -152,7 +169,8 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
'eauth': 'pam',
})
'''
return self.master_call(**low)
reformatted_low = self._reformat_low(low)
return self.master_call(**reformatted_low)
def cmd_sync(self, low, timeout=None):
'''
@ -175,16 +193,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
self.opts['transport'],
opts=self.opts)
# 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
reformatted_low = self._reformat_low(low)
job = self.master_call(**reformatted_low)
ret_tag = tagify('ret', base=job['tag'])

View File

@ -3,16 +3,33 @@
This runner is used only for test purposes and servers no production purpose
'''
# Import python libs
from __future__ import print_function
import pprint
def arg(*args, **kwargs):
'''
Output the given args and kwargs
Kwargs will be filtered for 'private' keynames.
'''
kwargs = dict((k, v) for k, v in kwargs.iteritems()
if not k.startswith('__'))
ret = {
'args': args,
'kwargs': kwargs,
}
pprint.pprint(ret)
return ret
def raw_arg(*args, **kwargs):
'''
Output the given args and kwargs
'''
ret = {
'args': args,
'kwargs': kwargs,
}
print(ret)
pprint.pprint(ret)
return ret

View File

@ -97,26 +97,7 @@ class WheelClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
})
{'minions': {'jerry': '5d:f6:79:43:5e:d4:42:3f:57:b8:45:a8:7e:a4:6e:ca'}}
'''
sevent = salt.utils.event.get_event('master',
self.opts['sock_dir'],
self.opts['transport'],
opts=self.opts)
job = self.master_call(**low)
ret_tag = tagify('ret', base=job['tag'])
timelimit = time.time() + (timeout or 300)
while True:
ret = sevent.get_event(full=True)
if ret is None:
continue
if ret['tag'] == ret_tag:
return ret['data']['return']
if time.time() > timelimit:
raise salt.exceptions.SaltClientTimeout(
"WheelClient job '%s' timed out", job['jid'],
jid=job['jid'])
return self.master_call(**low)
def cmd_async(self, low):
'''

View File

@ -11,6 +11,12 @@ import salt.wheel
class WheelModuleTest(integration.ClientCase):
eauth_creds = {
'username': 'saltdev_auto',
'password': 'saltdev',
'eauth': 'auto',
}
def setUp(self):
'''
Configure an eauth user to test with
@ -24,13 +30,13 @@ class WheelModuleTest(integration.ClientCase):
The choice of using key.list_all for this is arbitrary and should be
changed to some mocked function that is more testing friendly.
'''
self.wheel.master_call(**{
low = {
'client': 'wheel',
'fun': 'key.list_all',
'eauth': 'auto',
'username': 'saltdev_auto',
'password': 'saltdev',
})
}
low.update(self.eauth_creds)
self.wheel.master_call(**low)
def test_token(self):
'''
@ -45,11 +51,7 @@ class WheelModuleTest(integration.ClientCase):
self.mkdir_p(os.path.join(opts['root_dir'], 'cache', 'tokens'))
auth = salt.auth.LoadAuth(opts)
token = auth.mk_token({
'username': 'saltdev_auto',
'password': 'saltdev',
'eauth': 'auto',
})
token = auth.mk_token(self.eauth_creds)
self.wheel.master_call(**{
'client': 'wheel',
@ -57,6 +59,34 @@ class WheelModuleTest(integration.ClientCase):
'token': token['token'],
})
def test_cmd_sync(self):
low = {
'client': 'wheel',
'fun': 'key.list_keys',
}
low.update(self.eauth_creds)
self.wheel.cmd_sync(low)
def test_cmd_async(self):
low = {
'client': 'wheel_async',
'fun': 'key.list_keys',
}
low.update(self.eauth_creds)
self.wheel.cmd_async(low)
def test_cmd_sync_w_arg(self):
low = {
'fun': 'key.finger',
'match': '*',
}
low.update(self.eauth_creds)
ret = self.wheel.cmd_sync(low)
self.assertIn('return', ret.get('data', {}))
def test_wildcard_auth(self):
low = {
'username': 'the_s0und_of_t3ch',

View File

@ -66,7 +66,7 @@ def _get_proc_name(proc):
def _get_proc_pid(proc):
return proc.pid() if PSUTIL2 else proc.pid
return proc.pid
@skipIf(not HAS_PSUTIL, "psutils are required for this test case")