summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/ldapupdate.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-01-10 09:50:22 -0500
committerMartin Kosek <mkosek@redhat.com>2013-03-01 16:59:42 +0100
commit7e1495b404f6d7dd2a8c779736e62f28fc2311ea (patch)
tree54cde6c38e53e7dde1be3eeb56f2688664e5d928 /ipaserver/install/ldapupdate.py
parent83f99070d6a25785e872bbfa8026333fc3110624 (diff)
downloadfreeipa-7e1495b404f6d7dd2a8c779736e62f28fc2311ea.tar.gz
freeipa-7e1495b404f6d7dd2a8c779736e62f28fc2311ea.tar.xz
freeipa-7e1495b404f6d7dd2a8c779736e62f28fc2311ea.zip
Derive Entity class from Entry, and move it to ldapupdate
The two classes were nearly identical, and the updater is the only code that uses Entity. Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'ipaserver/install/ldapupdate.py')
-rw-r--r--ipaserver/install/ldapupdate.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index f08ee8b9e..0d2606404 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -33,6 +33,7 @@ import pwd
import fnmatch
import csv
import inspect
+import copy
import krbV
import ldap
@@ -40,13 +41,37 @@ from ldap.schema.models import ObjectClass, AttributeType
from ipaserver.install import installutils
from ipaserver import ipaldap
-from ipapython import entity, ipautil
+from ipapython import ipautil
from ipalib import errors
from ipalib import api
from ipapython.dn import DN
from ipapython.ipa_log_manager import *
from ipaserver.install.plugins import PRE_UPDATE, POST_UPDATE
+
+class Entity(ipaldap.Entry):
+ # TODO: Use ldap2 instead
+ def __init__(self, entrydata=None):
+ ipaldap.Entry.__init__(self, entrydata)
+ y = {}
+ for key, value in self.data.iteritems():
+ y[copy.deepcopy(key)] = copy.deepcopy(value)
+ self.orig_data = ipautil.CIDict(y)
+
+ def attrList(self):
+ """Return a list of all attributes in the entry"""
+ return self.data.keys()
+
+ def origDataDict(self):
+ """Returns a dict of the original values of the user.
+
+ Used for updates.
+ """
+ result = ipautil.CIDict(self.orig_data)
+ result['dn'] = self.dn
+ return result
+
+
class BadSyntax(installutils.ScriptError):
def __init__(self, value):
self.value = value
@@ -255,7 +280,7 @@ class LDAPUpdate:
entry[key] = ''
elif len(value) == 1:
entry[key] = value[0]
- return entity.Entity(entry)
+ return Entity(entry)
def _combine_updates(self, all_updates, update):
'Combine a new update with the list of total updates'
@@ -483,7 +508,7 @@ class LDAPUpdate:
def _create_default_entry(self, dn, default):
"""Create the default entry from the values provided.
- The return type is entity.Entity
+ The return type is Entity
"""
assert isinstance(dn, DN)
entry = ipaldap.Entry(dn)