Exemple #1
0
def create_stores():
    """
    Registers all store modules and all schemes
    from the given config. Duplicates are not re-registered.
    """
    store_count = 0
    store_classes = set()
    for store_entry in CONF.known_stores:
        store_entry = store_entry.strip()
        if not store_entry:
            continue
        store_cls = _get_store_class(store_entry)
        store_instance = store_cls()
        schemes = store_instance.get_schemes()
        if not schemes:
            raise BackendException('Unable to register store %s. '
                                   'No schemes associated with it.' %
                                   store_cls)
        else:
            if store_cls not in store_classes:
                LOG.debug("Registering store %s with schemes %s", store_cls,
                          schemes)
                store_classes.add(store_cls)
                scheme_map = {}
                for scheme in schemes:
                    loc_cls = store_instance.get_store_location_class()
                    scheme_map[scheme] = {
                        'store_class': store_cls,
                        'location_class': loc_cls,
                    }
                location.register_scheme_map(scheme_map)
                store_count += 1
            else:
                LOG.debug("Store %s already registered", store_cls)
    return store_count
Exemple #2
0
def create_stores():
    """
    Registers all store modules and all schemes
    from the given config. Duplicates are not re-registered.
    """
    store_count = 0
    store_classes = set()
    for store_entry in CONF.known_stores:
        store_entry = store_entry.strip()
        if not store_entry:
            continue
        store_cls = _get_store_class(store_entry)
        store_instance = store_cls()
        schemes = store_instance.get_schemes()
        if not schemes:
            raise BackendException('Unable to register store %s. '
                                   'No schemes associated with it.'
                                   % store_cls)
        else:
            if store_cls not in store_classes:
                LOG.debug("Registering store %s with schemes %s",
                          store_cls, schemes)
                store_classes.add(store_cls)
                scheme_map = {}
                for scheme in schemes:
                    loc_cls = store_instance.get_store_location_class()
                    scheme_map[scheme] = {
                        'store_class': store_cls,
                        'location_class': loc_cls,
                    }
                location.register_scheme_map(scheme_map)
                store_count += 1
            else:
                LOG.debug("Store %s already registered", store_cls)
    return store_count
Exemple #3
0
def create_stores(conf=CONF):
    """
    Registers all store modules and all schemes
    from the given config. Duplicates are not re-registered.
    """
    store_count = 0
    store_classes = set()

    for (store_entry, store_instance) in _load_stores(conf):
        schemes = store_instance.get_schemes()
        store_instance.configure()
        if not schemes:
            raise exceptions.BackendException(
                "Unable to register store %s. " "No schemes associated with it." % store_cls
            )
        else:
            LOG.debug("Registering store %s with schemes %s", store_entry, schemes)

            scheme_map = {}
            for scheme in schemes:
                loc_cls = store_instance.get_store_location_class()
                scheme_map[scheme] = {"store": store_instance, "location_class": loc_cls}
            location.register_scheme_map(scheme_map)
            store_count += 1

    return store_count
Exemple #4
0
def create_stores():
    """
    Registers all store modules and all schemes
    from the given config. Duplicates are not re-registered.
    """
    store_count = 0
    store_classes = set()
    for store_entry in set(CONF.known_stores + _ALL_STORES):
        store_entry = store_entry.strip()
        if not store_entry:
            continue
        store_cls = _get_store_class(store_entry)
        try:
            store_instance = store_cls()
        except exception.BadStoreConfiguration as e:
            if store_entry in CONF.known_stores:
                LOG.warn(
                    _("%s Skipping store driver.") % utils.exception_to_str(e))
            continue
        finally:
            # NOTE(flaper87): To be removed in Juno
            if store_entry not in CONF.known_stores:
                LOG.deprecated(
                    _("%s not found in `known_store`. "
                      "Stores need to be explicitly enabled in "
                      "the configuration file.") % store_entry)

        schemes = store_instance.get_schemes()
        if not schemes:
            raise BackendException('Unable to register store %s. '
                                   'No schemes associated with it.' %
                                   store_cls)
        else:
            if store_cls not in store_classes:
                LOG.debug(
                    "Registering store %(cls)s with schemes "
                    "%(schemes)s", {
                        'cls': store_cls,
                        'schemes': schemes
                    })
                store_classes.add(store_cls)
                scheme_map = {}
                for scheme in schemes:
                    loc_cls = store_instance.get_store_location_class()
                    scheme_map[scheme] = {
                        'store_class': store_cls,
                        'location_class': loc_cls,
                    }
                location.register_scheme_map(scheme_map)
                store_count += 1
            else:
                LOG.debug("Store %s already registered", store_cls)
    _register_stores(store_classes)
    return store_count
