Beispiel #1
0
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
Beispiel #2
0
def _raise(m, ep, e):
    raise exceptions.ExtensionError(
        error='Failed to load entry point target: %(error)s' % {'error': e})