From: Ivan Kolodyazhny Date: Tue, 16 Dec 2014 23:04:33 +0000 (+0200) Subject: Remove custom lazy loading X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2146c18c4abc7675b768008133b27ec3c2927943;p=openstack-build%2Fcinder-build.git Remove custom lazy loading We are using stevedore for database migration backend loading Closes-Bug: #1420321 Change-Id: I281d631f9fd72d9d6938ffd2945fbeea8099dff5 --- diff --git a/cinder/db/api.py b/cinder/db/api.py index 4a393e60d..7cd45a34a 100644 --- a/cinder/db/api.py +++ b/cinder/db/api.py @@ -17,8 +17,6 @@ """Defines interface for DB access. -The underlying driver is loaded as a :class:`LazyPluggable`. - Functions in this module are imported into the cinder.db namespace. Call these functions from cinder.db namespace, not the cinder.db.api namespace. @@ -30,9 +28,6 @@ these objects be simple dictionaries. **Related Flags** -:backend: string to lookup in the list of LazyPluggable backends. - `sqlalchemy` is the only supported backend right now. - :connection: string specifying the sqlalchemy connection to use, like: `sqlite:///var/lib/cinder/cinder.sqlite`. @@ -47,14 +42,6 @@ from oslo.db import options as db_options db_opts = [ - # TODO(rpodolyaka): this option is deprecated but still passed to - # LazyPluggable class which doesn't support retrieving - # of options put into groups. Nova's version of this - # class supports this. Perhaps, we should put it to Oslo - # and then reuse here. - cfg.StrOpt('db_backend', - default='sqlalchemy', - help='The backend to use for db'), cfg.BoolOpt('enable_new_services', default=True, help='Services to be added to the available pool on create'), diff --git a/cinder/utils.py b/cinder/utils.py index aa6fadcc9..0ad14dd5b 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -276,37 +276,6 @@ def last_completed_audit_period(unit=None): return (begin, end) -class LazyPluggable(object): - """A pluggable backend loaded lazily based on some value.""" - - def __init__(self, pivot, **backends): - self.__backends = backends - self.__pivot = pivot - self.__backend = None - - def __get_backend(self): - if not self.__backend: - backend_name = CONF[self.__pivot] - if backend_name not in self.__backends: - raise exception.Error(_('Invalid backend: %s') % backend_name) - - backend = self.__backends[backend_name] - if isinstance(backend, tuple): - name = backend[0] - fromlist = backend[1] - else: - name = backend - fromlist = backend - - self.__backend = __import__(name, None, None, fromlist) - LOG.debug('backend %s', self.__backend) - return self.__backend - - def __getattr__(self, key): - backend = self.__get_backend() - return getattr(backend, key) - - class ProtectedExpatParser(expatreader.ExpatParser): """An expat parser which disables DTD's and entities by default."""