Exemple #5
0
    def register_store_schemes(self, store):
        schemes = store.get_schemes()
        scheme_map = {}

        for scheme in schemes:
            loc_cls = store.get_store_location_class()
            scheme_map[scheme] = {
                'store': store,
                'location_class': loc_cls,
            }
        location.register_scheme_map(scheme_map)
Exemple #6
0
def create_stores():
    """
    Registers all store modules and all schemes
    from the given config. Duplicates are not re-registered.
    """
    store_count = 0
    store_classes = set()
    for store_entry in set(CONF.known_stores + _ALL_STORES):
        store_entry = store_entry.strip()
        if not store_entry:
            continue
        store_cls = _get_store_class(store_entry)
        try:
            store_instance = store_cls()
        except exception.BadStoreConfiguration as e:
            if store_entry in CONF.known_stores:
                LOG.warn(_("%s Skipping store driver.") %
                         utils.exception_to_str(e))
            continue
        finally:
            # NOTE(flaper87): To be removed in Juno
            if store_entry not in CONF.known_stores:
                LOG.deprecated(_("%s not found in `known_store`. "
                                 "Stores need to be explicitly enabled in "
                                 "the configuration file.") % store_entry)

        schemes = store_instance.get_schemes()
        if not schemes:
            raise BackendException('Unable to register store %s. '
                                   'No schemes associated with it.'
                                   % store_cls)
        else:
            if store_cls not in store_classes:
                LOG.debug(_("Registering store %(cls)s with schemes "
                            "%(schemes)s"), {'cls': store_cls,
                                             'schemes': schemes})
                store_classes.add(store_cls)
                scheme_map = {}
                for scheme in schemes:
                    loc_cls = store_instance.get_store_location_class()
                    scheme_map[scheme] = {
                        'store_class': store_cls,
                        'location_class': loc_cls,
                    }
                location.register_scheme_map(scheme_map)
                store_count += 1
            else:
                LOG.debug(_("Store %s already registered"), store_cls)
    _register_stores(store_classes)
    return store_count
Exemple #7
0
def register_store(store_module, schemes):
    """
    Registers a store module and a set of schemes
    for which a particular URI request should be routed.

    :param store_module: String representing the store module
    :param schemes: List of strings representing schemes for
                    which this store should be used in routing
    """
    try:
        utils.import_class(store_module + '.Store')
    except exception.NotFound:
        raise BackendException('Unable to register store. Could not find '
                               'a class named Store in module %s.' %
                               store_module)
    REGISTERED_STORE_MODULES.append(store_module)
    scheme_map = {}
    for scheme in schemes:
        scheme_map[scheme] = store_module
    location.register_scheme_map(scheme_map)
Exemple #8
0
def register_store(store_module, schemes):
    """
    Registers a store module and a set of schemes
    for which a particular URI request should be routed.

    :param store_module: String representing the store module
    :param schemes: List of strings representing schemes for
                    which this store should be used in routing
    """
    try:
        utils.import_class(store_module + '.Store')
    except exception.NotFound:
        raise BackendException('Unable to register store. Could not find '
                               'a class named Store in module %s.'
                               % store_module)
    REGISTERED_STORE_MODULES.append(store_module)
    scheme_map = {}
    for scheme in schemes:
        scheme_map[scheme] = store_module
    location.register_scheme_map(scheme_map)