ipactl can not restart ipa services if current status is stopped

fixed by starting the directory server when restarting if it is not
currently running to enable fetching running services

later restart didn't check that

also added a check, that if the directory server started at the
beginning, there is no need to restart it

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

Reviewed-By: Martin Kosek <mkosek@redhat.com>
This commit is contained in:
Misnyovszki Adam 2014-02-19 16:41:39 +01:00 committed by Martin Kosek
parent b769d1c186
commit a1459e38e7

View File

@ -291,6 +291,15 @@ def ipa_stop(options):
def ipa_restart(options):
dirsrv = ipaservices.knownservices.dirsrv
new_svc_list = []
dirsrv_restart = True
if not dirsrv.is_running():
try:
print "Starting Directory Service"
dirsrv.start(capture_output=get_capture_output('dirsrv', options.debug))
dirsrv_restart = False
except Exception, e:
raise IpactlError("Failed to start Directory Service: " + str(e))
try:
new_svc_list = get_config(dirsrv)
except Exception, e:
@ -339,8 +348,9 @@ def ipa_restart(options):
emit_err("Failed to stop %s Service" % svc)
try:
print "Restarting Directory Service"
dirsrv.restart(capture_output=get_capture_output('dirsrv', options.debug))
if dirsrv_restart:
print "Restarting Directory Service"
dirsrv.restart(capture_output=get_capture_output('dirsrv', options.debug))
except Exception, e:
emit_err("Failed to restart Directory Service: " + str(e))
emit_err("Shutting down")