diff options
author | Rob Crittenden <rcrit@rhel1.greyoak.com> | 2008-04-14 21:18:24 -0400 |
---|---|---|
committer | Rob Crittenden <rcrit@rhel1.greyoak.com> | 2008-04-14 23:14:16 -0400 |
commit | 4eb7c51e59dee8348463e83a50e7fba2f1cf2677 (patch) | |
tree | af7118ee476f5e5134ef15829a4723035dc977e4 /ipa-server/ipaserver | |
parent | b1f58e5441eeb371a55d1f54d4f33bdf65a1c2f1 (diff) | |
download | freeipa-4eb7c51e59dee8348463e83a50e7fba2f1cf2677.tar.gz freeipa-4eb7c51e59dee8348463e83a50e7fba2f1cf2677.tar.xz freeipa-4eb7c51e59dee8348463e83a50e7fba2f1cf2677.zip |
Better detection of DS not starting.
The dirsrv init script always returns 0 on status checks, even if an
instance is not started. So we have to look through the output instead.
442452
Diffstat (limited to 'ipa-server/ipaserver')
-rw-r--r-- | ipa-server/ipaserver/dsinstance.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py index cd89d31ec..a56a8a814 100644 --- a/ipa-server/ipaserver/dsinstance.py +++ b/ipa-server/ipaserver/dsinstance.py @@ -87,6 +87,21 @@ def check_ports(): ds_secure = installutils.port_available(636) return (ds_unsecure, ds_secure) +def is_ds_running(): + """The DS init script always returns 0 when requesting status so it cannot + be used to determine if the server is running. We have to look at the + output. + """ + ret = True + try: + (sout, serr) = ipautil.run(["/sbin/service", "dirsrv", "status"]) + if sout.find("is stopped") >= 0: + ret = False + except ipautil.CalledProcessError: + ret = False + return ret + + INF_TEMPLATE = """ [General] FullMachineName= $FQHN @@ -192,7 +207,7 @@ class DsInstance(service.Service): self.backup_state("user_exists", user_exists) def __create_instance(self): - self.backup_state("running", self.is_running()) + self.backup_state("running", is_ds_running()) self.backup_state("serverid", self.serverid) self.sub_dict['BASEDC'] = self.realm_name[:self.realm_name.find('.')].lower() @@ -242,9 +257,14 @@ class DsInstance(service.Service): def __restart_instance(self): try: self.restart() - except: + if not is_ds_running(): + logging.critical("Failed to restart the directory server. See the installation log for details.") + sys.exit(1) + except SystemExit, e: + raise e + except Exception, e: # TODO: roll back here? - logging.critical("Failed to restart the ds instance") + logging.critical("Failed to restart the directory server. See the installation log for details.") def __ldap_mod(self, ldif, sub_dict = None): fd = None |