summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/ldapupdate.py
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-03-05 16:56:02 +0100
committerTomas Babej <tbabej@redhat.com>2015-03-19 12:37:09 +0100
commit10bc6bd0bf96bda733500e12e7a8c2463ebf7fe4 (patch)
tree7b61fec9a0f93ca921690d3f47969fa1f682b90a /ipaserver/install/ldapupdate.py
parentbb1d7a741c3e8c932e13e642adb1799957becb0c (diff)
downloadfreeipa-10bc6bd0bf96bda733500e12e7a8c2463ebf7fe4.tar.gz
freeipa-10bc6bd0bf96bda733500e12e7a8c2463ebf7fe4.tar.xz
freeipa-10bc6bd0bf96bda733500e12e7a8c2463ebf7fe4.zip
Server Upgrade: Upgrade one file per time
* Files are sorted alphabetically, no numbering required anymore * One file updated per time Ticket: https://fedorahosted.org/freeipa/ticket/3560 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipaserver/install/ldapupdate.py')
-rw-r--r--ipaserver/install/ldapupdate.py54
1 files changed, 18 insertions, 36 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index e8516ff86..3b4aa58d9 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -793,44 +793,27 @@ class LDAPUpdate:
def update(self, files, ordered=False):
"""Execute the update. files is a list of the update files to use.
+ :param ordered: Update files are executed in alphabetical order
- 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
+ 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:
+ 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)
# 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
+ upgrade_files = files
+ if ordered:
+ upgrade_files = sorted(files)
+ for f in upgrade_files:
try:
self.info("Parsing update file '%s'" % f)
data = self.read_file(f)
@@ -839,17 +822,16 @@ class LDAPUpdate:
sys.exit(e)
self.parse_update_file(f, data, all_updates)
+ self._run_updates(all_updates)
+ all_updates = {}
- self._run_updates(all_updates)
+ if self.plugins:
+ self.info('POST_UPDATE')
+ updates = api.Backend.updateclient.update(POST_UPDATE, self.dm_password, self.ldapi, self.live_run)
+ self.merge_updates(all_updates, updates)
+ self._run_updates(all_updates)
finally:
- if self.conn: self.conn.unbind()
-
- if self.plugins:
- self.info('POST_UPDATE')
- all_updates = {}
- updates = api.Backend.updateclient.update(POST_UPDATE, self.dm_password, self.ldapi, self.live_run)
- self.merge_updates(all_updates, updates)
- self._run_updates(all_updates)
+ self.close_connection()
return self.modified