summaryrefslogtreecommitdiffstats
path: root/keystone/catalog
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-07 01:55:51 +0000
committerGerrit Code Review <review@openstack.org>2012-11-07 01:55:51 +0000
commit126dd9c9bdab46074d812f4a16358357d364e789 (patch)
tree6c41496c882432164de59fbd86753dff10aae1bb /keystone/catalog
parent6b87660d91b30dcccf19c77cf999fa3f0dee84b2 (diff)
parent86aaff4a50039a927eac2ca0db927249058bef12 (diff)
downloadkeystone-126dd9c9bdab46074d812f4a16358357d364e789.tar.gz
keystone-126dd9c9bdab46074d812f4a16358357d364e789.tar.xz
keystone-126dd9c9bdab46074d812f4a16358357d364e789.zip
Merge "Merge remote-tracking branch 'origin/feature/keystone-v3' into HEAD"
Diffstat (limited to 'keystone/catalog')
-rw-r--r--keystone/catalog/core.py137
1 files changed, 126 insertions, 11 deletions
diff --git a/keystone/catalog/core.py b/keystone/catalog/core.py
index 430cc47e..e5b8fe66 100644
--- a/keystone/catalog/core.py
+++ b/keystone/catalog/core.py
@@ -19,6 +19,7 @@
import uuid
+from keystone.common import controller
from keystone.common import logging
from keystone.common import manager
from keystone.common import wsgi
@@ -106,6 +107,14 @@ class Manager(manager.Manager):
class Driver(object):
"""Interface description for an Catalog driver."""
+ def create_service(self, service_id, service_ref):
+ """Creates a new service.
+
+ :raises: keystone.exception.Conflict
+
+ """
+ raise exception.NotImplemented()
+
def list_services(self):
"""List all service ids in catalog.
@@ -114,6 +123,14 @@ class Driver(object):
"""
raise exception.NotImplemented()
+ def get_all_services(self):
+ """List all services.
+
+ :returns: list of service_refs or an empty list.
+
+ """
+ raise exception.NotImplemented()
+
def get_service(self, service_id):
"""Get service by id.
@@ -123,18 +140,19 @@ class Driver(object):
"""
raise exception.NotImplemented()
- def delete_service(self, service_id):
- """Deletes an existing service.
+ def update_service(self, service_id):
+ """Update service by id.
+ :returns: service_ref dict
:raises: keystone.exception.ServiceNotFound
"""
raise exception.NotImplemented()
- def create_service(self, service_id, service_ref):
- """Creates a new service.
+ def delete_service(self, service_id):
+ """Deletes an existing service.
- :raises: keystone.exception.Conflict
+ :raises: keystone.exception.ServiceNotFound
"""
raise exception.NotImplemented()
@@ -148,27 +166,45 @@ class Driver(object):
"""
raise exception.NotImplemented()
- def delete_endpoint(self, endpoint_id):
- """Deletes an endpoint for a service.
+ def get_endpoint(self, endpoint_id):
+ """Get endpoint by id.
+ :returns: endpoint_ref dict
:raises: keystone.exception.EndpointNotFound
"""
raise exception.NotImplemented()
- def get_endpoint(self, endpoint_id):
+ def list_endpoints(self):
+ """List all endpoint ids in catalog.
+
+ :returns: list of endpoint_ids or an empty list.
+
+ """
+ raise exception.NotImplemented()
+
+ def get_all_endpoints(self):
+ """List all endpoints.
+
+ :returns: list of endpoint_refs or an empty list.
+
+ """
+ raise exception.NotImplemented()
+
+ def update_endpoint(self, endpoint_id, endpoint_ref):
"""Get endpoint by id.
:returns: endpoint_ref dict
:raises: keystone.exception.EndpointNotFound
+ keystone.exception.ServiceNotFound
"""
raise exception.NotImplemented()
- def list_endpoints(self):
- """List all endpoint ids in catalog.
+ def delete_endpoint(self, endpoint_id):
+ """Deletes an endpoint for a service.
- :returns: list of endpoint_ids or an empty list.
+ :raises: keystone.exception.EndpointNotFound
"""
raise exception.NotImplemented()
@@ -261,3 +297,82 @@ class EndpointController(wsgi.Application):
def delete_endpoint(self, context, endpoint_id):
self.assert_admin(context)
self.catalog_api.delete_endpoint(context, endpoint_id)
+
+
+class ServiceControllerV3(controller.V3Controller):
+ def create_service(self, context, service):
+ self.assert_admin(context)
+
+ 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}
+
+ def list_services(self, context):
+ self.assert_admin(context)
+
+ refs = self.catalog_api.get_all_services(context)
+ refs = self._filter_by_attribute(context, refs, 'type')
+ return {'services': self._paginate(context, refs)}
+
+ def get_service(self, context, service_id):
+ self.assert_admin(context)
+
+ ref = self.catalog_api.get_service(context, service_id)
+ return {'service': ref}
+
+ def update_service(self, context, service_id, service):
+ self.assert_admin(context)
+
+ self._require_matching_id(service_id, service)
+
+ ref = self.catalog_api.update_service(context, service_id, service)
+ return {'service': ref}
+
+ def delete_service(self, context, service_id):
+ self.assert_admin(context)
+
+ return self.catalog_api.delete_service(context, service_id)
+
+
+class EndpointControllerV3(controller.V3Controller):
+ def create_endpoint(self, context, endpoint):
+ self.assert_admin(context)
+
+ 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}
+
+ def list_endpoints(self, context):
+ self.assert_admin(context)
+
+ refs = self.catalog_api.get_all_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)}
+
+ def get_endpoint(self, context, endpoint_id):
+ self.assert_admin(context)
+
+ ref = self.catalog_api.get_endpoint(context, endpoint_id)
+ return {'endpoint': ref}
+
+ def update_endpoint(self, context, endpoint_id, endpoint):
+ self.assert_admin(context)
+
+ 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}
+
+ def delete_endpoint(self, context, endpoint_id):
+ self.assert_admin(context)
+ return self.catalog_api.delete_endpoint(context, endpoint_id)