summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-01-23 10:19:55 -0500
committerMartin Kosek <mkosek@redhat.com>2013-03-01 16:59:45 +0100
commitfdd416912427e02dfa5709788fa7db06d216226d (patch)
tree594f62a03976b2dfd793b2c565cfa413b115a21e /ipaserver
parentfc571da1af5271caf76e08c359d85e386d67f2a4 (diff)
downloadfreeipa-fdd416912427e02dfa5709788fa7db06d216226d.tar.gz
freeipa-fdd416912427e02dfa5709788fa7db06d216226d.tar.xz
freeipa-fdd416912427e02dfa5709788fa7db06d216226d.zip
Inline waitForEntry in its only caller
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/replication.py41
-rw-r--r--ipaserver/ipaldap.py42
2 files changed, 40 insertions, 43 deletions
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index 538cf92cf..7d3f68b21 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -132,6 +132,45 @@ def wait_for_task(conn, dn):
return exit_code
+def wait_for_entry(connection, entry, timeout=7200, attr='', quiet=True):
+ """Wait for entry and/or attr to show up"""
+
+ filter = "(objectclass=*)"
+ attrlist = []
+ if attr:
+ filter = "(%s=*)" % attr
+ attrlist.append(attr)
+ timeout += int(time.time())
+
+ dn = entry.dn
+
+ if not quiet:
+ sys.stdout.write("Waiting for %s %s:%s " % (connection, dn, attr))
+ sys.stdout.flush()
+ entry = None
+ while not entry and int(time.time()) < timeout:
+ try:
+ [entry] = connection.get_entries(
+ dn, ldap.SCOPE_BASE, filter, attrlist)
+ except errors.NotFound:
+ pass # no entry yet
+ except Exception, e: # badness
+ print "\nError reading entry", dn, e
+ break
+ if not entry:
+ if not quiet:
+ sys.stdout.write(".")
+ sys.stdout.flush()
+ time.sleep(1)
+
+ if not entry and int(time.time()) > timeout:
+ print "\nwait_for_entry timeout for %s for %s" % (connection, dn)
+ elif entry and not quiet:
+ print "\nThe waited for entry is:", entry
+ elif not entry:
+ print "\nError: could not read entry %s from %s" % (dn, connection)
+
+
class ReplicationManager(object):
"""Manage replication agreements between DS servers, and sync
agreements with Windows servers"""
@@ -606,7 +645,7 @@ class ReplicationManager(object):
entry['nsds5ReplicaStripAttrs'] = [" ".join(STRIP_ATTRS)]
- entry = a_conn.waitForEntry(entry)
+ wait_for_entry(a_conn, entry)
def needs_memberof_fixup(self):
return self.need_memberof_fixup
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 72fc4afee..3c272d838 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -19,7 +19,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import sys
import string
import time
import shutil
@@ -1697,47 +1696,6 @@ class IPAdmin(LDAPClient):
return modlist
- def waitForEntry(self, dn, timeout=7200, attr='', quiet=True):
- filter = "(objectclass=*)"
- attrlist = []
- if attr:
- filter = "(%s=*)" % attr
- attrlist.append(attr)
- timeout += int(time.time())
-
- if isinstance(dn, LDAPEntry):
- dn = dn.dn
- assert isinstance(dn, DN)
-
- # wait for entry and/or attr to show up
- if not quiet:
- sys.stdout.write("Waiting for %s %s:%s " % (self,dn,attr))
- sys.stdout.flush()
- entry = None
- while not entry and int(time.time()) < timeout:
- try:
- [entry] = self.get_entries(
- dn, ldap.SCOPE_BASE, filter, attrlist)
- except errors.NotFound:
- pass # no entry yet
- except Exception, e: # badness
- print "\nError reading entry", dn, e
- break
- if not entry:
- if not quiet:
- sys.stdout.write(".")
- sys.stdout.flush()
- time.sleep(1)
-
- if not entry and int(time.time()) > timeout:
- print "\nwaitForEntry timeout for %s for %s" % (self,dn)
- elif entry and not quiet:
- print "\nThe waited for entry is:", entry
- elif not entry:
- print "\nError: could not read entry %s from %s" % (dn,self)
-
- return entry
-
def __getattr__(self, attrname):
# This makes IPAdmin classes look like IPASimpleLDAPObjects
# FIXME: for backwards compatibility only