Merge "Cleanup backend loading"

This commit is contained in:
Jenkins 2013-12-15 08:53:54 +00:00 committed by Gerrit Code Review
commit 2f10188457
4 changed files with 35 additions and 40 deletions

View File

@ -46,6 +46,7 @@ from keystone.common import environment
from keystone.common import utils
from keystone import config
from keystone.openstack.common import importutils
from keystone import service
CONF = config.CONF
@ -122,6 +123,8 @@ if __name__ == '__main__':
monkeypatch_thread = False
environment.use_eventlet(monkeypatch_thread)
service.load_backends()
servers = []
servers.append(create_server(paste_config,
'admin',

View File

@ -29,6 +29,7 @@ gettextutils.install('keystone')
from keystone.common import environment
from keystone import config
from keystone.openstack.common import log
from keystone import service
CONF = config.CONF
@ -41,6 +42,9 @@ name = os.path.basename(__file__)
if CONF.debug:
CONF.log_opt_values(log.getLogger(CONF.prog), logging.DEBUG)
drivers = service.load_backends()
# NOTE(ldbragst): 'application' is required in this context by WSGI spec.
# The following is a reference to Python Paste Deploy documentation
# http://pythonpaste.org/deploy/

View File

@ -42,23 +42,32 @@ LOG = logging.getLogger(__name__)
# Ensure the cache is configured and built before we instantiate the managers
cache.configure_cache_region(cache.REGION)
# Ensure that the identity driver is created before the assignment manager.
# The default assignment driver is determined by the identity driver, so the
# identity driver must be available to the assignment manager.
_IDENTITY_API = identity.Manager()
DRIVERS = dict(
assignment_api=assignment.Manager(),
catalog_api=catalog.Manager(),
credentials_api=credential.Manager(),
endpoint_filter_api=endpoint_filter.Manager(),
identity_api=_IDENTITY_API,
policy_api=policy.Manager(),
token_api=token.Manager(),
trust_api=trust.Manager(),
token_provider_api=token.provider.Manager())
def load_backends(include_oauth1=False):
dependency.resolve_future_dependencies()
# Ensure that the identity driver is created before the assignment manager.
# The default assignment driver is determined by the identity driver, so
# the identity driver must be available to the assignment manager.
_IDENTITY_API = identity.Manager()
DRIVERS = dict(
assignment_api=assignment.Manager(),
catalog_api=catalog.Manager(),
credential_api=credential.Manager(),
endpoint_filter_api=endpoint_filter.Manager(),
identity_api=_IDENTITY_API,
policy_api=policy.Manager(),
token_api=token.Manager(),
trust_api=trust.Manager(),
token_provider_api=token.provider.Manager())
if include_oauth1:
from keystone.contrib import oauth1
DRIVERS['oauth1_api'] = oauth1.Manager()
dependency.resolve_future_dependencies()
return DRIVERS
def fail_gracefully(f):

View File

@ -44,8 +44,6 @@ from keystone.openstack.common import gettextutils
# Accept-Language in the request rather than the Keystone server locale.
gettextutils.install('keystone', lazy=True)
from keystone import assignment
from keystone import catalog
from keystone.common import cache
from keystone.common import dependency
from keystone.common import environment
@ -55,17 +53,10 @@ from keystone.common import sql
from keystone.common import utils
from keystone.common import wsgi
from keystone import config
from keystone.contrib import endpoint_filter
from keystone.contrib import oauth1
from keystone import credential
from keystone import exception
from keystone import identity
from keystone.openstack.common import log
from keystone.openstack.common import timeutils
from keystone import policy
from keystone import token
from keystone.token import provider as token_provider
from keystone import trust
from keystone import service
# NOTE(dstanek): Tests inheriting from TestCase depend on having the
# policy_file command-line option declared before setUp runs. Importing the
@ -347,22 +338,10 @@ class TestCase(testtools.TestCase):
# should eventually be removed once testing has been cleaned up.
kvs_core.KEY_VALUE_STORE_REGISTRY.clear()
# NOTE(blk-u): identity must be before assignment to ensure that the
# identity driver is available to the assignment manager because the
# assignment manager gets the default assignment driver from the
# identity driver.
for manager in [identity, assignment, catalog, credential,
endpoint_filter, policy, token, token_provider,
trust, oauth1]:
# manager.__name__ is like keystone.xxx[.yyy],
# converted to xxx[_yyy]
manager_name = ('%s_api' %
manager.__name__.replace('keystone.', '').
replace('.', '_'))
drivers = service.load_backends(include_oauth1=True)
setattr(self, manager_name, manager.Manager())
dependency.resolve_future_dependencies()
for manager_name, manager in drivers.iteritems():
setattr(self, manager_name, manager)
def load_fixtures(self, fixtures):
"""Hacky basic and naive fixture loading based on a python module.