diff options
author | Dolph Mathews <dolph.mathews@gmail.com> | 2012-09-05 10:15:44 -0500 |
---|---|---|
committer | Dolph Mathews <dolph.mathews@gmail.com> | 2012-09-05 13:07:49 -0500 |
commit | 399cb4cc71c5d48f58a668e0233396de97e65f89 (patch) | |
tree | f4ad905af78ac96f9471eac18c0b9d04f48150d5 /keystone/catalog | |
parent | 84da6be591d0cf4702c0728a0fd1e430526c7530 (diff) | |
download | keystone-399cb4cc71c5d48f58a668e0233396de97e65f89.tar.gz keystone-399cb4cc71c5d48f58a668e0233396de97e65f89.tar.xz keystone-399cb4cc71c5d48f58a668e0233396de97e65f89.zip |
Identity API v3 Config, Routers, Controllers
Provides configuration to deploy the v3 API identically across both:
http://[...]:5000/v3/
http://[...]:35357/v3/
Change-Id: I97c5a2f7a84e3fca0adaea020697f958e04f5753
Diffstat (limited to 'keystone/catalog')
-rw-r--r-- | keystone/catalog/core.py | 137 |
1 files changed, 126 insertions, 11 deletions
diff --git a/keystone/catalog/core.py b/keystone/catalog/core.py index b2b6c24e..686f5f7c 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 manager from keystone.common import wsgi from keystone import config @@ -82,6 +83,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. @@ -90,6 +99,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. @@ -99,18 +116,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() @@ -124,27 +142,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() @@ -237,3 +273,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) |