mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Support executors in ioflo.
This commit is contained in:
parent
d57a3ab79e
commit
0c9877d52c
@ -626,7 +626,8 @@ class SaltLoadModules(ioflo.base.deeding.Deed):
|
||||
'modules': '.salt.loader.modules',
|
||||
'grain_time': '.salt.var.grain_time',
|
||||
'module_refresh': '.salt.var.module_refresh',
|
||||
'returners': '.salt.loader.returners'}
|
||||
'returners': '.salt.loader.returners',
|
||||
'module_executors': '.salt.loader.executors'}
|
||||
|
||||
def _prepare(self):
|
||||
self._load_modules()
|
||||
@ -668,10 +669,13 @@ class SaltLoadModules(ioflo.base.deeding.Deed):
|
||||
self.utils.value = salt.loader.utils(self.opts.value)
|
||||
self.modules.value = salt.loader.minion_mods(self.opts.value, utils=self.utils.value)
|
||||
self.returners.value = salt.loader.returners(self.opts.value, self.modules.value)
|
||||
self.module_executors = salt.loader.executors(self.opts, self.modules.value)
|
||||
|
||||
|
||||
self.utils.value.clear()
|
||||
self.modules.value.clear()
|
||||
self.returners.value.clear()
|
||||
self.module_executors.value.clear()
|
||||
|
||||
# we're done, reset the limits!
|
||||
if modules_max_memory is True:
|
||||
|
@ -16,6 +16,7 @@ import subprocess
|
||||
import json
|
||||
|
||||
# Import salt libs
|
||||
import salt.ext.six as six
|
||||
import salt.daemons.masterapi
|
||||
import salt.utils.args
|
||||
import salt.utils
|
||||
@ -24,6 +25,7 @@ from raet import raeting, nacling
|
||||
from raet.lane.stacking import LaneStack
|
||||
from raet.lane.yarding import RemoteYard
|
||||
|
||||
from salt.executors import FUNCTION_EXECUTORS
|
||||
from salt.utils import kinds, is_windows
|
||||
from salt.utils.event import tagify
|
||||
|
||||
@ -137,6 +139,7 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
||||
'grains': '.salt.grains',
|
||||
'modules': '.salt.loader.modules',
|
||||
'returners': '.salt.loader.returners',
|
||||
'module_executors': '.salt.loader.executors',
|
||||
'fun': '.salt.var.fun',
|
||||
'matcher': '.salt.matcher',
|
||||
'executors': '.salt.track.executors',
|
||||
@ -286,16 +289,33 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
||||
salt.utils.args.parse_input(data['arg']),
|
||||
data)
|
||||
sys.modules[func.__module__].__context__['retcode'] = 0
|
||||
if self.opts.get('sudo_user', ''):
|
||||
sudo_runas = self.opts.get('sudo_user')
|
||||
if 'sudo.salt_call' in self.modules.value:
|
||||
return_data = self.modules.value['sudo.salt_call'](
|
||||
sudo_runas,
|
||||
data['fun'],
|
||||
*args,
|
||||
**kwargs)
|
||||
|
||||
executors = data.get('module_executors') or self.opts.get('module_executors', ['direct_call.get'])
|
||||
if isinstance(executors, six.string_types):
|
||||
executors = [executors]
|
||||
elif not isinstance(executors, list) or not executors:
|
||||
raise SaltInvocationError("Wrong executors specification: {0}. String or non-empty list expected".
|
||||
format(executors))
|
||||
if self.opts.get('sudo_user', '') and executors[-1] != 'sudo.get':
|
||||
if executors[-1] in FUNCTION_EXECUTORS:
|
||||
executors[-1] = 'sudo.get' # replace
|
||||
else:
|
||||
return_data = func(*args, **kwargs)
|
||||
executors.append('sudo.get') # append
|
||||
log.trace("Executors list {0}".format(executors))
|
||||
|
||||
# Get executors
|
||||
def get_executor(name):
|
||||
executor_class = self.module_executors.value.get(name)
|
||||
if executor_class is None:
|
||||
raise SaltInvocationError("Executor '{0}' is not available".format(name))
|
||||
return executor_class
|
||||
# Get the last one that is function executor
|
||||
executor = get_executor(executors.pop())(self.opts, data, func, args, kwargs)
|
||||
# Instantiate others from bottom to the top
|
||||
for executor_name in reversed(executors):
|
||||
executor = get_executor(executor_name)(self.opts, data, executor)
|
||||
return_data = executor.execute()
|
||||
|
||||
if isinstance(return_data, types.GeneratorType):
|
||||
ind = 0
|
||||
iret = {}
|
||||
|
Loading…
Reference in New Issue
Block a user