示例#1
0
import salt.loader

from common_util import dict_get, dict_find, dict_filter
from messaging import EventDrivenMessageProcessor, keyword_resolve

log = logging.getLogger(__name__)

# Message processor
edmp = EventDrivenMessageProcessor("reactor")

context = {
    "cache.get":
    lambda *args, **kwargs: dict_get(context.get("cache", None), *args, **
                                     kwargs),
    "cache.find":
    lambda *args, **kwargs: dict_find(
        context.get("cache", {}).values(), *args, **kwargs)
}


@edmp.register_hook()
def module_handler(name, *args, **kwargs):
    """
    Calls a Salt execution module from within minion process.
    """

    return __salt__["minionutil.run_job"](name, *args, **kwargs)


@edmp.register_hook()
def module_direct_handler(name, *args, **kwargs):
    """
示例#2
0
import copy
import logging
import salt.loader

from common_util import dict_find, dict_filter
from messaging import EventDrivenMessageProcessor, keyword_resolve

log = logging.getLogger(__name__)

# Message processor
edmp = EventDrivenMessageProcessor("reactor")

context = {
    "cache.get":
    lambda *args, **kwargs: dict_find(context, "cache", *args, **kwargs),
}


@edmp.register_hook()
def module_handler(name, *args, **kwargs):
    """
    Calls a Salt execution module from within minion process.
    """

    return __salt__["minionutil.run_job"](name, *args, **kwargs)


@edmp.register_hook()
def module_direct_handler(name, *args, **kwargs):
    """
    Calls a Salt execution module directy from this engine process.