def get_runner_module(name): """ Load runner driver and return reference to the runner driver module. """ # NOTE: For backward compatibility we also support "_" in place of "-" from stevedore.exception import NoMatches try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except NoMatches: name = name.replace('_', '-') try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except Exception as e: available_runners = get_available_plugins( namespace=RUNNERS_NAMESPACE) available_runners = ', '.join(available_runners) msg = ( 'Failed to find runner %s. Make sure that the runner is available and installed ' 'in StackStorm virtual environment. Available runners are: %s' % (name, available_runners)) LOG.exception(msg) raise exc.ActionRunnerCreateError('%s\n\n%s' % (msg, six.text_type(e))) return module
def get_callback_module(name): """ Retrieve runner callback module for the provided runner. """ # NOTE: For backward compatibility we also support "_" in place of "-" from stevedore.exception import NoMatches try: module = get_plugin_instance(RUNNERS_CALLBACK_MODULES_NAMESPACE, name, invoke_on_load=False) except NoMatches: name = name.replace('_', '-') module = get_plugin_instance(RUNNERS_CALLBACK_MODULES_NAMESPACE, name, invoke_on_load=False) return module
def get_runner(name, config=None): """ Load the module and return an instance of the runner. """ LOG.debug('Runner loading Python module: %s', name) # NOTE: For backward compatibility we also support "_" in place of "-" from stevedore.exception import NoMatches try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except NoMatches: name = name.replace('_', '-') try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except Exception as e: available_runners = get_available_plugins( namespace=RUNNERS_NAMESPACE) available_runners = ', '.join(available_runners) msg = ( 'Failed to find runner %s. Make sure that the runner is available and installed ' 'in StackStorm virtual environment. Available runners are: %s' % (name, available_runners)) LOG.exception(msg) raise exc.ActionRunnerCreateError('%s\n\n%s' % (msg, six.text_type(e))) LOG.debug('Instance of runner module: %s', module) if config: runner_kwargs = {'config': config} else: runner_kwargs = {} runner = module.get_runner(**runner_kwargs) LOG.debug('Instance of runner: %s', runner) return runner
def metrics_initialize(): """Initialize metrics constant """ global METRICS try: METRICS = get_plugin_instance(PLUGIN_NAMESPACE, cfg.CONF.metrics.driver) except (NoMatches, MultipleMatches, NoSuchOptError) as error: raise PluginLoadError('Error loading metrics driver. Check configuration: %s', error) return METRICS
def get_runner(name, config=None): """ Load the module and return an instance of the runner. """ LOG.debug('Runner loading Python module: %s', name) # NOTE: For backward compatibility we also support "_" in place of "-" from stevedore.exception import NoMatches try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except NoMatches: name = name.replace('_', '-') try: module = get_plugin_instance(RUNNERS_NAMESPACE, name, invoke_on_load=False) except Exception as e: available_runners = get_available_plugins(namespace=RUNNERS_NAMESPACE) available_runners = ', '.join(available_runners) msg = ('Failed to find runner %s. Make sure that the runner is available and installed ' 'in StackStorm virtual environment. Available runners are: %s' % (name, available_runners)) LOG.exception(msg) raise exc.ActionRunnerCreateError('%s\n\n%s' % (msg, six.text_type(e))) LOG.debug('Instance of runner module: %s', module) if config: runner_kwargs = {'config': config} else: runner_kwargs = {} runner = module.get_runner(**runner_kwargs) LOG.debug('Instance of runner: %s', runner) return runner