Changes to support API calls as per OS-KSCATALOG extension.

Change-Id: I087b6f06528e4751d92fd9a98d5dc4d7f4c1c774
This commit is contained in:
Yogeshwar Srikrishnan 2011-10-19 10:38:43 -05:00
parent 831a755a77
commit 37ff1d6762
4 changed files with 92 additions and 54 deletions

View File

@ -19,8 +19,13 @@
from keystone.contrib.extensions.admin.osksadm.extension_handler\
import ExtensionHandler as KSADMExtensionHandler
from keystone.contrib.extensions.admin.oskscatalog.extension_handler\
import ExtensionHandler as KSCATALOGExtensionHandler
def configure_extensions(mapper, options):
#TODO: Make extensions configurable.
ksadm_extenion_handler = KSADMExtensionHandler()
ksadm_extenion_handler.map_extension_methods(mapper, options)
kscatalog_extension_handler = KSCATALOGExtensionHandler()
kscatalog_extension_handler.map_extension_methods(mapper, options)

View File

@ -0,0 +1,63 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from keystone.contrib.extensions.admin.extension import BaseExtensionHandler
from keystone.controllers.endpointtemplates import EndpointTemplatesController
class ExtensionHandler(BaseExtensionHandler):
def map_extension_methods(self, mapper, options):
#EndpointTemplates Calls
endpoint_templates_controller = EndpointTemplatesController(options)
mapper.connect("/OS-KSCATALOG/endpointTemplates",
controller=endpoint_templates_controller,
action="get_endpoint_templates",
conditions=dict(method=["GET"]))
mapper.connect("/OS-KSCATALOG/endpointTemplates",
controller=endpoint_templates_controller,
action="add_endpoint_template",
conditions=dict(method=["POST"]))
mapper.connect(
"/OS-KSCATALOG/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="get_endpoint_template",
conditions=dict(method=["GET"]))
mapper.connect(
"/OS-KSCATALOG/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="modify_endpoint_template",
conditions=dict(method=["PUT"]))
mapper.connect(
"/OS-KSCATALOG/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="delete_endpoint_template",
conditions=dict(method=["DELETE"]))
#Endpoint Calls
mapper.connect("/tenants/{tenant_id}/OS-KSCATALOG/endpoints",
controller=endpoint_templates_controller,
action="get_endpoints_for_tenant",
conditions=dict(method=["GET"]))
mapper.connect("/tenants/{tenant_id}/OS-KSCATALOG/endpoints",
controller=endpoint_templates_controller,
action="add_endpoint_to_tenant",
conditions=dict(method=["POST"]))
mapper.connect(
"/tenants/{tenant_id}/OS-KSCATALOG/endpoints/{endpoint_id}",
controller=endpoint_templates_controller,
action="remove_endpoint_from_tenant",
conditions=dict(method=["DELETE"]))

View File

