Class for V3 router packages
The V3 routes were being added by the append_v3_routers function in each controller package, so the only way state could be stored is in a global variable which makes unit testing difficult. With this change, the append_v3_routers functions are put into a class in each package. This will eventually be used to store JSON Home data. bp json-home Change-Id: I744a4c82dc84bb1a8d29d0314e3c51cc43c077a2
This commit is contained in:
parent
76f3c55e71
commit
dd70a5548e
@ -55,7 +55,9 @@ class Admin(wsgi.ComposableRouter):
|
||||
conditions=dict(method=['GET']))
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
routers.append(
|
||||
router.Router(controllers.DomainV3(),
|
||||
'domains', 'domain'))
|
||||
@ -71,19 +73,23 @@ def append_v3_routers(mapper, routers):
|
||||
|
||||
role_controller = controllers.RoleV3()
|
||||
routers.append(router.Router(role_controller, 'roles', 'role'))
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='create_grant',
|
||||
conditions=dict(method=['PUT']))
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='create_grant',
|
||||
conditions=dict(method=['PUT']))
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='check_grant',
|
||||
conditions=dict(method=['GET', 'HEAD']))
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='check_grant',
|
||||
conditions=dict(method=['GET', 'HEAD']))
|
||||
@ -95,11 +101,13 @@ def append_v3_routers(mapper, routers):
|
||||
controller=role_controller,
|
||||
action='list_grants',
|
||||
conditions=dict(method=['GET']))
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/users/{user_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='revoke_grant',
|
||||
conditions=dict(method=['DELETE']))
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/projects/{project_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='revoke_grant',
|
||||
conditions=dict(method=['DELETE']))
|
||||
@ -107,7 +115,8 @@ def append_v3_routers(mapper, routers):
|
||||
controller=role_controller,
|
||||
action='create_grant',
|
||||
conditions=dict(method=['PUT']))
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='create_grant',
|
||||
conditions=dict(method=['PUT']))
|
||||
@ -115,7 +124,8 @@ def append_v3_routers(mapper, routers):
|
||||
controller=role_controller,
|
||||
action='check_grant',
|
||||
conditions=dict(method=['GET', 'HEAD']))
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='check_grant',
|
||||
conditions=dict(method=['GET', 'HEAD']))
|
||||
@ -131,7 +141,8 @@ def append_v3_routers(mapper, routers):
|
||||
controller=role_controller,
|
||||
action='revoke_grant',
|
||||
conditions=dict(method=['DELETE']))
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
|
||||
mapper.connect('/domains/{domain_id}/groups/{group_id}/roles/'
|
||||
'{role_id}',
|
||||
controller=role_controller,
|
||||
action='revoke_grant',
|
||||
conditions=dict(method=['DELETE']))
|
||||
|
@ -13,9 +13,12 @@
|
||||
# under the License.
|
||||
|
||||
from keystone.auth import controllers
|
||||
from keystone.common import wsgi
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
auth_controller = controllers.Auth()
|
||||
|
||||
mapper.connect('/auth/tokens',
|
||||
|
@ -14,9 +14,12 @@
|
||||
|
||||
from keystone.catalog import controllers
|
||||
from keystone.common import router
|
||||
from keystone.common import wsgi
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
regions_controller = controllers.RegionV3()
|
||||
routers.append(router.Router(regions_controller,
|
||||
'regions', 'region'))
|
||||
|
@ -604,6 +604,16 @@ class ExtensionRouter(Router):
|
||||
return _factory
|
||||
|
||||
|
||||
class RoutersBase(object):
|
||||
"""Base class for Routers."""
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
"""Append v3 routers.
|
||||
|
||||
Subclasses should override this method to map its routes.
|
||||
"""
|
||||
|
||||
|
||||
def render_response(body=None, status=None, headers=None, method=None):
|
||||
"""Forms a WSGI response."""
|
||||
if headers is None:
|
||||
|
@ -15,10 +15,13 @@
|
||||
"""WSGI Routers for the Credentials service."""
|
||||
|
||||
from keystone.common import router
|
||||
from keystone.common import wsgi
|
||||
from keystone.credential import controllers
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
routers.append(
|
||||
router.Router(controllers.CredentialV3(),
|
||||
'credentials', 'credential'))
|
||||
|
@ -27,7 +27,9 @@ class Admin(wsgi.ComposableRouter):
|
||||
conditions=dict(method=['GET']))
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
user_controller = controllers.UserV3()
|
||||
routers.append(
|
||||
router.Router(user_controller,
|
||||
|
@ -12,9 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from keystone.common import router
|
||||
from keystone.common import wsgi
|
||||
from keystone.policy import controllers
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
policy_controller = controllers.PolicyV3()
|
||||
routers.append(router.Router(policy_controller, 'policies', 'policy'))
|
||||
|
@ -89,11 +89,14 @@ def v3_app_factory(global_conf, **local_conf):
|
||||
controllers.register_version('v3')
|
||||
mapper = routes.Mapper()
|
||||
v3routers = []
|
||||
for module in [assignment, auth, catalog, credential, identity, policy]:
|
||||
module.routers.append_v3_routers(mapper, v3routers)
|
||||
|
||||
router_modules = [assignment, auth, catalog, credential, identity, policy]
|
||||
if CONF.trust.enabled:
|
||||
trust.routers.append_v3_routers(mapper, v3routers)
|
||||
router_modules.append(trust)
|
||||
|
||||
for module in router_modules:
|
||||
routers_instance = module.routers.Routers()
|
||||
routers_instance.append_v3_routers(mapper, v3routers)
|
||||
|
||||
# Add in the v3 version api
|
||||
v3routers.append(routers.VersionV3('admin'))
|
||||
|
@ -13,10 +13,13 @@
|
||||
# under the License.
|
||||
"""WSGI Routers for the Identity service."""
|
||||
|
||||
from keystone.common import wsgi
|
||||
from keystone.trust import controllers
|
||||
|
||||
|
||||
def append_v3_routers(mapper, routers):
|
||||
class Routers(wsgi.RoutersBase):
|
||||
|
||||
def append_v3_routers(self, mapper, routers):
|
||||
trust_controller = controllers.TrustV3()
|
||||
|
||||
mapper.connect('/OS-TRUST/trusts',
|
||||
|
Loading…
Reference in New Issue
Block a user