mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge branch '2015.8' into '2016.3'
Conflicts: - salt/modules/saltutil.py - salt/returners/postgres_local_cache.py
This commit is contained in:
commit
dda2c32325
@ -945,8 +945,14 @@ class AESFuncs(object):
|
||||
if not salt.utils.verify.valid_id(self.opts, id_):
|
||||
return False
|
||||
pub_path = os.path.join(self.opts['pki_dir'], 'minions', id_)
|
||||
with salt.utils.fopen(pub_path, 'r') as fp_:
|
||||
minion_pub = fp_.read()
|
||||
try:
|
||||
with salt.utils.fopen(pub_path, 'r') as fp_:
|
||||
minion_pub = fp_.read()
|
||||
except (IOError, OSError):
|
||||
log.warning('Salt minion claiming to be {0} attempted to communicate '
|
||||
'with master but key could not be read and verification was '
|
||||
'denied.'.format(id_))
|
||||
return False
|
||||
tmp_pub = salt.utils.mkstemp()
|
||||
with salt.utils.fopen(tmp_pub, 'w+') as fp_:
|
||||
fp_.write(minion_pub)
|
||||
|
@ -45,6 +45,7 @@ import salt.runner
|
||||
import salt.state
|
||||
import salt.transport
|
||||
import salt.utils
|
||||
import salt.utils.args
|
||||
import salt.utils.event
|
||||
import salt.utils.extmods
|
||||
import salt.utils.minion
|
||||
@ -1087,13 +1088,13 @@ def cmd_iter(tgt,
|
||||
yield ret
|
||||
|
||||
|
||||
def runner(_fun, **kwargs):
|
||||
def runner(name, **kwargs):
|
||||
'''
|
||||
Execute a runner module (this function must be run on the master)
|
||||
|
||||
.. versionadded:: 2014.7.0
|
||||
|
||||
_fun
|
||||
name
|
||||
The name of the function to run
|
||||
|
||||
kwargs
|
||||
@ -1105,6 +1106,7 @@ def runner(_fun, **kwargs):
|
||||
|
||||
salt '*' saltutil.runner jobs.list_jobs
|
||||
'''
|
||||
saltenv = kwargs.pop('__env__', 'base')
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
|
||||
if 'master_job_cache' not in __opts__:
|
||||
@ -1115,10 +1117,15 @@ def runner(_fun, **kwargs):
|
||||
else:
|
||||
rclient = salt.runner.RunnerClient(__opts__)
|
||||
|
||||
return rclient.cmd(_fun, kwarg=kwargs)
|
||||
if name in rclient.functions:
|
||||
aspec = salt.utils.args.get_function_argspec(rclient.functions[name])
|
||||
if 'saltenv' in aspec.args:
|
||||
kwargs['saltenv'] = saltenv
|
||||
|
||||
return rclient.cmd(name, kwarg=kwargs)
|
||||
|
||||
|
||||
def wheel(_fun, *args, **kwargs):
|
||||
def wheel(name, *args, **kwargs):
|
||||
'''
|
||||
Execute a wheel module and function. This function must be run against a
|
||||
minion that is local to the master.
|
||||
@ -1153,6 +1160,8 @@ def wheel(_fun, *args, **kwargs):
|
||||
their return data.
|
||||
|
||||
'''
|
||||
saltenv = kwargs.pop('__env__', 'base')
|
||||
|
||||
if __opts__['__role'] == 'minion':
|
||||
master_config = os.path.join(os.path.dirname(__opts__['conf_file']),
|
||||
'master')
|
||||
@ -1172,10 +1181,22 @@ def wheel(_fun, *args, **kwargs):
|
||||
valid_kwargs[key] = val
|
||||
|
||||
try:
|
||||
ret = wheel_client.cmd(_fun, arg=args, pub_data=pub_data, kwarg=valid_kwargs)
|
||||
if name in wheel_client.functions:
|
||||
aspec = salt.utils.args.get_function_argspec(
|
||||
wheel_client.functions[name]
|
||||
)
|
||||
if 'saltenv' in aspec.args:
|
||||
valid_kwargs['saltenv'] = saltenv
|
||||
|
||||
ret = wheel_client.cmd(name,
|
||||
arg=args,
|
||||
pub_data=pub_data,
|
||||
kwarg=valid_kwargs)
|
||||
except SaltInvocationError:
|
||||
raise CommandExecutionError('This command can only be executed on a minion '
|
||||
'that is located on the master.')
|
||||
raise CommandExecutionError(
|
||||
'This command can only be executed on a minion that is located on '
|
||||
'the master.'
|
||||
)
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -76,7 +76,7 @@ def _check_for_unit_changes(name):
|
||||
Check for modified/updated unit files, and run a daemon-reload if any are
|
||||
found.
|
||||
'''
|
||||
contextkey = 'systemd._check_for_unit_changes'
|
||||
contextkey = 'systemd._check_for_unit_changes.{0}'.format(name)
|
||||
if contextkey not in __context__:
|
||||
if _untracked_custom_unit_found(name) or _unit_file_changed(name):
|
||||
systemctl_reload()
|
||||
|
@ -127,12 +127,13 @@ RETURN_P = 'return.p'
|
||||
# out is the "out" from the minion data
|
||||
OUT_P = 'out.p'
|
||||
|
||||
__virtualname__ = 'postgres_local_cache'
|
||||
|
||||
|
||||
def __virtual__():
|
||||
if not HAS_POSTGRES:
|
||||
log.info("Could not import psycopg2, postgres_local_cache disabled.")
|
||||
return False
|
||||
return 'postgres_local_cache'
|
||||
return (False, 'Could not import psycopg2; postges_local_cache disabled')
|
||||
return __virtualname__
|
||||
|
||||
|
||||
def _get_conn():
|
||||
|
@ -591,7 +591,9 @@ def runner(name, **kwargs):
|
||||
- name: manage.up
|
||||
'''
|
||||
ret = {'name': name, 'result': False, 'changes': {}, 'comment': ''}
|
||||
out = __salt__['saltutil.runner'](name, **kwargs)
|
||||
out = __salt__['saltutil.runner'](name,
|
||||
__env__=__env__,
|
||||
**kwargs)
|
||||
|
||||
ret['result'] = True
|
||||
ret['comment'] = "Runner function '{0}' executed.".format(name)
|
||||
@ -621,7 +623,9 @@ def wheel(name, **kwargs):
|
||||
- match: frank
|
||||
'''
|
||||
ret = {'name': name, 'result': False, 'changes': {}, 'comment': ''}
|
||||
out = __salt__['saltutil.wheel'](name, **kwargs)
|
||||
out = __salt__['saltutil.wheel'](name,
|
||||
__env__=__env__,
|
||||
**kwargs)
|
||||
|
||||
ret['result'] = True
|
||||
ret['comment'] = "Wheel function '{0}' executed.".format(name)
|
||||
|
@ -966,7 +966,7 @@ def format_call(fun,
|
||||
|
||||
aspec = salt.utils.args.get_function_argspec(fun)
|
||||
|
||||
arg_data = arg_lookup(fun)
|
||||
arg_data = arg_lookup(fun, aspec)
|
||||
args = arg_data['args']
|
||||
kwargs = arg_data['kwargs']
|
||||
|
||||
@ -1074,13 +1074,14 @@ def format_call(fun,
|
||||
return ret
|
||||
|
||||
|
||||
def arg_lookup(fun):
|
||||
def arg_lookup(fun, aspec=None):
|
||||
'''
|
||||
Return a dict containing the arguments and default arguments to the
|
||||
function.
|
||||
'''
|
||||
ret = {'kwargs': {}}
|
||||
aspec = salt.utils.args.get_function_argspec(fun)
|
||||
if aspec is None:
|
||||
aspec = salt.utils.args.get_function_argspec(fun)
|
||||
if aspec.defaults:
|
||||
ret['kwargs'] = dict(zip(aspec.args[::-1], aspec.defaults[::-1]))
|
||||
ret['args'] = [arg for arg in aspec.args if arg not in ret['kwargs']]
|
||||
|
Loading…
Reference in New Issue
Block a user