summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElena Ezhova <eezhova@mirantis.com>2013-04-19 18:11:37 +0400
committerElena Ezhova <eezhova@mirantis.com>2013-08-06 12:54:09 +0400
commit6f954d2c2982a6096c13053dafd96ebddc6017bb (patch)
tree684aba5dabfceb5d14ff5ec41bc30c2a4a4ad43b
parent1289bbf12e8cf6e7792df0de44a3bc9bf6e9c505 (diff)
downloadkeystone-6f954d2c2982a6096c13053dafd96ebddc6017bb.tar.gz
keystone-6f954d2c2982a6096c13053dafd96ebddc6017bb.tar.xz
keystone-6f954d2c2982a6096c13053dafd96ebddc6017bb.zip
Abstract out attribute_ignore assigning in LDAP driver
This is used to avoid code duplication in keystone/identity/ backends/ldap.py. All changes are fully covered by test_*option_ name*_attribute_ignore() in test_backend_ldap.py. bp refactor-ldap-driver Change-Id: Ia0fc0b3d4a92416dcd65ddb49b3b0bf9a0777363
-rw-r--r--keystone/assignment/backends/ldap.py6
-rw-r--r--keystone/common/ldap/core.py4
-rw-r--r--keystone/identity/backends/ldap.py6
3 files changed, 4 insertions, 12 deletions
diff --git a/keystone/assignment/backends/ldap.py b/keystone/assignment/backends/ldap.py
index 34cd9c2f..718d38c3 100644
--- a/keystone/assignment/backends/ldap.py
+++ b/keystone/assignment/backends/ldap.py
@@ -263,7 +263,6 @@ class ProjectApi(common_ldap.EnabledEmuMixIn, common_ldap.BaseLdap):
DEFAULT_OBJECTCLASS = 'groupOfNames'
DEFAULT_ID_ATTR = 'cn'
DEFAULT_MEMBER_ATTRIBUTE = 'member'
- DEFAULT_ATTRIBUTE_IGNORE = []
NotFound = exception.ProjectNotFound
notfound_arg = 'project_id' # NOTE(yorik-sar): while options_name = tenant
options_name = 'tenant'
@@ -277,8 +276,6 @@ class ProjectApi(common_ldap.EnabledEmuMixIn, common_ldap.BaseLdap):
super(ProjectApi, self).__init__(conf)
self.member_attribute = (getattr(conf.ldap, 'tenant_member_attribute')
or self.DEFAULT_MEMBER_ATTRIBUTE)
- self.attribute_ignore = (getattr(conf.ldap, 'tenant_attribute_ignore')
- or self.DEFAULT_ATTRIBUTE_IGNORE)
def create(self, values):
self.affirm_unique(values)
@@ -375,7 +372,6 @@ class RoleApi(common_ldap.BaseLdap):
DEFAULT_STRUCTURAL_CLASSES = []
DEFAULT_OBJECTCLASS = 'organizationalRole'
DEFAULT_MEMBER_ATTRIBUTE = 'roleOccupant'
- DEFAULT_ATTRIBUTE_IGNORE = []
NotFound = exception.RoleNotFound
options_name = 'role'
attribute_options_names = {'name': 'name'}
@@ -385,8 +381,6 @@ class RoleApi(common_ldap.BaseLdap):
super(RoleApi, self).__init__(conf)
self.member_attribute = (getattr(conf.ldap, 'role_member_attribute')
or self.DEFAULT_MEMBER_ATTRIBUTE)
- self.attribute_ignore = (getattr(conf.ldap, 'role_attribute_ignore')
- or self.DEFAULT_ATTRIBUTE_IGNORE)
def get(self, id, filter=None):
model = super(RoleApi, self).get(id, filter)
diff --git a/keystone/common/ldap/core.py b/keystone/common/ldap/core.py
index 71423064..39ea78de 100644
--- a/keystone/common/ldap/core.py
+++ b/keystone/common/ldap/core.py
@@ -172,6 +172,10 @@ class BaseLdap(object):
if self.notfound_arg is None:
self.notfound_arg = self.options_name + '_id'
+
+ attribute_ignore = '%s_attribute_ignore' % self.options_name
+ self.attribute_ignore = getattr(conf.ldap, attribute_ignore)
+
self.use_dumb_member = getattr(conf.ldap, 'use_dumb_member')
self.dumb_member = (getattr(conf.ldap, 'dumb_member') or
self.DUMB_MEMBER_DN)
diff --git a/keystone/identity/backends/ldap.py b/keystone/identity/backends/ldap.py
index 5aa4edee..a359c63f 100644
--- a/keystone/identity/backends/ldap.py
+++ b/keystone/identity/backends/ldap.py
@@ -210,7 +210,6 @@ class UserApi(common_ldap.EnabledEmuMixIn, common_ldap.BaseLdap):
DEFAULT_STRUCTURAL_CLASSES = ['person']
DEFAULT_ID_ATTR = 'cn'
DEFAULT_OBJECTCLASS = 'inetOrgPerson'
- DEFAULT_ATTRIBUTE_IGNORE = ['tenant_id', 'tenants']
NotFound = exception.UserNotFound
options_name = 'user'
attribute_options_names = {'password': 'pass',
@@ -225,8 +224,6 @@ class UserApi(common_ldap.EnabledEmuMixIn, common_ldap.BaseLdap):
super(UserApi, self).__init__(conf)
self.enabled_mask = conf.ldap.user_enabled_mask
self.enabled_default = conf.ldap.user_enabled_default
- self.attribute_ignore = (getattr(conf.ldap, 'user_attribute_ignore')
- or self.DEFAULT_ATTRIBUTE_IGNORE)
def _ldap_res_to_model(self, res):
obj = super(UserApi, self)._ldap_res_to_model(res)
@@ -271,7 +268,6 @@ class GroupApi(common_ldap.BaseLdap):
DEFAULT_OBJECTCLASS = 'groupOfNames'
DEFAULT_ID_ATTR = 'cn'
DEFAULT_MEMBER_ATTRIBUTE = 'member'
- DEFAULT_ATTRIBUTE_IGNORE = []
NotFound = exception.GroupNotFound
options_name = 'group'
attribute_options_names = {'description': 'desc',
@@ -283,8 +279,6 @@ class GroupApi(common_ldap.BaseLdap):
super(GroupApi, self).__init__(conf)
self.member_attribute = (getattr(conf.ldap, 'group_member_attribute')
or self.DEFAULT_MEMBER_ATTRIBUTE)
- self.attribute_ignore = (getattr(conf.ldap, 'group_attribute_ignore')
- or self.DEFAULT_ATTRIBUTE_IGNORE)
def create(self, values):
self.affirm_unique(values)