#1188 Wait for 389-ds tasks to finish before proceeding
Closed: Fixed None Opened 12 years ago by rcritten.

In the installer and updater we create tasks for memberof, indexes, etc. According to the 389-ds team we should wait for those to complete before proceeding, esp when we may be restarting the server soon.


Entry is an IPAEntry -

def checkTask(self,entry,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
    dn = entry.dn
    while not done:
        entry = self.getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
        if verbose:
            print entry
        if entry.nsTaskExitCode:
            exitCode = int(entry.nsTaskExitCode)
            done = True
        if dowait: time.sleep(1)
        else: break
    return (done, exitCode)

boy that was ugly - preformatted

    def checkTask(self,entry,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
        dn = entry.dn
        while not done:
            entry = self.getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
            if verbose:
                print entry
            if entry.nsTaskExitCode:
                exitCode = int(entry.nsTaskExitCode)
                done = True
            if dowait: time.sleep(1)
            else: break
        return (done, exitCode)

Metadata Update from @rcritten:
- Issue assigned to rcritten
- Issue set to the milestone: FreeIPA 2.2 Core Effort - 2012/01

7 years ago

Login to comment on this ticket.

Metadata