Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
18f53d92
Commit
18f53d92
authored
Mar 10, 2014
by
Charles Duffy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#6341: use shared function for parsing systemd status; check rc code
parent
d5997329
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
library/system/service
+12
-7
No files found.
library/system/service
View file @
18f53d92
...
@@ -473,18 +473,25 @@ class LinuxService(Service):
...
@@ -473,18 +473,25 @@ class LinuxService(Service):
if
location
.
get
(
'initctl'
,
None
):
if
location
.
get
(
'initctl'
,
None
):
self
.
svc_initctl
=
location
[
'initctl'
]
self
.
svc_initctl
=
location
[
'initctl'
]
def
get_systemd_status_dict
(
self
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s"
%
(
self
.
enable_cmd
,
self
.
__systemd_unit
,))
if
rc
!=
0
:
self
.
module
.
fail_json
(
'failure
%
d running systemctl show for
%
r:
%
s'
%
(
self
.
__systemd_unit
,
rc
,
err
))
return
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
def
get_systemd_service_status
(
self
):
def
get_systemd_service_status
(
self
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s"
%
(
self
.
enable_cmd
,
self
.
__systemd_unit
))
d
=
self
.
get_systemd_status_dict
()
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
if
d
.
get
(
'ActiveState'
)
==
'active'
:
if
d
[
'ActiveState'
]
==
'active'
:
# run-once services (for which a single successful exit indicates
# run-once services (for which a single successful exit indicates
# that they are running as designed) should not be restarted here.
# that they are running as designed) should not be restarted here.
# Thus, we are not checking d['SubState'].
# Thus, we are not checking d['SubState'].
self
.
running
=
True
self
.
running
=
True
self
.
crashed
=
False
self
.
crashed
=
False
elif
d
[
'ActiveState'
]
==
'failed'
:
elif
d
.
get
(
'ActiveState'
)
==
'failed'
:
self
.
running
=
False
self
.
running
=
False
self
.
crashed
=
True
self
.
crashed
=
True
elif
d
.
get
(
'ActiveState'
)
is
None
:
self
.
module
.
fail_json
(
msg
=
'No ActiveState value in systemctl show output for
%
r'
%
(
self
.
__systemd_unit
,))
else
:
else
:
self
.
running
=
False
self
.
running
=
False
self
.
crashed
=
False
self
.
crashed
=
False
...
@@ -605,9 +612,7 @@ class LinuxService(Service):
...
@@ -605,9 +612,7 @@ class LinuxService(Service):
return
return
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s"
%
(
self
.
enable_cmd
,
self
.
__systemd_unit
))
d
=
self
.
get_systemd_status_dict
()
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
if
"UnitFileState"
in
d
:
if
"UnitFileState"
in
d
:
if
self
.
enable
and
d
[
"UnitFileState"
]
==
"enabled"
:
if
self
.
enable
and
d
[
"UnitFileState"
]
==
"enabled"
:
return
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment