mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-03 12:11:25 -06:00
ipactl: Do not start/stop/restart single service multiple times
In case multiple services are provided by single system daemon it is not needed to start/stop/restart it mutiple time. https://fedorahosted.org/freeipa/ticket/5248 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
parent
02ab34c60b
commit
59cc54b6dc
@ -45,6 +45,16 @@ def check_IPA_configuration():
|
|||||||
raise IpactlError("IPA is not configured " +
|
raise IpactlError("IPA is not configured " +
|
||||||
"(see man pages of ipa-server-install for help)", 6)
|
"(see man pages of ipa-server-install for help)", 6)
|
||||||
|
|
||||||
|
def deduplicate(lst):
|
||||||
|
new_lst = []
|
||||||
|
s = set(lst)
|
||||||
|
for i in lst:
|
||||||
|
if i in s:
|
||||||
|
s.remove(i)
|
||||||
|
new_lst.append(i)
|
||||||
|
|
||||||
|
return new_lst
|
||||||
|
|
||||||
def is_dirsrv_debugging_enabled():
|
def is_dirsrv_debugging_enabled():
|
||||||
"""
|
"""
|
||||||
Check the 389-ds instance to see if debugging is enabled.
|
Check the 389-ds instance to see if debugging is enabled.
|
||||||
@ -283,6 +293,7 @@ def ipa_start(options):
|
|||||||
# no service to start
|
# no service to start
|
||||||
return
|
return
|
||||||
|
|
||||||
|
svc_list = deduplicate(svc_list)
|
||||||
for svc in svc_list:
|
for svc in svc_list:
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
@ -321,6 +332,7 @@ def ipa_stop(options):
|
|||||||
finally:
|
finally:
|
||||||
raise IpactlError()
|
raise IpactlError()
|
||||||
|
|
||||||
|
svc_list = deduplicate(svc_list)
|
||||||
for svc in reversed(svc_list):
|
for svc in reversed(svc_list):
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
@ -398,6 +410,7 @@ def ipa_restart(options):
|
|||||||
|
|
||||||
if len(old_svc_list) != 0:
|
if len(old_svc_list) != 0:
|
||||||
# we need to definitely stop some services
|
# we need to definitely stop some services
|
||||||
|
old_svc_list = deduplicate(old_svc_list)
|
||||||
for svc in reversed(old_svc_list):
|
for svc in reversed(old_svc_list):
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
@ -422,7 +435,7 @@ def ipa_restart(options):
|
|||||||
|
|
||||||
if len(svc_list) != 0:
|
if len(svc_list) != 0:
|
||||||
# there are services to restart
|
# there are services to restart
|
||||||
|
svc_list = deduplicate(svc_list)
|
||||||
for svc in svc_list:
|
for svc in svc_list:
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
@ -444,6 +457,7 @@ def ipa_restart(options):
|
|||||||
|
|
||||||
if len(new_svc_list) != 0:
|
if len(new_svc_list) != 0:
|
||||||
# we still need to start some services
|
# we still need to start some services
|
||||||
|
new_svc_list = deduplicate(new_svc_list)
|
||||||
for svc in new_svc_list:
|
for svc in new_svc_list:
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
@ -494,6 +508,7 @@ def ipa_status(options):
|
|||||||
if len(svc_list) == 0:
|
if len(svc_list) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
svc_list = deduplicate(svc_list)
|
||||||
for svc in svc_list:
|
for svc in svc_list:
|
||||||
svchandle = services.service(svc)
|
svchandle = services.service(svc)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user