def start_engines(opts, proc_mgr, proxy=None):
    '''
    Fire up the configured engines!
    '''
    utils = salt.loader.utils(opts, proxy=proxy)
    if opts['__role'] == 'master':
        runners = salt.loader.runner(opts, utils=utils)
    else:
        runners = []
    funcs = salt.loader.minion_mods(opts, utils=utils, proxy=proxy)
    engines = salt.loader.engines(opts, funcs, runners, utils, proxy=proxy)

    engines_opt = opts.get('engines', [])
    if isinstance(engines_opt, dict):
        engines_opt = [{k: v} for k, v in engines_opt.items()]

    # Function references are not picklable. Windows needs to pickle when
    # spawning processes. On Windows, these will need to be recalculated
    # in the spawned child process.
    if salt.utils.platform.is_windows():
        runners = None
        utils = None
        funcs = None

    for engine in engines_opt:
        if isinstance(engine, dict):
            engine, engine_opts = next(iter(engine.items()))
        else:
            engine_opts = None
        engine_name = None
        if engine_opts is not None and 'engine_module' in engine_opts:
            fun = '{0}.start'.format(engine_opts['engine_module'])
            engine_name = engine
            del engine_opts['engine_module']
        else:
            fun = '{0}.start'.format(engine)
        if fun in engines:
            start_func = engines[fun]
            if engine_name:
                name = '{0}.Engine({1}-{2})'.format(__name__,
                                                    start_func.__module__,
                                                    engine_name)
            else:
                name = '{0}.Engine({1})'.format(__name__,
                                                start_func.__module__)
            log.info('Starting Engine %s', name)
            proc_mgr.add_process(
                    Engine,
                    args=(
                        opts,
                        fun,
                        engine_opts,
                        funcs,
                        runners,
                        proxy
                        ),
                    name=name
                    )
def start_engines ( opts , proc_mgr , proxy = None ) : utils = salt . loader . utils ( opts , proxy = proxy ) if opts [ '__role' ] == 'master' : runners = salt . loader . runner ( opts , utils = utils ) else : runners = [ ] funcs = salt . loader . minion_mods ( opts , utils = utils , proxy = proxy ) engines = salt . loader . engines ( opts , funcs , runners , utils , proxy = proxy ) engines_opt = opts . get ( 'engines' , [ ] ) if isinstance ( engines_opt , dict ) : engines_opt = [ { k : v } for k , v in engines_opt . items ( ) ] if salt . utils . platform . is_windows ( ) : runners = None utils = None funcs = None for engine in engines_opt : if isinstance ( engine , dict ) : engine , engine_opts = next ( iter ( engine . items ( ) ) ) else : engine_opts = None engine_name = None if engine_opts is not None and 'engine_module' in engine_opts : fun = '{0}.start' . format ( engine_opts [ 'engine_module' ] ) engine_name = engine del engine_opts [ 'engine_module' ] else : fun = '{0}.start' . format ( engine ) if fun in engines : start_func = engines [ fun ] if engine_name : name = '{0}.Engine({1}-{2})' . format ( __name__ , start_func . __module__ , engine_name ) else : name = '{0}.Engine({1})' . format ( __name__ , start_func . __module__ ) log . info ( 'Starting Engine %s' , name ) proc_mgr . add_process ( Engine , args = ( opts , fun , engine_opts , funcs , runners , proxy ) , name = name )
Fire up the configured engines!