summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/ldapupdate.py35
1 files changed, 16 insertions, 19 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index f7261adc..48544108 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -893,26 +893,23 @@ class LDAPUpdate:
def _run_updates(self, all_updates):
# For adds and updates we want to apply updates from shortest
- # to greatest length of the DN. For deletes we want the reverse.
-
- dn_by_rdn_count = {}
- for dn in all_updates.keys():
+ # to greatest length of the DN. cn=schema must always go first to add
+ # new objectClasses and attributeTypes
+ # For deletes we want the reverse
+ def update_sort_key(dn_update):
+ dn, update = dn_update
assert isinstance(dn, DN)
- rdn_count = len(dn)
- rdn_count_list = dn_by_rdn_count.setdefault(rdn_count, [])
- if dn not in rdn_count_list:
- rdn_count_list.append(dn)
-
- sortedkeys = dn_by_rdn_count.keys()
- sortedkeys.sort()
- for rdn_count in sortedkeys:
- for dn in dn_by_rdn_count[rdn_count]:
- self._update_record(all_updates[dn])
-
- sortedkeys.reverse()
- for rdn_count in sortedkeys:
- for dn in dn_by_rdn_count[rdn_count]:
- self._delete_record(all_updates[dn])
+ return dn != DN(('cn', 'schema')), len(dn)
+
+ sorted_updates = sorted(all_updates.iteritems(), key=update_sort_key)
+
+ for dn, update in sorted_updates:
+ self._update_record(update)
+
+ # Now run the deletes in reversed order
+ sorted_updates.reverse()
+ for dn, update in sorted_updates:
+ self._delete_record(update)
def update(self, files):
"""Execute the update. files is a list of the update files to use.