summaryrefslogtreecommitdiffstats
path: root/keystone/policy
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-09-05 10:15:44 -0500
committerDolph Mathews <dolph.mathews@gmail.com>2012-09-05 13:07:49 -0500
commit399cb4cc71c5d48f58a668e0233396de97e65f89 (patch)
treef4ad905af78ac96f9471eac18c0b9d04f48150d5 /keystone/policy
parent84da6be591d0cf4702c0728a0fd1e430526c7530 (diff)
downloadkeystone-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/policy')
-rw-r--r--keystone/policy/core.py100
1 files changed, 100 insertions, 0 deletions
diff --git a/keystone/policy/core.py b/keystone/policy/core.py
index 5b60443b..498e027b 100644
--- a/keystone/policy/core.py
+++ b/keystone/policy/core.py
@@ -16,7 +16,9 @@
"""Main entry point into the Policy service."""
+
from keystone.common import manager
+from keystone.common import controller
from keystone import config
from keystone import exception
@@ -35,6 +37,26 @@ class Manager(manager.Manager):
def __init__(self):
super(Manager, self).__init__(CONF.policy.driver)
+ def get_policy(self, context, policy_id):
+ try:
+ return self.driver.get_policy(policy_id)
+ except exception.NotFound:
+ raise exception.PolicyNotFound(policy_id=policy_id)
+
+ def update_policy(self, context, policy_id, policy):
+ if 'id' in policy and policy_id != policy['id']:
+ raise exception.ValidationError('Cannot change policy ID')
+ try:
+ return self.driver.update_policy(policy_id, policy)
+ except exception.NotFound:
+ raise exception.PolicyNotFound(policy_id=policy_id)
+
+ def delete_policy(self, context, policy_id):
+ try:
+ return self.driver.delete_policy(policy_id)
+ except exception.NotFound:
+ raise exception.PolicyNotFound(policy_id=policy_id)
+
class Driver(object):
def enforce(context, credentials, action, target):
@@ -44,3 +66,81 @@ class Driver(object):
`keystone.common.policy.enforce`.
"""
raise exception.NotImplemented()
+
+ def create_policy(self, policy_id, policy):
+ """Store a policy blob for a particular endpoint.
+
+ :raises: keystone.exception.EndpointNotFound,
+ keystone.exception.Conflict
+
+ """
+ raise exception.NotImplemented()
+
+ def list_policies(self):
+ """List all policies."""
+ raise exception.NotImplemented()
+
+ def get_policy(self, policy_id):
+ """Retrieve a specific policy blob.
+
+ :raises: keystone.exception.PolicyNotFound
+
+ """
+ raise exception.NotImplemented()
+
+ def update_policy(self, policy_id, policy):
+ """Update a policy blob.
+
+ :raises: keystone.exception.PolicyNotFound,
+ keystone.exception.EndpointNotFound
+
+ """
+ raise exception.NotImplemented()
+
+ def delete_policy(self, policy_id):
+ """Remove a policy blob.
+
+ :raises: keystone.exception.PolicyNotFound
+
+ """
+ raise exception.NotImplemented()
+
+
+class PolicyControllerV3(controller.V3Controller):
+ def create_policy(self, context, policy):
+ self.assert_admin(context)
+
+ ref = self._assign_unique_id(self._normalize_dict(policy))
+ self._require_attribute(ref, 'blob')
+ self._require_attribute(ref, 'type')
+ self._require_attribute(ref, 'endpoint_id')
+
+ self.catalog_api.get_endpoint(context, ref['endpoint_id'])
+
+ ref = self.policy_api.create_policy(context, ref['id'], ref)
+ return {'policy': ref}
+
+ def list_policies(self, context):
+ self.assert_admin(context)
+ refs = self.policy_api.list_policies(context)
+ refs = self._filter_by_attribute(context, refs, 'endpoint_id')
+ refs = self._filter_by_attribute(context, refs, 'type')
+ return {'policies': self._paginate(context, refs)}
+
+ def get_policy(self, context, policy_id):
+ self.assert_admin(context)
+ ref = self.policy_api.get_policy(context, policy_id)
+ return {'policy': ref}
+
+ def update_policy(self, context, policy_id, policy):
+ self.assert_admin(context)
+
+ if 'endpoint_id' in policy:
+ self.catalog_api.get_endpoint(context, policy['endpoint_id'])
+
+ ref = self.policy_api.update_policy(context, policy_id, policy)
+ return {'policy': ref}
+
+ def delete_policy(self, context, policy_id):
+ self.assert_admin(context)
+ return self.policy_api.delete_policy(context, policy_id)