summaryrefslogtreecommitdiff
path: root/taskflow/persistence
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-05 13:07:29 +0000
committerGerrit Code Review <review@openstack.org>2016-01-05 13:07:29 +0000
commit14e32d5aef270a43346aa836f8cc2d12a0f3b1ff (patch)
treed7887c462a14c2fce9e1583935356318a9e80197 /taskflow/persistence
parent0380a32e690bb6b9c402855603cc47445a5116e2 (diff)
parentc145bef2247ebb5ac56c6429b301ae1de622bc37 (diff)
downloadtaskflow-14e32d5aef270a43346aa836f8cc2d12a0f3b1ff.tar.gz
Merge "Use shared util helper for driver name + config extraction"
Diffstat (limited to 'taskflow/persistence')
-rw-r--r--taskflow/persistence/backends/__init__.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/taskflow/persistence/backends/__init__.py b/taskflow/persistence/backends/__init__.py
index 50f2416..294febe 100644
--- a/taskflow/persistence/backends/__init__.py
+++ b/taskflow/persistence/backends/__init__.py
@@ -16,7 +16,6 @@
import contextlib
-import six
from stevedore import driver
from taskflow import exceptions as exc
@@ -51,30 +50,21 @@ def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs):
is ``{'a': 'b', 'c': 'd'}`` to the constructor of that persistence backend
instance.
"""
- if isinstance(conf, six.string_types):
- conf = {'connection': conf}
- backend_name = conf['connection']
- try:
- uri = misc.parse_uri(backend_name)
- except (TypeError, ValueError):
- pass
- else:
- backend_name = uri.scheme
- conf = misc.merge_uri(uri, conf.copy())
+ backend, conf = misc.extract_driver_and_conf(conf, 'connection')
# If the backend is like 'mysql+pymysql://...' which informs the
# backend to use a dialect (supported by sqlalchemy at least) we just want
# to look at the first component to find our entrypoint backend name...
- if backend_name.find("+") != -1:
- backend_name = backend_name.split("+", 1)[0]
- LOG.debug('Looking for %r backend driver in %r', backend_name, namespace)
+ if backend.find("+") != -1:
+ backend = backend.split("+", 1)[0]
+ LOG.debug('Looking for %r backend driver in %r', backend, namespace)
try:
- mgr = driver.DriverManager(namespace, backend_name,
+ mgr = driver.DriverManager(namespace, backend,
invoke_on_load=True,
invoke_args=(conf,),
invoke_kwds=kwargs)
return mgr.driver
except RuntimeError as e:
- raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e))
+ raise exc.NotFound("Could not find backend %s: %s" % (backend, e))
@contextlib.contextmanager