Merge pull request #16759 from thatch45/fix_salt_val

Fix #16504
This commit is contained in:
Thomas S Hatch 2014-10-20 14:41:59 -06:00
commit 45b88acd2d
5 changed files with 24 additions and 10 deletions

View File

@ -670,11 +670,13 @@ class Single(object):
pre_wrapper = salt.client.ssh.wrapper.FunctionWrapper(
self.opts,
self.id,
fsclient=self.fsclient,
**self.target)
opts_pkg = pre_wrapper['test.opts_pkg']()
opts_pkg['file_roots'] = self.opts['file_roots']
opts_pkg['pillar_roots'] = self.opts['pillar_roots']
opts_pkg['ext_pillar'] = self.opts['ext_pillar']
opts_pkg['_ssh_version'] = self.opts['_ssh_version']
if '_caller_cachedir' in self.opts:
opts_pkg['_caller_cachedir'] = self.opts['_caller_cachedir']
else:
@ -723,6 +725,7 @@ class Single(object):
wrapper = salt.client.ssh.wrapper.FunctionWrapper(
opts,
self.id,
fsclient=self.fsclient,
**self.target)
self.wfuncs = salt.loader.ssh_wrapper(opts, wrapper, self.context)
wrapper.wfuncs = self.wfuncs

View File

@ -14,7 +14,7 @@ import salt.utils
import salt.client.ssh
class FunctionWrapper(dict):
class FunctionWrapper(object):
'''
Create an object that acts like the salt function dict and makes function
calls remotely via the SSH shell system
@ -26,6 +26,7 @@ class FunctionWrapper(dict):
host,
wfuncs=None,
mods=None,
fsclient=None,
**kwargs):
super(FunctionWrapper, self).__init__()
self.wfuncs = wfuncs if isinstance(wfuncs, dict) else {}
@ -33,6 +34,7 @@ class FunctionWrapper(dict):
self.mods = mods if isinstance(mods, dict) else {}
self.kwargs = {'id_': id_,
'host': host}
self.fsclient = fsclient
self.kwargs.update(kwargs)
def __getitem__(self, cmd):
@ -54,6 +56,7 @@ class FunctionWrapper(dict):
argv,
mods=self.mods,
wipe=True,
fsclient=self.fsclient,
**self.kwargs
)
stdout, stderr, _ = single.cmd_block()

View File

@ -42,6 +42,7 @@ def sls(mods, saltenv='base', test=None, exclude=None, env=None, **kwargs):
'''
Create the seed file for a state.sls run
'''
st_kwargs = __salt__.kwargs
__opts__['grains'] = __grains__
if env is not None:
salt.utils.warn_until(
@ -102,7 +103,8 @@ def sls(mods, saltenv='base', test=None, exclude=None, env=None, **kwargs):
single = salt.client.ssh.Single(
__opts__,
cmd,
**__salt__.kwargs)
fsclient=__context__['fileclient'],
**st_kwargs)
single.shell.send(
trans_tar,
'{0}/salt_state.tgz'.format(__opts__['thin_dir']))
@ -130,6 +132,7 @@ def low(data, **kwargs):
salt '*' state.low '{"state": "pkg", "fun": "installed", "name": "vi"}'
'''
st_kwargs = __salt__.kwargs
__opts__['grains'] = __grains__
chunks = [data]
st_ = salt.client.ssh.state.SSHHighState(
@ -160,7 +163,8 @@ def low(data, **kwargs):
single = salt.client.ssh.Single(
__opts__,
cmd,
**__salt__.kwargs)
fsclient=__context__['fileclient'],
**st_kwargs)
single.shell.send(
trans_tar,
'{0}/salt_state.tgz'.format(__opts__['thin_dir']))
@ -183,6 +187,7 @@ def high(data, **kwargs):
salt '*' state.high '{"vim": {"pkg": ["installed"]}}'
'''
st_kwargs = __salt__.kwargs
__opts__['grains'] = __grains__
st_ = salt.client.ssh.state.SSHHighState(
__opts__,
@ -210,7 +215,8 @@ def high(data, **kwargs):
single = salt.client.ssh.Single(
__opts__,
cmd,
**__salt__.kwargs)
fsclient=__context__['fileclient'],
**st_kwargs)
single.shell.send(
trans_tar,
'{0}/salt_state.tgz'.format(__opts__['thin_dir']))
@ -235,6 +241,7 @@ def highstate(test=None, **kwargs):
salt '*' state.highstate exclude=sls_to_exclude
salt '*' state.highstate exclude="[{'id': 'id_to_exclude'}, {'sls': 'sls_to_exclude'}]"
'''
st_kwargs = __salt__.kwargs
__opts__['grains'] = __grains__
st_ = salt.client.ssh.state.SSHHighState(
__opts__,
@ -267,7 +274,8 @@ def highstate(test=None, **kwargs):
single = salt.client.ssh.Single(
__opts__,
cmd,
**__salt__.kwargs)
fsclient=__context__['fileclient'],
**st_kwargs)
single.shell.send(
trans_tar,
'{0}/salt_state.tgz'.format(__opts__['thin_dir']))
@ -296,6 +304,7 @@ def top(topfn, test=None, **kwargs):
salt '*' state.top reverse_top.sls exclude=sls_to_exclude
salt '*' state.top reverse_top.sls exclude="[{'id': 'id_to_exclude'}, {'sls': 'sls_to_exclude'}]"
'''
st_kwargs = __salt__.kwargs
__opts__['grains'] = __grains__
if salt.utils.test_mode(test=test, **kwargs):
__opts__['test'] = True
@ -329,7 +338,8 @@ def top(topfn, test=None, **kwargs):
single = salt.client.ssh.Single(
__opts__,
cmd,
**__salt__.kwargs)
fsclient=__context__['fileclient'],
**st_kwargs)
single.shell.send(
trans_tar,
'{0}/salt_state.tgz'.format(__opts__['thin_dir']))

View File

@ -812,9 +812,6 @@ class Loader(object):
(str(mod.__name__).startswith('salt.loaded.int.grain') or
str(mod.__name__).startswith('salt.loaded.ext.grain')):
mod.__salt__.update(funcs)
# TODO: Refactor this to be smarter and cleaner
elif str(mod.__name__).startswith('salt.loaded.int.wrapper'):
mod.__salt__.update(funcs)
return funcs
def load_modules(self):

View File

@ -231,7 +231,8 @@ def _split_module_dicts():
{{ salt.cmd.run('uptime') }}
'''
if not isinstance(__salt__, dict):
return __salt__
mod_dict = dict(__salt__)
for module_func_name, mod_fun in mod_dict.items():
mod, fun = module_func_name.split('.', 1)