@ -20,7 +20,6 @@ import routes
from keystone.common import wsgi
import keystone.backends as db
from keystone.controllers.auth import AuthController
from keystone.controllers.endpointtemplates import EndpointTemplatesController
from keystone.controllers.roles import RolesController
from keystone.controllers.staticfiles import StaticFilesController
from keystone.controllers.tenant import TenantController
@ -78,43 +77,6 @@ class AdminApi(wsgi.Router):
mapper.connect("/users/{user_id}/roles",
controller=roles_controller, action="get_user_roles",
conditions=dict(method=["GET"]))
#EndpointTemplatesControllers and Endpoints
endpoint_templates_controller = EndpointTemplatesController(options)
mapper.connect("/endpointTemplates",
controller=endpoint_templates_controller,
action="get_endpoint_templates",
conditions=dict(method=["GET"]))
mapper.connect("/endpointTemplates",
controller=endpoint_templates_controller,
action="add_endpoint_template",
conditions=dict(method=["POST"]))
mapper.connect("/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="get_endpoint_template",
conditions=dict(method=["GET"]))
mapper.connect("/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="modify_endpoint_template",
conditions=dict(method=["PUT"]))
mapper.connect("/endpointTemplates/{endpoint_template_id}",
controller=endpoint_templates_controller,
action="delete_endpoint_template",
conditions=dict(method=["DELETE"]))
mapper.connect("/tenants/{tenant_id}/endpoints",
controller=endpoint_templates_controller,
action="get_endpoints_for_tenant",
conditions=dict(method=["GET"]))
mapper.connect("/tenants/{tenant_id}/endpoints",
controller=endpoint_templates_controller,
action="add_endpoint_to_tenant",
conditions=dict(method=["POST"]))
mapper.connect(
"/tenants/{tenant_id}/endpoints/{endpoint_id}",
controller=endpoint_templates_controller,
action="remove_endpoint_from_tenant",
conditions=dict(method=["DELETE"]))
# Miscellaneous Operations
version_controller = VersionController(options)
mapper.connect("/", controller=version_controller,

View File

@ -328,48 +328,56 @@ class ApiTestCase(RestfulTestCase):
path='/OS-KSADM/roles/%s' % (role_id,), **kwargs)
def get_endpoint_templates(self, **kwargs):
"""GET /endpointTemplates"""
return self.admin_request(method='GET', path='/endpointTemplates',
"""GET /OS-KSCATALOG/endpointTemplates"""
return self.admin_request(method='GET',
path='/OS-KSCATALOG/endpointTemplates',
**kwargs)
def post_endpoint_template(self, **kwargs):
"""POST /endpointTemplates"""
return self.admin_request(method='POST', path='/endpointTemplates',
"""POST /OS-KSCATALOG/endpointTemplates"""
return self.admin_request(method='POST',
path='/OS-KSCATALOG/endpointTemplates',
**kwargs)
def put_endpoint_template(self, endpoint_template_id, **kwargs):
"""PUT /endpointTemplates/{endpoint_template_id}"""
"""PUT /OS-KSCATALOG/endpointTemplates/{endpoint_template_id}"""
return self.admin_request(method='PUT',
path='/endpointTemplates/%s' % (endpoint_template_id,),
path='/OS-KSCATALOG/endpointTemplates/%s'
% (endpoint_template_id,),
**kwargs)
def get_endpoint_template(self, endpoint_template_id, **kwargs):
"""GET /endpointTemplates/{endpoint_template_id}"""
"""GET /OS-KSCATALOG/endpointTemplates/{endpoint_template_id}"""
return self.admin_request(method='GET',
path='/endpointTemplates/%s' % (endpoint_template_id,),
path='/OS-KSCATALOG/endpointTemplates/%s'
% (endpoint_template_id,),
**kwargs)
def delete_endpoint_template(self, endpoint_template_id, **kwargs):
"""DELETE /endpointTemplates/{endpoint_template_id}"""
"""DELETE /OS-KSCATALOG/endpointTemplates/{endpoint_template_id}"""
return self.admin_request(method='DELETE',
path='/endpointTemplates/%s' % (endpoint_template_id,),
path='/OS-KSCATALOG/endpointTemplates/%s' %
(endpoint_template_id,),
**kwargs)
def get_tenant_endpoints(self, tenant_id, **kwargs):
"""GET /tenants/{tenant_id}/endpoints"""
"""GET /tenants/{tenant_id}/OS-KSCATALOG/endpoints"""
return self.admin_request(method='GET',
path='/tenants/%s/endpoints' % (tenant_id,),
path='/tenants/%s/OS-KSCATALOG/endpoints' %
(tenant_id,),
**kwargs)
def post_tenant_endpoint(self, tenant_id, **kwargs):
"""POST /tenants/{tenant_id}/endpoints"""
"""POST /tenants/{tenant_id}/OS-KSCATALOG/endpoints"""
return self.admin_request(method='POST',
path='/tenants/%s/endpoints' % (tenant_id,), **kwargs)
path='/tenants/%s/OS-KSCATALOG/endpoints' %
(tenant_id,), **kwargs)
def delete_tenant_endpoint(self, tenant_id, endpoint_id, **kwargs):
"""DELETE /tenants/{tenant_id}/endpoints/{endpoint_id}"""
"""DELETE /tenants/{tenant_id}/OS-KSCATALOG/endpoints/{endpoint_id}"""
return self.admin_request(method='DELETE',
path='/tenants/%s/endpoints/%s' % (tenant_id, endpoint_id,),
path='/tenants/%s/OS-KSCATALOG/endpoints/%s' %
(tenant_id, endpoint_id,),
**kwargs)
def post_service(self, **kwargs):