summaryrefslogtreecommitdiffstats
path: root/keystone/catalog
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-12-05 09:58:54 -0600
committerDolph Mathews <dolph.mathews@gmail.com>2012-12-05 10:32:47 -0600
commitc858c1b304cae6310f08a220cf54c763f684fc42 (patch)
tree0b5dcfbed4c30bc7f40a3e9899af244c27a27a4c /keystone/catalog
parent75277cf1ae496145369e929702005ef2304e6942 (diff)
downloadkeystone-c858c1b304cae6310f08a220cf54c763f684fc42.tar.gz
keystone-c858c1b304cae6310f08a220cf54c763f684fc42.tar.xz
keystone-c858c1b304cae6310f08a220cf54c763f684fc42.zip
Only 'import *' from 'core' modules
- Renamed identity.controllers.* and identity.routers.* since they now occopy unique namespaces (thanks ayoung!) - Moved catalog and policy controllers into their own respective modules Change-Id: Ib9e277355e0eac15d4d218785c816b718b493b5b
Diffstat (limited to 'keystone/catalog')
-rw-r--r--keystone/catalog/__init__.py1
-rw-r--r--keystone/catalog/controllers.py154
-rw-r--r--keystone/catalog/core.py136
3 files changed, 155 insertions, 136 deletions
diff --git a/keystone/catalog/__init__.py b/keystone/catalog/__init__.py
index 47f60b38..c029a486 100644
--- a/keystone/catalog/__init__.py
+++ b/keystone/catalog/__init__.py
@@ -15,3 +15,4 @@
# under the License.
from keystone.catalog.core import *
+from keystone.catalog import controllers
diff --git a/keystone/catalog/controllers.py b/keystone/catalog/controllers.py
new file mode 100644
index 00000000..b58f3d07
--- /dev/null
+++ b/keystone/catalog/controllers.py
@@ -0,0 +1,154 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack LLC
+# Copyright 2012 Canonical Ltd.
+#
+# 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.
+
+import uuid
+
+from keystone.catalog import core
+from keystone.common import controller
+from keystone.common import wsgi
+from keystone import identity
+from keystone import policy
+from keystone import token
+
+
+class Service(wsgi.Application):
+ def __init__(self):
+ self.catalog_api = core.Manager()
+ self.identity_api = identity.Manager()
+ self.policy_api = policy.Manager()
+ self.token_api = token.Manager()
+ super(Service, self).__init__()
+
+ def get_services(self, context):
+ self.assert_admin(context)
+ service_list = self.catalog_api.list_services(context)
+ return {'OS-KSADM:services': service_list}
+
+ def get_service(self, context, service_id):
+ self.assert_admin(context)
+ service_ref = self.catalog_api.get_service(context, service_id)
+ return {'OS-KSADM:service': service_ref}
+
+ def delete_service(self, context, service_id):
+ self.assert_admin(context)
+ self.catalog_api.delete_service(context, service_id)
+
+ def create_service(self, context, OS_KSADM_service):
+ self.assert_admin(context)
+ service_id = uuid.uuid4().hex
+ service_ref = OS_KSADM_service.copy()
+ service_ref['id'] = service_id
+ new_service_ref = self.catalog_api.create_service(
+ context, service_id, service_ref)
+ return {'OS-KSADM:service': new_service_ref}
+
+
+class Endpoint(wsgi.Application):
+ def __init__(self):
+ self.catalog_api = core.Manager()
+ self.identity_api = identity.Manager()
+ self.policy_api = policy.Manager()
+ self.token_api = token.Manager()
+ super(Endpoint, self).__init__()
+
+ def get_endpoints(self, context):
+ self.assert_admin(context)
+ endpoint_list = self.catalog_api.list_endpoints(context)
+ return {'endpoints': endpoint_list}
+
+ def create_endpoint(self, context, endpoint):
+ self.assert_admin(context)
+ endpoint_id = uuid.uuid4().hex
+ endpoint_ref = endpoint.copy()
+ endpoint_ref['id'] = endpoint_id
+ new_endpoint_ref = self.catalog_api.create_endpoint(
+ context, endpoint_id, endpoint_ref)
+ return {'endpoint': new_endpoint_ref}
+
+ def delete_endpoint(self, context, endpoint_id):
+ self.assert_admin(context)
+ self.catalog_api.delete_endpoint(context, endpoint_id)
+
+
+class ServiceV3(controller.V3Controller):
+ @controller.protected
+ def create_service(self, context, service):
+ ref = self._assign_unique_id(self._normalize_dict(service))
+ self._require_attribute(ref, 'type')
+
+ ref = self.catalog_api.create_service(context, ref['id'], ref)
+ return {'service': ref}
+
+ @controller.protected
+ def list_services(self, context):
+ refs = self.catalog_api.list_services(context)
+ refs = self._filter_by_attribute(context, refs, 'type')
+ return {'services': self._paginate(context, refs)}
+
+ @controller.protected
+ def get_service(self, context, service_id):
+ ref = self.catalog_api.get_service(context, service_id)
+ return {'service': ref}
+
+ @controller.protected
+ def update_service(self, context, service_id, service):
+ self._require_matching_id(service_id, service)
+
+ ref = self.catalog_api.update_service(context, service_id, service)
+ return {'service': ref}
+
+ @controller.protected
+ def delete_service(self, context, service_id):
+ return self.catalog_api.delete_service(context, service_id)
+
+
+class EndpointV3(controller.V3Controller):
+ @controller.protected
+ def create_endpoint(self, context, endpoint):
+ ref = self._assign_unique_id(self._normalize_dict(endpoint))
+ self._require_attribute(ref, 'service_id')
+ self._require_attribute(ref, 'interface')
+ self.catalog_api.get_service(context, ref['service_id'])
+
+ ref = self.catalog_api.create_endpoint(context, ref['id'], ref)
+ return {'endpoint': ref}
+
+ @controller.protected
+ def list_endpoints(self, context):
+ refs = self.catalog_api.list_endpoints(context)
+ refs = self._filter_by_attribute(context, refs, 'service_id')
+ refs = self._filter_by_attribute(context, refs, 'interface')
+ return {'endpoints': self._paginate(context, refs)}
+
+ @controller.protected
+ def get_endpoint(self, context, endpoint_id):
+ ref = self.catalog_api.get_endpoint(context, endpoint_id)
+ return {'endpoint': ref}
+
+ @controller.protected
+ def update_endpoint(self, context, endpoint_id, endpoint):
+ self._require_matching_id(endpoint_id, endpoint)
+
+ if 'service_id' in endpoint:
+ self.catalog_api.get_service(context, endpoint['service_id'])
+
+ ref = self.catalog_api.update_endpoint(context, endpoint_id, endpoint)
+ return {'endpoint': ref}
+
+ @controller.protected
+ def delete_endpoint(self, context, endpoint_id):
+ return self.catalog_api.delete_endpoint(context, endpoint_id)
diff --git a/keystone/catalog/core.py b/keystone/catalog/core.py
index 79b3df2a..df100d74 100644
--- a/keystone/catalog/core.py
+++ b/keystone/catalog/core.py
@@ -17,17 +17,10 @@
"""Main entry point into the Catalog service."""
-import uuid
-
-from keystone.common import controller
from keystone.common import logging
from keystone.common import manager
-from keystone.common import wsgi
from keystone import config
from keystone import exception
-from keystone import identity
-from keystone import policy
-from keystone import token
CONF = config.CONF
@@ -216,132 +209,3 @@ class Driver(object):
"""
raise exception.NotImplemented()
-
-
-class ServiceController(wsgi.Application):
- def __init__(self):
- self.catalog_api = Manager()
- self.identity_api = identity.Manager()
- self.policy_api = policy.Manager()
- self.token_api = token.Manager()
- super(ServiceController, self).__init__()
-
- def get_services(self, context):
- self.assert_admin(context)
- service_list = self.catalog_api.list_services(context)
- return {'OS-KSADM:services': service_list}
-
- def get_service(self, context, service_id):
- self.assert_admin(context)
- service_ref = self.catalog_api.get_service(context, service_id)
- return {'OS-KSADM:service': service_ref}
-
- def delete_service(self, context, service_id):
- self.assert_admin(context)
- self.catalog_api.delete_service(context, service_id)
-
- def create_service(self, context, OS_KSADM_service):
- self.assert_admin(context)
- service_id = uuid.uuid4().hex
- service_ref = OS_KSADM_service.copy()
- service_ref['id'] = service_id
- new_service_ref = self.catalog_api.create_service(
- context, service_id, service_ref)
- return {'OS-KSADM:service': new_service_ref}
-
-
-class EndpointController(wsgi.Application):
- def __init__(self):
- self.catalog_api = Manager()
- self.identity_api = identity.Manager()
- self.policy_api = policy.Manager()
- self.token_api = token.Manager()
- super(EndpointController, self).__init__()
-
- def get_endpoints(self, context):
- self.assert_admin(context)
- endpoint_list = self.catalog_api.list_endpoints(context)
- return {'endpoints': endpoint_list}
-
- def create_endpoint(self, context, endpoint):
- self.assert_admin(context)
- endpoint_id = uuid.uuid4().hex
- endpoint_ref = endpoint.copy()
- endpoint_ref['id'] = endpoint_id
- new_endpoint_ref = self.catalog_api.create_endpoint(
- context, endpoint_id, endpoint_ref)
- return {'endpoint': new_endpoint_ref}
-
- def delete_endpoint(self, context, endpoint_id):
- self.assert_admin(context)
- self.catalog_api.delete_endpoint(context, endpoint_id)
-
-
-class ServiceControllerV3(controller.V3Controller):
- @controller.protected
- def create_service(self, context, service):
- ref = self._assign_unique_id(self._normalize_dict(service))
- self._require_attribute(ref, 'type')
-
- ref = self.catalog_api.create_service(context, ref['id'], ref)
- return {'service': ref}
-
- @controller.protected
- def list_services(self, context):
- refs = self.catalog_api.list_services(context)
- refs = self._filter_by_attribute(context, refs, 'type')
- return {'services': self._paginate(context, refs)}
-
- @controller.protected
- def get_service(self, context, service_id):
- ref = self.catalog_api.get_service(context, service_id)
- return {'service': ref}
-
- @controller.protected
- def update_service(self, context, service_id, service):
- self._require_matching_id(service_id, service)
-
- ref = self.catalog_api.update_service(context, service_id, service)
- return {'service': ref}
-
- @controller.protected
- def delete_service(self, context, service_id):
- return self.catalog_api.delete_service(context, service_id)
-
-
-class EndpointControllerV3(controller.V3Controller):
- @controller.protected
- def create_endpoint(self, context, endpoint):
- ref = self._assign_unique_id(self._normalize_dict(endpoint))
- self._require_attribute(ref, 'service_id')
- self._require_attribute(ref, 'interface')
- self.catalog_api.get_service(context, ref['service_id'])
-
- ref = self.catalog_api.create_endpoint(context, ref['id'], ref)
- return {'endpoint': ref}
-
- @controller.protected
- def list_endpoints(self, context):
- refs = self.catalog_api.list_endpoints(context)
- refs = self._filter_by_attribute(context, refs, 'service_id')
- refs = self._filter_by_attribute(context, refs, 'interface')
- return {'endpoints': self._paginate(context, refs)}
-
- @controller.protected
- def get_endpoint(self, context, endpoint_id):
- ref = self.catalog_api.get_endpoint(context, endpoint_id)
- return {'endpoint': ref}
-
- @controller.protected
- def update_endpoint(self, context, endpoint_id, endpoint):
- self._require_matching_id(endpoint_id, endpoint)
-
- if 'service_id' in endpoint:
- self.catalog_api.get_service(context, endpoint['service_id'])
-
- ref = self.catalog_api.update_endpoint(context, endpoint_id, endpoint)
- return {'endpoint': ref}
-
- @controller.protected
- def delete_endpoint(self, context, endpoint_id):
- return self.catalog_api.delete_endpoint(context, endpoint_id)