Wait for DS ports to open after _every_ DS service restart.
Several restarts were missed by the current open port checker
implementation.

https://fedorahosted.org/freeipa/ticket/1182

>From c76be0cf9cb5c1feb58c18e3d7a6bd72594947e4 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Wed, 27 Apr 2011 12:37:04 +0200
Subject: [PATCH] Improve Directory Service open port checker

Wait for DS ports to open after _every_ DS service restart.
Several restarts were missed by the current open port checker
implementation.

https://fedorahosted.org/freeipa/ticket/1182
---
 ipaserver/install/dsinstance.py |   21 ++++++++++++++++-----
 ipaserver/install/service.py    |    2 +-
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 38195c72cf5337178fe314d6236dd803040ccf79..74243cfc1b4bdda853e03130f01094362fd3bf0a 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -183,6 +183,7 @@ class DsInstance(service.Service):
         self.idstart = None
         self.idmax = None
         self.subject_base = None
+        self.open_ports = []
         if realm_name:
             self.suffix = util.realm_to_suffix(self.realm_name)
             self.__setup_sub_dict()
@@ -376,9 +377,13 @@ class DsInstance(service.Service):
             logging.debug("completed creating ds instance")
         except ipautil.CalledProcessError, e:
             logging.critical("failed to restart ds instance %s" % e)
+        
+        # check for open port 389 from now on
+        self.open_ports.append(389)
+
         logging.debug("restarting ds instance")
         try:
-            self.restart(self.serverid)
+            self.__restart_instance()
             logging.debug("done restarting ds instance")
         except ipautil.CalledProcessError, e:
             print "failed to restart ds instance", e
@@ -406,18 +411,21 @@ class DsInstance(service.Service):
             # Does not apply with newer DS releases
             pass
 
-    def __restart_instance(self):
+    def restart(self, instance=''):
         try:
-            self.restart(self.serverid)
+            super(DsInstance, self).restart(instance)
             if not is_ds_running():
                 logging.critical("Failed to restart the directory server. See the installation log for details.")
                 sys.exit(1)
-            installutils.wait_for_open_ports('localhost', [389, 636], 300)
+            installutils.wait_for_open_ports('localhost', self.open_ports, 300)
         except SystemExit, e:
             raise e
         except Exception, e:
             # TODO: roll back here?
-            logging.critical("Failed to restart the directory server. See the installation log for details.")
+            logging.critical("Failed to restart the directory server (%s). See the installation log for details." % e)
+
+    def __restart_instance(self):
+        self.restart(self.serverid)
 
     def __enable_entryusn(self):
         self._ldap_mod("entryusn.ldif")
@@ -549,6 +557,9 @@ class DsInstance(service.Service):
 
         conn.unbind()
 
+        # check for open secure port 636 from now on
+        self.open_ports.append(636)
+
     def __add_default_layout(self):
         self._ldap_mod("bootstrap-template.ldif", self.sub_dict)
 
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 0b9bb01ebc44ecdb2423c342f1d7b6ee0d4766c9..1ebd96d7b48a8d8d1df41950da517e18383f2d9c 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -98,7 +98,7 @@ def print_msg(message, output_fd=sys.stdout):
     output_fd.write("\n")
 
 
-class Service:
+class Service(object):
     def __init__(self, service_name, sstore=None, dm_password=None):
         self.service_name = service_name
         self.steps = []
-- 
1.7.4.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to