示例#1
0
def fetch(conf, namespace=BACKEND_NAMESPACE):
    backend_name = urlutils.urlparse(conf['connection']).scheme
    LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
    try:
        mgr = driver.DriverManager(namespace, backend_name,
                                   invoke_on_load=True,
                                   invoke_kwds={'conf': conf})
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
示例#2
0
def fetch(conf, namespace=BACKEND_NAMESPACE):
    backend_name = urlutils.urlparse(conf['connection']).scheme
    LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
    try:
        mgr = driver.DriverManager(namespace,
                                   backend_name,
                                   invoke_on_load=True,
                                   invoke_kwds={'conf': conf})
        return mgr.driver
    except RuntimeError as e:
        raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
def _make_conf(backend_uri):
    parsed_url = urlutils.urlparse(backend_uri)
    backend_type = parsed_url.scheme.lower()
    if not backend_type:
        raise ValueError("Unknown backend type for uri: %s" % (backend_type))
    if backend_type in ('file', 'dir'):
        conf = {
            'path': parsed_url.path,
            'connection': backend_uri,
        }
    else:
        conf = {
            'connection': backend_uri,
        }
    return conf