How to use the stevedore.extension function in stevedore

To help you get started, we’ve selected a few stevedore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / cliff / cliff / command.py View on Github external
def _load_hooks(self):
        # Look for command extensions
        if self.app and self.cmd_name:
            namespace = '{}.{}'.format(
                self.app.command_manager.namespace,
                self.cmd_name.replace(' ', '_')
            )
            self._hooks = extension.ExtensionManager(
                namespace=namespace,
                invoke_on_load=True,
                invoke_kwds={
                    'command': self,
                },
            )
        else:
            # Setting _hooks to an empty list allows iteration without
            # checking if there are hooks every time.
            self._hooks = []
        return
github openstack / keystoneauth / keystoneauth / openstack / common / apiclient / auth.py View on Github external
def discover_auth_systems():
    """Discover the available auth-systems.

    This won't take into account the old style auth-systems.
    """
    global _discovered_plugins
    _discovered_plugins = {}

    def add_plugin(ext):
        _discovered_plugins[ext.name] = ext.plugin

    ep_namespace = "keystonauth.openstack.common.apiclient.auth"
    mgr = extension.ExtensionManager(ep_namespace)
    mgr.map(add_plugin)
github PyCQA / doc8 / doc8 / main.py View on Github external
def fetch_checks(cfg):
    base = [
        checks.CheckValidity(cfg),
        checks.CheckTrailingWhitespace(cfg),
        checks.CheckIndentationNoTab(cfg),
        checks.CheckCarriageReturn(cfg),
        checks.CheckMaxLineLength(cfg),
        checks.CheckNewlineEndOfFile(cfg),
    ]
    mgr = extension.ExtensionManager(
        namespace="doc8.extension.check", invoke_on_load=True, invoke_args=(cfg.copy(),)
    )
    addons = []
    for e in mgr:
        addons.append(e.obj)
    return base + addons
github openstack / designate / designate / api / v1 / __init__.py View on Github external
response = flask.jsonify(**response)
        response.status_code = code

        return response

    for code in six.iterkeys(wexceptions.default_exceptions):
        app.register_error_handler(code, _json_error)

    # TODO(kiall): Ideally, we want to make use of the Plugin class here.
    #              This works for the moment though.
    def _register_blueprint(ext):
        app.register_blueprint(ext.plugin)

    # Add all in-built APIs
    mgr = extension.ExtensionManager('designate.api.v1')
    mgr.map(_register_blueprint)

    # Add any (enabled) optional extensions
    extensions = cfg.CONF['service:api'].enabled_extensions_v1

    if len(extensions) > 0:
        extmgr = named.NamedExtensionManager('designate.api.v1.extensions',
                                             names=extensions)
        extmgr.map(_register_blueprint)

    return app
github cloud-ark / caastle / server / gcloud_handler.py View on Github external
home_dir = expanduser("~")

APP_AND_ENV_STORE_PATH = ("{home_dir}/.cld/data/deployments/").format(home_dir=home_dir)

fmlogger = fm_logger.Logging()


class GCloudHandler(object):

    res_mgr = extension.ExtensionManager(
        namespace='server.server_plugins.gcloud.resource',
        invoke_on_load=True,
    )

    coe_mgr = extension.ExtensionManager(
        namespace='server.server_plugins.gcloud.coe',
        invoke_on_load=True,
    )

    app_mgr = extension.ExtensionManager(
        namespace='server.server_plugins.gcloud.app',
        invoke_on_load=True,
    )

    gcloudhelper = gcloud_helper.GCloudHelper()

    def create_resources(self, env_id, resource_list):
        fmlogger.debug("GCloudHandler create_resources")
        resource_details = ''
        ret_status_list = []
github openstack / python-troveclient / troveclient / apiclient / auth.py View on Github external
def discover_auth_systems():
    """Discover the available auth-systems.

    This won't take into account the old style auth-systems.
    """
    global _discovered_plugins
    _discovered_plugins = {}

    def add_plugin(ext):
        _discovered_plugins[ext.name] = ext.plugin

    ep_namespace = "troveclient.apiclient.auth"
    mgr = extension.ExtensionManager(ep_namespace)
    mgr.map(add_plugin)
github unitedstack / gringotts / gringotts / waiter / plugins / volume.py View on Github external
def __init__(self):
        super(VolumeNotificationBase, self).__init__()
        self.product_items = extension.ExtensionManager(
            namespace='gringotts.volume.product_item',
            invoke_on_load=True,
        )
github unitedstack / gringotts / gringotts / checker / notifier / __init__.py View on Github external
def __init__(self, level):
        self.level = level or 0
        self.notifiers = []
        extensions = extension.ExtensionManager(self.EXTENSIONS_NAMESPACE,
                                                invoke_on_load=True)
        if self.level == 0:
            self.notifiers.append(extensions['log'].obj)
        elif self.level == 1:
            self.notifiers.append(extensions['log'].obj)
            self.notifiers.append(extensions['email'].obj)
        else:
            self.notifiers.append(extensions['log'].obj)
            self.notifiers.append(extensions['email'].obj)
            self.notifiers.append(extensions['sms'].obj)
github openstack / mistral / mistral / expressions / __init__.py View on Github external
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import copy

from oslo_log import log as logging
import six
from stevedore import extension

from mistral import exceptions as exc

LOG = logging.getLogger(__name__)

_mgr = extension.ExtensionManager(
    namespace='mistral.expression.evaluators',
    invoke_on_load=False
)

_evaluators = []
patterns = {}

for name in sorted(_mgr.names()):
    evaluator = _mgr[name].plugin
    _evaluators.append((name, evaluator))
    patterns[name] = evaluator.find_expression_pattern.pattern


def validate(expression):
    LOG.debug("Validating expression [expression='%s']", expression)
github openstack / cloudkitty / cloudkitty / utils.py View on Github external
"""Trigger reload of entry points.

    Useful to have dynamic loading/unloading of stevedore modules.
    """
    # NOTE(sheeprine): pkg_resources doesn't support reload on python3 due to
    # defining basestring which is still there on reload hence executing
    # python2 related code.
    try:
        del sys.modules['pkg_resources'].basestring
    except AttributeError:
        # python2, do nothing
        pass
    # Force working_set reload
    moves.reload_module(sys.modules['pkg_resources'])
    # Clear stevedore cache
    cache = extension.ExtensionManager.ENTRY_POINT_CACHE
    if namespace:
        if namespace in cache:
            del cache[namespace]
    else:
        cache.clear()