mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #52773 from bloomberg/exec_2019
2019.2: bug: executors lazyloader is missing functions and proxy args
This commit is contained in:
parent
2ed3a1b8ff
commit
321710e7c8
9 changed files with 111 additions and 4 deletions
|
@ -83,7 +83,7 @@ Sync Via the saltutil Module
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The saltutil module has a number of functions that can be used to sync all
|
||||
or specific dynamic modules. The ``saltutil.sync_*``
|
||||
or specific dynamic modules. The ``saltutil.sync_*``
|
||||
:py:mod:`execution functions <salt.modules.saltutil>` and
|
||||
:py:mod:`runner functions <salt.runners.saltutil>` can be used to sync modules
|
||||
to minions and the master, respectively.
|
||||
|
@ -120,7 +120,7 @@ This is done via setuptools entry points:
|
|||
)
|
||||
|
||||
Note that these are not synced from the Salt Master to the Minions. They must be
|
||||
installed indepdendently on each Minion.
|
||||
installed independently on each Minion.
|
||||
|
||||
Module Types
|
||||
============
|
||||
|
@ -139,7 +139,7 @@ Cache ``salt.cache`` (:ref:`index <all-salt.cache>`) ``
|
|||
Cloud ``salt.cloud.clouds`` (:ref:`index <all-salt.clouds>`) ``clouds`` ``cloud_dirs``
|
||||
Engine ``salt.engines`` (:ref:`index <engines>`) ``engines`` ``engines_dirs``
|
||||
Execution ``salt.modules`` (:ref:`index <all-salt.modules>`) ``modules`` ``module_dirs``
|
||||
Executor ``salt.executors`` (:ref:`index <all-salt.executors>`) ``executors`` [#no-fs]_ ``executor_dirs``
|
||||
Executor ``salt.executors`` (:ref:`index <all-salt.executors>`) ``executors`` ``executor_dirs``
|
||||
File Server ``salt.fileserver`` (:ref:`index <file-server>`) ``fileserver`` ``fileserver_dirs``
|
||||
Grain ``salt.grains`` (:ref:`index <all-salt.grains>`) ``grains`` ``grains_dirs``
|
||||
Log Handler ``salt.log.handlers`` (:ref:`index <external-logging-handlers>`) ``log_handlers`` ``log_handlers_dirs``
|
||||
|
|
|
@ -457,7 +457,7 @@ class MinionBase(object):
|
|||
# self.matcher = Matcher(self.opts, self.functions)
|
||||
self.matchers = salt.loader.matchers(self.opts)
|
||||
self.functions['sys.reload_modules'] = self.gen_modules
|
||||
self.executors = salt.loader.executors(self.opts, self.functions)
|
||||
self.executors = salt.loader.executors(self.opts, self.functions, proxy=self.proxy)
|
||||
|
||||
@staticmethod
|
||||
def process_schedule(minion, loop_interval):
|
||||
|
|
|
@ -918,6 +918,45 @@ def sync_pillar(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl
|
|||
return ret
|
||||
|
||||
|
||||
def sync_executors(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None):
|
||||
'''
|
||||
.. versionadded:: Neon
|
||||
|
||||
Sync executors from ``salt://_executors`` to the minion
|
||||
|
||||
saltenv
|
||||
The fileserver environment from which to sync. To sync from more than
|
||||
one environment, pass a comma-separated list.
|
||||
|
||||
If not passed, then all environments configured in the :ref:`top files
|
||||
<states-top>` will be checked for log handlers to sync. If no top files
|
||||
are found, then the ``base`` environment will be synced.
|
||||
|
||||
refresh : True
|
||||
If ``True``, refresh the available execution modules on the minion.
|
||||
This refresh will be performed even if no new log handlers are synced.
|
||||
Set to ``False`` to prevent this refresh.
|
||||
|
||||
extmod_whitelist : None
|
||||
comma-seperated list of modules to sync
|
||||
|
||||
extmod_blacklist : None
|
||||
comma-seperated list of modules to blacklist based on type
|
||||
|
||||
CLI Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' saltutil.sync_executors
|
||||
salt '*' saltutil.sync_executors saltenv=dev
|
||||
salt '*' saltutil.sync_executors saltenv=base,dev
|
||||
'''
|
||||
ret = _sync('executors', saltenv, extmod_whitelist, extmod_blacklist)
|
||||
if refresh:
|
||||
refresh_modules()
|
||||
return ret
|
||||
|
||||
|
||||
def sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None):
|
||||
'''
|
||||
.. versionchanged:: 2015.8.11,2016.3.2
|
||||
|
@ -978,6 +1017,7 @@ def sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist
|
|||
ret['output'] = sync_output(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['utils'] = sync_utils(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['log_handlers'] = sync_log_handlers(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['executors'] = sync_executors(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['proxymodules'] = sync_proxymodules(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['engines'] = sync_engines(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
ret['thorium'] = sync_thorium(saltenv, False, extmod_whitelist, extmod_blacklist)
|
||||
|
|
|
@ -64,6 +64,7 @@ def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None):
|
|||
ret['tops'] = sync_tops(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)
|
||||
ret['tokens'] = sync_eauth_tokens(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)
|
||||
ret['serializers'] = sync_serializers(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)
|
||||
ret['executors'] = sync_executors(saltenv=saltenv, extmod_whitelist=extmod_whitelist, extmod_blacklist=extmod_blacklist)
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -607,3 +608,29 @@ def sync_serializers(saltenv='base', extmod_whitelist=None, extmod_blacklist=Non
|
|||
'''
|
||||
return salt.utils.extmods.sync(__opts__, 'serializers', saltenv=saltenv, extmod_whitelist=extmod_whitelist,
|
||||
extmod_blacklist=extmod_blacklist)[0]
|
||||
|
||||
|
||||
def sync_executors(saltenv='base', extmod_whitelist=None, extmod_blacklist=None):
|
||||
'''
|
||||
.. versionadded:: Neon
|
||||
|
||||
Sync executor modules from ``salt://_executors`` to the master
|
||||
|
||||
saltenv : base
|
||||
The fileserver environment from which to sync. To sync from more than
|
||||
one environment, pass a comma-separated list.
|
||||
|
||||
extmod_whitelist : None
|
||||
comma-seperated list of modules to sync
|
||||
|
||||
extmod_blacklist : None
|
||||
comma-seperated list of modules to blacklist based on type
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-run saltutil.sync_executors
|
||||
'''
|
||||
return salt.utils.extmods.sync(__opts__, 'executors', saltenv=saltenv, extmod_whitelist=extmod_whitelist,
|
||||
extmod_blacklist=extmod_blacklist)[0]
|
||||
|
|
1
tests/integration/executors/__init__.py
Normal file
1
tests/integration/executors/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
10
tests/integration/files/file/base/_executors/arg.py
Normal file
10
tests/integration/files/file/base/_executors/arg.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
def __virtual__():
|
||||
return True
|
||||
|
||||
|
||||
def execute(*args, **kwargs):
|
||||
# we use the dunder to assert the loader is provided minionmods
|
||||
return __salt__['test.arg']('test.arg fired')
|
24
tests/integration/minion/test_executor.py
Normal file
24
tests/integration/minion/test_executor.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase, ShellCase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ExecutorTest(ModuleCase, ShellCase):
|
||||
|
||||
def setup(self):
|
||||
self.run_function('saltutil.sync_all')
|
||||
|
||||
def test_executor(self):
|
||||
'''
|
||||
test that dunders are set
|
||||
'''
|
||||
data = self.run_call('test.arg --module-executors=arg')
|
||||
self.assertIn('test.arg fired', "".join(data))
|
|
@ -98,6 +98,7 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'states': [],
|
||||
'sdb': [],
|
||||
'proxymodules': [],
|
||||
'executors': [],
|
||||
'output': [],
|
||||
'thorium': [],
|
||||
'serializers': []}
|
||||
|
@ -121,6 +122,7 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'states': [],
|
||||
'sdb': [],
|
||||
'proxymodules': [],
|
||||
'executors': [],
|
||||
'output': [],
|
||||
'thorium': [],
|
||||
'serializers': []}
|
||||
|
@ -147,6 +149,7 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'states': [],
|
||||
'sdb': [],
|
||||
'proxymodules': [],
|
||||
'executors': [],
|
||||
'output': [],
|
||||
'thorium': [],
|
||||
'serializers': []}
|
||||
|
@ -163,6 +166,7 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'beacons': [],
|
||||
'utils': [],
|
||||
'returners': [],
|
||||
'executors': [],
|
||||
'modules': [],
|
||||
'renderers': [],
|
||||
'log_handlers': [],
|
||||
|
|
|
@ -135,6 +135,7 @@ class BadTestModuleNamesTestCase(TestCase):
|
|||
'integration.master.test_event_return',
|
||||
'integration.minion.test_blackout',
|
||||
'integration.minion.test_pillar',
|
||||
'integration.minion.test_executor',
|
||||
'integration.minion.test_timeout',
|
||||
'integration.modules.test_decorators',
|
||||
'integration.modules.test_pkg',
|
||||
|
|
Loading…
Add table
Reference in a new issue