當前位置: 首頁>>代碼示例>>Python>>正文


Python stevedore.ExtensionManager方法代碼示例

本文整理匯總了Python中stevedore.ExtensionManager方法的典型用法代碼示例。如果您正苦於以下問題:Python stevedore.ExtensionManager方法的具體用法?Python stevedore.ExtensionManager怎麽用?Python stevedore.ExtensionManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stevedore的用法示例。


在下文中一共展示了stevedore.ExtensionManager方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: plugins

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def plugins(ctx):
    """
    Displays available plugins and if they're enabled.
    """
    try:
        from nidaba.config import nidaba_cfg
    except IOError as e:
        if e.errno == 2:
            click.echo('plugins command only available for local installations.')
            ctx.exit()

    import stevedore

    mgr = stevedore.ExtensionManager(namespace='nidaba.plugins')
    enabled = set(nidaba_cfg['plugins_load'].keys()).intersection(set(mgr.names()))
    disabled = set(mgr.names()) - enabled
    for plugin in mgr.names():
        click.echo(plugin, nl=False)
        if plugin in disabled:
            click.secho(u' (disabled)', fg='red')
        else:
            click.secho(u' (enabled)', fg='green') 
開發者ID:OpenPhilology,項目名稱:nidaba,代碼行數:24,代碼來源:cli.py

示例2: job_runner

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def job_runner(self):
        # Lazily import this since this module will be loaded on hadoop worker nodes however stevedore will not be
        # available in that environment.
        from stevedore import ExtensionManager

        extension_manager = ExtensionManager('mapreduce.engine')
        try:
            engine_class = extension_manager[self.mapreduce_engine].plugin
        except KeyError:
            raise KeyError('A map reduce engine must be specified in order to run MapReduceJobTasks')

        if issubclass(engine_class, MapReduceJobRunner):
            engine_kwargs = self._get_engine_parameters_from_targets()
            return engine_class(**engine_kwargs)
        else:
            return engine_class() 
開發者ID:edx,項目名稱:edx-analytics-pipeline,代碼行數:18,代碼來源:mapreduce.py

示例3: test_entry_points

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def test_entry_points(self):
        factory_classes = {
            'catch_errors': 'CatchErrors',
            'correlation_id': 'CorrelationId',
            'cors': 'CORS',
            'debug': 'Debug',
            'healthcheck': 'Healthcheck',
            'http_proxy_to_wsgi': 'HTTPProxyToWSGI',
            'request_id': 'RequestId',
            'sizelimit': 'RequestBodySizeLimiter',
            'ssl': 'SSLMiddleware',
        }

        em = stevedore.ExtensionManager('paste.filter_factory')

        # Ensure all the factories are defined by their names
        factory_names = [extension.name for extension in em]
        self.assertThat(factory_names,
                        matchers.ContainsAll(factory_classes)) 
開發者ID:openstack,項目名稱:oslo.middleware,代碼行數:21,代碼來源:test_entry_points.py

示例4: _get_extension_manager_of_resource

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def _get_extension_manager_of_resource(resource_name):
    """Get the resource specific ExtensionManager instance.

    :param resource_name: The name of the resource e.g.
        'system' / 'ethernet_interface' / 'update_service'
    :returns: the ExtensionManager instance
    :raises ExtensionError: on resource OEM extension load error.
    """
    global _global_extn_mgrs_by_resource

    if resource_name not in _global_extn_mgrs_by_resource:
        resource_namespace = 'sushy.resources.' + resource_name + '.oems'
        _global_extn_mgrs_by_resource[resource_name] = (
            _create_extension_manager(resource_namespace)
        )
    return _global_extn_mgrs_by_resource[resource_name] 
開發者ID:openstack,項目名稱:sushy,代碼行數:18,代碼來源:common.py

示例5: list_opts

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def list_opts():
    """Returns a list of oslo.config options available in the library.

    The returned list includes all oslo.config options which may be registered
    at runtime by the library.

    Each element of the list is a tuple. The first element is the name of the
    group under which the list of elements in the second element will be
    registered. A group name of None corresponds to the [DEFAULT] group in
    config files.

    The purpose of this is to allow tools like the Oslo sample config file
    generator to discover the options exposed to users by this library.

    :returns: a list of (group_name, opts) tuples
    """
    key_manager_opts = []
    key_manager_opts.extend(key_manager.key_manager_opts)
    key_manager_opts.extend(utils.credential_opts)
    opts = [('key_manager', key_manager_opts)]

    ext_mgr = ExtensionManager(
        "castellan.drivers",
        invoke_on_load=True,
        invoke_args=[cfg.CONF])

    for driver in ext_mgr.names():
        opts.extend(ext_mgr[driver].obj.list_options_for_discovery())

    return opts 
開發者ID:openstack,項目名稱:castellan,代碼行數:32,代碼來源:options.py

示例6: __init__

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def __init__(self, app, app_args, cmd_name=None):
        super(CompleteCommand, self).__init__(app, app_args, cmd_name)
        self._formatters = stevedore.ExtensionManager(
            namespace='cliff.formatter.completion',
        ) 
