Skip to content

Commit 22c85d0

Browse files
authored
Merge branch 'linux-ras:master' into a
2 parents 081b32c + 20c21fb commit 22c85d0

14 files changed

Lines changed: 239 additions & 71 deletions

File tree

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
# (C) Copyright IBM Corp. 2018, 2019
44
# Author: Sourabh Jain <sourabhjain@linux.ibm.com>
55

6+
PYTHON:=python3
7+
68

79
# build everything needed to install
810
build:
9-
python setup.py build
11+
$(PYTHON) setup.py build
1012

1113
# install everything from build directory
1214
install:
13-
python setup.py install
15+
$(PYTHON) setup.py install
1416

1517
# build the rpm package
1618
build_rpm:
17-
python setup.py bdist_rpm
19+
$(PYTHON) setup.py bdist_rpm
1820

1921
# clean up temporary files from 'build' command
2022
clean:
21-
python setup.py clean --all
23+
$(PYTHON) setup.py clean --all

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ make install
5959

6060
### Running
6161

62+
NOTE: servicereport by default runs with python3, if you want to run
63+
servicereport with python2 consider chaging the shebang in servicereport
64+
script to python2.
65+
6266
Runs and print the status of all the applicable plugins in current system
6367
```
6468
$ servicereport

ServiceReport.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ systemctl enable servicereport.service
4343
%defattr(-,root,root)
4444
%doc /usr/share/man/man8/*
4545
%doc /usr/share/doc/*
46+
%doc /usr/share/licenses/*
4647
/usr/lib/*
4748
/usr/bin/*
4849

servicereport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# SPDX-License-Identifier: GPL-2.0-only
44
#

servicereportpkg/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
import sys
1414
import time
15+
import platform
1516
from argparse import ArgumentParser
1617

1718
from servicereportpkg.repair import Repair
@@ -21,9 +22,10 @@
2122
from servicereportpkg.global_context import TOOL_NAME
2223
from servicereportpkg.logger import get_default_logger
2324
from servicereportpkg.utils import trigger_kernel_crash
25+
from servicereportpkg.global_context import SUPPORTED_ARCHS
2426

2527

26-
__version__ = '2.2.2'
28+
__version__ = '2.2.3'
2729

2830

2931
def parse_commandline_args(args):
@@ -104,10 +106,25 @@ def get_dump_plugin(validation_results):
104106
return None
105107

106108

109+
def is_arch_supported():
110+
"""Returns True if the tool supports current architecture else False"""
111+
112+
arch = platform.machine().lower()
113+
if arch in SUPPORTED_ARCHS:
114+
return True
115+
116+
return False
117+
118+
107119
def main():
108120
"""Entry point of ServiceReport tool"""
109121

110122
cmd_opts = parse_commandline_args(sys.argv[1:])
123+
124+
if not is_arch_supported():
125+
print("\nUnsupported Architecure!")
126+
return 1
127+
111128
log = setup_logger(cmd_opts.log_file, cmd_opts.verbose)
112129

113130
print(TOOL_NAME + " " + get_version()+"\n")

servicereportpkg/check.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,33 @@ def get_service(self):
5656
class DaemonCheck(Check):
5757
"""Manage daemon check information"""
5858

59-
def __init__(self, name, daemon, status=None, note=None):
60-
Check.__init__(self, name, status, note)
61-
self.daemon = daemon
59+
def __init__(self, name, status=None, enabled=None,
60+
active=None):
61+
"""Daemon check initializer"""
62+
63+
Check.__init__(self, name, status)
64+
self.enabled = enabled
65+
self.active = active
66+
67+
def set_daemon_enabled(self, enabled):
68+
"""Set daemon enabled status"""
69+
70+
self.enabled = enabled
71+
72+
def is_daemon_enabled(self):
73+
"""Returns daemon enabled status"""
74+
75+
return self.enabled
76+
77+
def set_daemon_active(self, active):
78+
"""Set daemon active status"""
79+
80+
self.active = active
6281

63-
def get_daemon(self):
64-
"""Returns the daemon name"""
82+
def is_daemon_active(self):
83+
"""Returns daemon active status"""
6584

66-
return self.daemon
85+
return self.active
6786

6887

6988
class PackageCheck(Check):

servicereportpkg/global_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
import sys
99

1010
TOOL_NAME = os.path.basename(sys.argv[0])
11+
SUPPORTED_ARCHS = ["ppc64le"]

servicereportpkg/repair/plugins/daemon_repair.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
from servicereportpkg.repair.plugins import RepairPlugin
10-
from servicereportpkg.utils import enable_daemon
10+
from servicereportpkg.utils import enable_daemon, restart_service
1111
from servicereportpkg.check import Notes
1212

1313
class DaemonRepair(RepairPlugin):
@@ -22,8 +22,22 @@ def repair(self, plugin_obj, checks):
2222

2323
for check in checks:
2424
if not check.get_status():
25-
if enable_daemon(check.get_name()):
25+
daemon = check.get_name()
26+
enabled = check.is_daemon_enabled()
27+
active = check.is_daemon_active()
28+
29+
if not enabled:
30+
enabled = enable_daemon(daemon)
31+
if enabled:
32+
check.set_daemon_enabled(True)
33+
34+
if not active:
35+
active = restart_service(daemon)
36+
if active:
37+
check.set_daemon_active(True)
38+
39+
if enabled and active:
2640
check.set_status(True)
2741
check.set_note(Notes.FIXED)
2842
else:
29-
check.set_note(Notes.NOT_FIXABLE)
43+
check.set_note("Failed to enable/start %s" % daemon)

servicereportpkg/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def install_package(package):
293293
log = get_default_logger()
294294

295295
if package_manager is None:
296-
log.walk_packages("Unable to locate the package manager")
296+
log.warning("Unable to locate the package manager")
297297
return None
298298

299299
command = package_manager["installer"]+" "+package_manager["install_option"]+" "+package

servicereportpkg/validate/plugins/daemon.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from servicereportpkg.check import DaemonCheck
1010
from servicereportpkg.utils import is_daemon_enabled
11+
from servicereportpkg.utils import get_service_status
1112
from servicereportpkg.validate.plugins import Plugin
1213
from servicereportpkg.validate.schemes.schemes import PSeriesScheme
1314
from servicereportpkg.validate.schemes.schemes import BMCPowerNVScheme
@@ -19,20 +20,33 @@
1920

2021

2122
def generate_daemon_check(self, daemon):
22-
"""Generates a function that checks the given daemon is enabled or not"""
23+
"""Generates a function to check daemon status"""
2324

2425
def check():
25-
check_daemon = daemon
26-
daemon_status = is_daemon_enabled(check_daemon)
27-
28-
if daemon_status is None:
29-
self.log.warning("Unable to find %s daemon status", check_daemon)
30-
elif daemon_status is False:
31-
self.log.error("%s is not enabled" % check_daemon)
26+
status = True
27+
enabled = is_daemon_enabled(daemon)
28+
29+
if enabled is None:
30+
self.log.warning("Unable to find %s daemon status", daemon)
31+
elif enabled is False:
32+
self.log.error("%s is not enabled" % daemon)
33+
34+
active = get_service_status(daemon)
35+
if active is None or active != 0:
36+
self.log.error("%s daemon is not active", daemon)
37+
self.log.recommendation("Start the service: systemctl start %s",
38+
daemon)
39+
active = False
3240
else:
33-
self.log.info("%s is enabled" % check_daemon)
41+
self.log.info("%s is active" % daemon)
42+
active = True
43+
44+
if enabled is None or active is None:
45+
status = None
46+
elif enabled is False or active is False:
47+
status = False
3448

35-
return DaemonCheck(check_daemon, check_daemon, daemon_status)
49+
return DaemonCheck(daemon, status, enabled, active)
3650

3751
check.__doc__ = "%s" % (daemon)
3852
return check

0 commit comments

Comments
 (0)