summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Misnyovszki <amisnyov@redhat.com>2014-02-20 15:34:05 +0100
committerMartin Kosek <mkosek@redhat.com>2014-02-20 16:41:30 +0100
commit189bdcb95d4d2346ad5859c2717e7b94dcca018b (patch)
tree1483bb6adce5ab2ae5c0dd2f6a473b8753cafc58
parent6bbc3368544fb898d5191ae1c19b0ef1e1809eb0 (diff)
downloadfreeipa.git-189bdcb95d4d2346ad5859c2717e7b94dcca018b.tar.gz
freeipa.git-189bdcb95d4d2346ad5859c2717e7b94dcca018b.tar.xz
freeipa.git-189bdcb95d4d2346ad5859c2717e7b94dcca018b.zip
Add --force option to ipactl
If an error occurs in the start up sequence in ipactl start/restart, all the services are stopped. Using the --force option prevents stopping of services that have successfully started, just skips the services which can not be started. ipactl status now shows stopped services also, if the directory server is running. With the contribution of Ana Krivokapic https://fedorahosted.org/freeipa/ticket/3509 Reviewed-By: Martin Kosek <mkosek@redhat.com>
-rwxr-xr-xinstall/tools/ipactl109
-rw-r--r--install/tools/man/ipactl.86
2 files changed, 67 insertions, 48 deletions
diff --git a/install/tools/ipactl b/install/tools/ipactl
index 58c7f316..202081d4 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -87,6 +87,9 @@ def parse_options():
parser.add_option("-d", "--debug", action="store_true", dest="debug",
help="Display debugging information")
+ parser.add_option("-f", "--force", action="store_true", dest="force",
+ help="If any service start fails, do not rollback the"
+ + " services, continue with the operation")
options, args = parser.parse_args()
safe_options = parser.get_safe_opts(options)
@@ -189,6 +192,23 @@ def get_config_from_file():
return ordered_list
+
+def stop_services(svc_list):
+ for svc in svc_list:
+ svc_off = ipaservices.service(svc)
+ try:
+ svc_off.stop(capture_output=False)
+ except Exception:
+ pass
+
+
+def stop_dirsrv(dirsrv):
+ try:
+ dirsrv.stop(capture_output=False)
+ except Exception:
+ pass
+
+
def ipa_start(options):
if os.path.isfile(ipaservices.get_svc_list_file()):
@@ -214,10 +234,10 @@ def ipa_start(options):
except Exception, e:
emit_err("Failed to data from service file: " + str(e))
emit_err("Shutting down")
- try:
- dirsrv.stop(capture_output=False)
- except:
- pass
+
+ if not options.force:
+ stop_dirsrv(dirsrv)
+
if isinstance(e, IpactlError):
# do not display any other error message
raise IpactlError(rval=e.rval)
@@ -233,19 +253,17 @@ def ipa_start(options):
try:
print "Starting %s Service" % svc
svchandle.start(capture_output=get_capture_output(svc, options.debug))
- except:
+ except Exception:
emit_err("Failed to start %s Service" % svc)
+ #if force start specified, skip rollback and continue with the next service
+ if options.force:
+ emit_err("Forced start, ignoring %s Service, continuing normal operation" % svc)
+ continue
+
emit_err("Shutting down")
- for svc in svc_list:
- svc_off = ipaservices.service(svc)
- try:
- svc_off.stop(capture_output=False)
- except:
- pass
- try:
- dirsrv.stop(capture_output=False)
- except:
- pass
+ stop_services(svc_list)
+ stop_dirsrv(dirsrv)
+
raise IpactlError("Aborting ipactl")
def ipa_stop(options):
@@ -354,16 +372,11 @@ def ipa_restart(options):
except Exception, e:
emit_err("Failed to restart Directory Service: " + str(e))
emit_err("Shutting down")
- for svc in reversed(svc_list):
- svc_off = ipaservices.service(svc)
- try:
- svc_off.stop(capture_output=False)
- except:
- pass
- try:
- dirsrv.stop(capture_output=False)
- except:
- pass
+
+ if not options.force:
+ stop_services(reversed(svc_list))
+ stop_dirsrv(dirsrv)
+
raise IpactlError("Aborting ipactl")
if len(svc_list) != 0:
@@ -374,19 +387,17 @@ def ipa_restart(options):
try:
print "Restarting %s Service" % svc
svchandle.restart(capture_output=get_capture_output(svc, options.debug))
- except:
+ except Exception:
emit_err("Failed to restart %s Service" % svc)
+ #if force start specified, skip rollback and continue with the next service
+ if options.force:
+ emit_err("Forced restart, ignoring %s Service, continuing normal operation" % svc)
+ continue
+
emit_err("Shutting down")
- for svc in reversed(svc_list):
- svc_off = ipaservices.service(svc)
- try:
- svc_off.stop(capture_output=False)
- except:
- pass
- try:
- dirsrv.stop(capture_output=False)
- except:
- pass
+ stop_services(svc_list)
+ stop_dirsrv(dirsrv)
+
raise IpactlError("Aborting ipactl")
if len(new_svc_list) != 0:
@@ -396,25 +407,27 @@ def ipa_restart(options):
try:
print "Starting %s Service" % svc
svchandle.start(capture_output=get_capture_output(svc, options.debug))
- except:
+ except Exception:
emit_err("Failed to start %s Service" % svc)
+ #if force start specified, skip rollback and continue with the next service
+ if options.force:
+ emit_err("Forced start, ignoring %s Service, continuing normal operation" % svc)
+ continue
+
emit_err("Shutting down")
- for svc in reversed(svc_list):
- svc_off = ipaservices.service(svc)
- try:
- svc_off.stop(capture_output=False)
- except:
- pass
- try:
- dirsrv.stop(capture_output=False)
- except:
- pass
+ stop_services(svc_list)
+ stop_dirsrv(dirsrv)
+
raise IpactlError("Aborting ipactl")
def ipa_status(options):
try:
- svc_list = get_config_from_file()
+ dirsrv = ipaservices.knownservices.dirsrv
+ if dirsrv.is_running():
+ svc_list = get_config(dirsrv)
+ else:
+ svc_list = get_config_from_file()
except IpactlError, e:
if os.path.exists(ipaservices.get_svc_list_file()):
raise e
diff --git a/install/tools/man/ipactl.8 b/install/tools/man/ipactl.8
index 05be8e0e..5a1fd27a 100644
--- a/install/tools/man/ipactl.8
+++ b/install/tools/man/ipactl.8
@@ -37,3 +37,9 @@ Stop all of the services that make up IPA
.TP
restart
Stop then start all of the services that make up IPA
+.TP
+\fB\-d\fR, \fB\-\-debug\fR
+Display debugging information
+.TP
+\fB\-f\fR, \fB\-\-force\fR
+If any service start fails, do not rollback the services, continue with the operation