summaryrefslogtreecommitdiffstats
path: root/ipaserver/ipaldap.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-04-21 16:43:10 -0400
committerMartin Kosek <mkosek@redhat.com>2011-04-22 11:43:50 +0200
commit46a341142079d1722647d24d06155346fc1c8442 (patch)
tree66e716279075c0381016158c242ec0dbe589807d /ipaserver/ipaldap.py
parentd2be41dd1b69020b11cdd6ba66436424f3a0033a (diff)
downloadfreeipa-46a341142079d1722647d24d06155346fc1c8442.tar.gz
freeipa-46a341142079d1722647d24d06155346fc1c8442.tar.xz
freeipa-46a341142079d1722647d24d06155346fc1c8442.zip
Wait for memberof task and DS to start before proceeding in installation.
This was causing a replica DS instance to crash if the task was not completed when we attempted a shutdown to do a restart. In replication.py we were restarting the DS instance without waiting for the ports to become available. It is unlikely that the dn of the memberof task will change but just in case I noted it in the two places it is referenced. ticket 1188
Diffstat (limited to 'ipaserver/ipaldap.py')
-rw-r--r--ipaserver/ipaldap.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index b933839ab..7df7cceff 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -641,6 +641,29 @@ class IPAdmin(SimpleLDAPObject):
return entry
+ def checkTask(self, dn, dowait=False, verbose=False):
+ """check task status - task is complete when the nsTaskExitCode attr
+ is set return a 2 tuple (true/false,code) first is false if task is
+ running, true if done - if true, second is the exit code - if dowait
+ is True, this function will block until the task is complete
+ """
+ attrlist = ['nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', 'nsTaskCurrentItem', 'nsTaskTotalItems']
+ done = False
+ exitCode = 0
+ while not done:
+ try:
+ entry = self.getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
+ except errors.NotFound:
+ break
+ if verbose:
+ print entry
+ if entry.nsTaskExitCode:
+ exitCode = int(entry.nsTaskExitCode)
+ done = True
+ if dowait: time.sleep(1)
+ else: break
+ return (done, exitCode)
+
def normalizeDN(dn):
# not great, but will do until we use a newer version of python-ldap
# that has DN utilities