Use stevedore to load storage engine drivers
Use the stevedore library to load the storage engine plugins. Change-Id: I491317e64e4fa50340e16b0f67783bfeca09c979 Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
parent
0a431b2e7c
commit
06b2207ef7
@ -18,7 +18,7 @@
|
|||||||
"""Storage backend management
|
"""Storage backend management
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pkg_resources
|
from stevedore import driver
|
||||||
|
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import cfg
|
from ceilometer.openstack.common import cfg
|
||||||
@ -53,20 +53,10 @@ def get_engine(conf):
|
|||||||
engine_name = urlparse(conf.database_connection).scheme
|
engine_name = urlparse(conf.database_connection).scheme
|
||||||
LOG.debug('looking for %r driver in %r',
|
LOG.debug('looking for %r driver in %r',
|
||||||
engine_name, STORAGE_ENGINE_NAMESPACE)
|
engine_name, STORAGE_ENGINE_NAMESPACE)
|
||||||
for ep in pkg_resources.iter_entry_points(STORAGE_ENGINE_NAMESPACE,
|
mgr = driver.DriverManager(STORAGE_ENGINE_NAMESPACE,
|
||||||
engine_name):
|
engine_name,
|
||||||
try:
|
invoke_on_load=True)
|
||||||
engine_class = ep.load()
|
return mgr.driver
|
||||||
engine = engine_class()
|
|
||||||
except Exception as err:
|
|
||||||
LOG.error('Failed to load storage engine %s: %s',
|
|
||||||
engine_name, err)
|
|
||||||
LOG.exception(err)
|
|
||||||
raise
|
|
||||||
LOG.info('Loaded %s storage engine %r', engine_name, ep)
|
|
||||||
return engine
|
|
||||||
else:
|
|
||||||
raise RuntimeError('No %r storage engine found' % engine_name)
|
|
||||||
|
|
||||||
|
|
||||||
def get_connection(conf):
|
def get_connection(conf):
|
||||||
|
@ -9,3 +9,4 @@ sqlalchemy
|
|||||||
eventlet
|
eventlet
|
||||||
anyjson==0.3.1
|
anyjson==0.3.1
|
||||||
Flask==0.9
|
Flask==0.9
|
||||||
|
stevedore>=0.4
|
||||||
|
@ -10,3 +10,4 @@ argparse
|
|||||||
sqlalchemy
|
sqlalchemy
|
||||||
anyjson==0.3.1
|
anyjson==0.3.1
|
||||||
Flask==0.9
|
Flask==0.9
|
||||||
|
stevedore>=0.4
|
||||||
|
Loading…
Reference in New Issue
Block a user