mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-25 14:40:16 -05:00
ipactl: support script status 3, program is not running
Return status 3 if ipactl status can't start 389-ds or if any of the expected services is not running. https://pagure.io/freeipa/issue/8588 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
1 parent
daf2ca3ead
commit
928ab51be6
1 file changed
+31
-10
+31
-10
@@ -613,6 +613,22 @@ def ipa_restart(options):
|
|||||||
|
|
||||||
|
|
||||||
def ipa_status(options):
|
def ipa_status(options):
|
||||||
|
"""Report status of IPA-owned processes
|
||||||
|
|
||||||
|
The LSB defines the possible status values as:
|
||||||
|
|
||||||
|
0 program is running or service is OK
|
||||||
|
1 program is dead and /var/run pid file exists
|
||||||
|
2 program is dead and /var/lock lock file exists
|
||||||
|
3 program is not running
|
||||||
|
4 program or service status is unknown
|
||||||
|
5-99 reserved for future LSB use
|
||||||
|
100-149 reserved for distribution use
|
||||||
|
150-199 reserved for application use
|
||||||
|
200-254 reserved
|
||||||
|
|
||||||
|
We only really care about 0, 3 and 4.
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dirsrv = services.knownservices.dirsrv
|
dirsrv = services.knownservices.dirsrv
|
||||||
@@ -627,7 +643,8 @@ def ipa_status(options):
|
|||||||
svc_list = []
|
svc_list = []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise IpactlError(
|
raise IpactlError(
|
||||||
"Failed to get list of services to probe status: " + str(e)
|
"Failed to get list of services to probe status: " + str(e),
|
||||||
|
4
|
||||||
)
|
)
|
||||||
|
|
||||||
dirsrv = services.knownservices.dirsrv
|
dirsrv = services.knownservices.dirsrv
|
||||||
@@ -636,19 +653,19 @@ def ipa_status(options):
|
|||||||
print("Directory Service: RUNNING")
|
print("Directory Service: RUNNING")
|
||||||
else:
|
else:
|
||||||
print("Directory Service: STOPPED")
|
print("Directory Service: STOPPED")
|
||||||
if len(svc_list) == 0:
|
|
||||||
print(
|
|
||||||
(
|
|
||||||
"Directory Service must be running in order to "
|
|
||||||
"obtain status of other services"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise IpactlError("Failed to get Directory Service status")
|
raise IpactlError("Failed to get Directory Service status", 4)
|
||||||
|
|
||||||
if len(svc_list) == 0:
|
if len(svc_list) == 0:
|
||||||
return
|
raise IpactlError(
|
||||||
|
(
|
||||||
|
"Directory Service must be running in order to "
|
||||||
|
"obtain status of other services"
|
||||||
|
),
|
||||||
|
3,
|
||||||
|
)
|
||||||
|
|
||||||
|
stopped = 0
|
||||||
for svc in svc_list:
|
for svc in svc_list:
|
||||||
svchandle = services.service(svc, api=api)
|
svchandle = services.service(svc, api=api)
|
||||||
try:
|
try:
|
||||||
@@ -656,9 +673,13 @@ def ipa_status(options):
|
|||||||
print("%s Service: RUNNING" % svc)
|
print("%s Service: RUNNING" % svc)
|
||||||
else:
|
else:
|
||||||
print("%s Service: STOPPED" % svc)
|
print("%s Service: STOPPED" % svc)
|
||||||
|
stopped += 1
|
||||||
except Exception:
|
except Exception:
|
||||||
emit_err("Failed to get %s Service status" % svc)
|
emit_err("Failed to get %s Service status" % svc)
|
||||||
|
|
||||||
|
if stopped > 0:
|
||||||
|
raise IpactlError("%d service(s) are not running" % stopped, 3)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if not os.getegid() == 0:
|
if not os.getegid() == 0:
|
||||||
|
|||||||
Reference in new issue
Block a user