From 5271eb217c4227a83ac99f9c8daa7e853871523a Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 21 Jan 2013 07:23:20 -0500 Subject: Replace IPAdmin.checkTask by replication.wait_for_task The method was only used for waiting, not actual checking. Part of the work for: https://fedorahosted.org/freeipa/ticket/2660 --- ipaserver/install/replication.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'ipaserver/install/replication.py') diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py index d604cf7b..eaf4c495 100644 --- a/ipaserver/install/replication.py +++ b/ipaserver/install/replication.py @@ -110,6 +110,27 @@ def enable_replication_version_checking(hostname, realm, dirman_passwd): else: conn.unbind() + +def wait_for_task(conn, dn): + """Check task status + + Task is complete when the nsTaskExitCode attr is set. + + :return: the task's return code + """ + assert isinstance(dn, DN) + attrlist = [ + 'nsTaskLog', 'nsTaskStatus', 'nsTaskExitCode', 'nsTaskCurrentItem', + 'nsTaskTotalItems'] + while True: + entry = conn.get_entry(dn, attrlist) + if entry.getValue('nsTaskExitCode'): + exit_code = int(entry.getValue('nsTaskExitCode')) + break + time.sleep(1) + return exit_code + + class ReplicationManager(object): """Manage replication agreements between DS servers, and sync agreements with Windows servers""" @@ -1206,7 +1227,7 @@ class ReplicationManager(object): print "This may be safely interrupted with Ctrl+C" - self.conn.checkTask(dn, dowait=True) + wait_for_task(self.conn, dn) def abortcleanallruv(self, replicaId): """ @@ -1233,4 +1254,4 @@ class ReplicationManager(object): print "This may be safely interrupted with Ctrl+C" - self.conn.checkTask(dn, dowait=True) + wait_for_task(self.conn, dn) -- cgit