summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/ldapupdate.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver/install/ldapupdate.py')
-rw-r--r--ipaserver/install/ldapupdate.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 79aea178..8f3e8924 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -33,6 +33,7 @@ import pwd
import fnmatch
import csv
import inspect
+import re
import krbV
import ldap
@@ -900,21 +901,46 @@ class LDAPUpdate:
for dn, update in sorted_updates:
self._delete_record(update)
- def update(self, files):
+ def update(self, files, ordered=False):
"""Execute the update. files is a list of the update files to use.
+ If ordered is True then the updates the file must be of the form
+ ##-name.update where ## is an integer between 10 and 89. The
+ changes are applied to LDAP at the end of each value divisible
+ by 10, so after 20, 30, etc.
+
returns True if anything was changed, otherwise False
"""
+ pat = re.compile(r'(\d+)-.*\.update')
all_updates = {}
+ r = 20
if self.plugins:
self.info('PRE_UPDATE')
updates = api.Backend.updateclient.update(PRE_UPDATE, self.dm_password, self.ldapi, self.live_run)
self.merge_updates(all_updates, updates)
try:
self.create_connection()
+ if ordered and all_updates:
+ # flush out PRE_UPDATE plugin updates before we begin
+ self._run_updates(all_updates)
+ all_updates = {}
for f in files:
+ name = os.path.basename(f)
+ if ordered:
+ m = pat.match(name)
+ if not m:
+ raise RuntimeError("Filename does not match format #-name.update: %s" % f)
+ index = int(m.group(1))
+ if index < 10 or index > 90:
+ raise RuntimeError("Index not legal range: %d" % index)
+
+ if index >= r:
+ self._run_updates(all_updates)
+ all_updates = {}
+ r += 10
+
try:
self.info("Parsing update file '%s'" % f)
data = self.read_file(f)