開發者ID:openstack,項目名稱:cliff,代碼行數:7,代碼來源:complete.py

示例7: _load_formatter_plugins

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def _load_formatter_plugins(self):
        # Here so tests can override
        return stevedore.ExtensionManager(
            self.formatter_namespace,
            invoke_on_load=True,
        ) 
開發者ID:openstack,項目名稱:cliff,代碼行數:8,代碼來源:display.py

示例8: get_plugin_list

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def get_plugin_list():
    """Gather plugin list and cache it"""

    global PLUGIN_LIST

    if PLUGIN_LIST is None:
        PLUGIN_LIST = stevedore.ExtensionManager(
            base.PLUGIN_NAMESPACE,
            invoke_on_load=False,
            propagate_map_exceptions=True,
        )
    return PLUGIN_LIST 
開發者ID:nttcom,項目名稱:eclcli,代碼行數:14,代碼來源:auth.py

示例9: load_all_extensions

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def load_all_extensions():
    """Load all available modules with DF models"""
    manager = stevedore.ExtensionManager(  # noqa F841
        'dragonflow.db.models',
    )
    # NOTE(oanson) In case Stevedore changes and we need to manually load
    # the extensions:
    # modules = [extension.plugin for extension in manager] 
開發者ID:openstack,項目名稱:dragonflow,代碼行數:10,代碼來源:all.py

示例10: get_extensions

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def get_extensions():
    global extension_checks
    if extension_checks is None:
        em = stevedore.ExtensionManager('oslo.policy.rule_checks',
                                        invoke_on_load=False)
        extension_checks = {
            extension.name: extension.plugin
            for extension in em
        }
    return extension_checks 
開發者ID:openstack,項目名稱:oslo.policy,代碼行數:12,代碼來源:_checks.py

示例11: rule_conditions_manager

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def rule_conditions_manager():
    """Create a Stevedore extension manager for conditions in rules."""
    global _CONDITIONS_MGR
    if _CONDITIONS_MGR is None:
        _CONDITIONS_MGR = stevedore.ExtensionManager(
            'ironic_inspector.rules.conditions',
            invoke_on_load=True)
    return _CONDITIONS_MGR 
開發者ID:openstack,項目名稱:ironic-inspector,代碼行數:10,代碼來源:base.py

示例12: rule_actions_manager

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def rule_actions_manager():
    """Create a Stevedore extension manager for actions in rules."""
    global _ACTIONS_MGR
    if _ACTIONS_MGR is None:
        _ACTIONS_MGR = stevedore.ExtensionManager(
            'ironic_inspector.rules.actions',
            invoke_on_load=True)
    return _ACTIONS_MGR 
開發者ID:openstack,項目名稱:ironic-inspector,代碼行數:10,代碼來源:base.py

示例13: introspection_data_manager

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def introspection_data_manager():
    global _INTROSPECTION_DATA_MGR
    if _INTROSPECTION_DATA_MGR is None:
        _INTROSPECTION_DATA_MGR = stevedore.ExtensionManager(
            'ironic_inspector.introspection_data.store',
            invoke_on_load=True)
    return _INTROSPECTION_DATA_MGR 
開發者ID:openstack,項目名稱:ironic-inspector,代碼行數:9,代碼來源:base.py

示例14: _create_extension_manager

# 需要導入模塊: import stevedore [as 別名]
# 或者: from stevedore import ExtensionManager [as 別名]
def _create_extension_manager(namespace):
    """Create the resource specific ExtensionManager instance.

    Use stevedore to find all vendor extensions of resource from their
    namespace and return the ExtensionManager instance.
    :param namespace: The namespace for the entry points. It maps to a
        specific Sushy resource type.
    :returns: the ExtensionManager instance
    :raises ExtensionError: on resource OEM extension load error.
    """
    # namespace format is:
    # ``sushy.resources.<underscore_joined_resource_name>.oems``
    resource_name = namespace.split('.')[-2]

    extension_manager = (
        stevedore.ExtensionManager(namespace=namespace,
                                   propagate_map_exceptions=True,
                                   on_load_failure_callback=_raise))

    LOG.debug('Resource OEM extensions for "%(resource)s" under namespace '
              '"%(namespace)s":',
              {'resource': resource_name, 'namespace': namespace})
    for extension in extension_manager:
        LOG.debug('Found vendor: %(name)s target: %(target)s',
                  {'name': extension.name,
                   'target': extension.entry_point_target})

    if not extension_manager.names():
        m = (('No extensions found for "%(resource)s" under namespace '
              '"%(namespace)s"') %
             {'resource': resource_name,
              'namespace': namespace})
        LOG.error(m)
        raise exceptions.ExtensionError(error=m)

    return extension_manager 
開發者ID:openstack,項目名稱:sushy,代碼行數:38,代碼來源:common.py


注:本文中的stevedore.ExtensionManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。