Provide the V3 routers to the V3 extension controller

The V3 extension controller needs access to the V3 routers because
they provide the JSON Home data.

bp json-home

Change-Id: Ia455c7c5c06f7cfcefa0bc6afc91bf6954d85e3c
This commit is contained in:
Brant Knudson 2014-08-02 18:52:28 -05:00
parent de61102e0a
commit 47723ed130
3 changed files with 13 additions and 8 deletions

View File

@ -62,8 +62,9 @@ def register_version(version):
class Version(wsgi.Application): class Version(wsgi.Application):
def __init__(self, version_type): def __init__(self, version_type, routers=None):
self.endpoint_url_type = version_type self.endpoint_url_type = version_type
self._routers = routers
super(Version, self).__init__() super(Version, self).__init__()

View File

@ -57,11 +57,13 @@ class VersionV2(wsgi.ComposableRouter):
class VersionV3(wsgi.ComposableRouter): class VersionV3(wsgi.ComposableRouter):
def __init__(self, description): def __init__(self, description, routers):
self.description = description self.description = description
self._routers = routers
def add_routes(self, mapper): def add_routes(self, mapper):
version_controller = controllers.Version(self.description) version_controller = controllers.Version(self.description,
routers=self._routers)
mapper.connect('/', mapper.connect('/',
controller=version_controller, controller=version_controller,
action='get_version_v3') action='get_version_v3')

View File

@ -88,7 +88,8 @@ def admin_version_app_factory(global_conf, **local_conf):
def v3_app_factory(global_conf, **local_conf): def v3_app_factory(global_conf, **local_conf):
controllers.register_version('v3') controllers.register_version('v3')
mapper = routes.Mapper() mapper = routes.Mapper()
v3routers = [] sub_routers = []
_routers = []
router_modules = [assignment, auth, catalog, credential, identity, policy] router_modules = [assignment, auth, catalog, credential, identity, policy]
if CONF.trust.enabled: if CONF.trust.enabled:
@ -96,10 +97,11 @@ def v3_app_factory(global_conf, **local_conf):
for module in router_modules: for module in router_modules:
routers_instance = module.routers.Routers() routers_instance = module.routers.Routers()
routers_instance.append_v3_routers(mapper, v3routers) _routers.append(routers_instance)
routers_instance.append_v3_routers(mapper, sub_routers)
# Add in the v3 version api # Add in the v3 version api
v3routers.append(routers.VersionV3('admin')) sub_routers.append(routers.VersionV3('admin', _routers))
v3routers.append(routers.VersionV3('public')) sub_routers.append(routers.VersionV3('public', _routers))
# TODO(ayoung): put token routes here # TODO(ayoung): put token routes here
return wsgi.ComposingRouter(mapper, v3routers) return wsgi.ComposingRouter(mapper, sub_routers)