Skip to content

Commit 081b32c

Browse files
author
Seeteena Thoufeek
committed
Add RSCT Validate/Repair check in ServiceReport tool
Signed-off-by: Seeteena Thoufeek s1seetee@linux.vnet.ibm.com
1 parent d3e790d commit 081b32c

3 files changed

Lines changed: 220 additions & 0 deletions

File tree

servicereportpkg/check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,4 @@ class Notes(object):
151151
FAIL_TO_FIX = "Unable to Fix"
152152
NOT_FIXABLE = "Not Auto-Fixable"
153153
FIXED_NEED_REBOOT = "Auto Fixed, Needs Reboot"
154+
MANUAL_FIX = "Manual Fix Needed"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# (C) Copyright IBM Corp. 2020
4+
# Author: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
5+
6+
"""Plugin to repair the rsct configuration check"""
7+
8+
9+
from servicereportpkg.repair.plugins import RepairPlugin
10+
from servicereportpkg.check import Notes
11+
from servicereportpkg.utils import execute_command
12+
from servicereportpkg.validate.schemes.schemes import PSeriesScheme
13+
from servicereportpkg.utils import install_package
14+
15+
16+
class RSCTRepair(RepairPlugin, PSeriesScheme):
17+
"""Plugin to repair the RSCT configuration check"""
18+
19+
def __init__(self):
20+
RepairPlugin.__init__(self)
21+
self.name = 'RSCT'
22+
self.optional = True
23+
24+
def enable_subsystem(self, plugin_obj, check):
25+
"""Enables the subsystem if not active"""
26+
27+
subsys_list = check.get_service()
28+
for subsystem in subsys_list:
29+
subsystem_status = subsystem[1]
30+
if subsystem_status is False:
31+
command = ["startsrc", "-s", subsystem[0]]
32+
execute_command(command)
33+
re_check = plugin_obj.check_rsct_subsystem_check()
34+
if re_check.get_status():
35+
self.log.debug("Subsystems active")
36+
check.set_status(True)
37+
check.set_note(Notes.FIXED)
38+
else:
39+
self.log.debug("Subsystems not active")
40+
check.set_note(Notes.FAIL_TO_FIX)
41+
42+
def fix_rsct_package(self, plugin_obj, check):
43+
"""fix rsct package"""
44+
45+
self.log.info("RSCT package repair")
46+
pkg_list = check.get_package_name()
47+
for package in pkg_list:
48+
install_package(package[0])
49+
re_check = plugin_obj.check_rsct_package_check()
50+
if re_check.get_status():
51+
check.set_status(True)
52+
check.set_note(Notes.FIXED)
53+
else:
54+
check.set_note(Notes.FAIL_TO_FIX)
55+
56+
def fix_rsct_install_path(self, plugin_obj, check):
57+
"""Fix rsct install path"""
58+
59+
re_check = plugin_obj.check_rsct_installation_path()
60+
if re_check.get_status():
61+
check.set_status(True)
62+
check.set_note(Notes.FIXED)
63+
else:
64+
check.set_note(Notes.FAIL_TO_FIX)
65+
66+
def repair(self, plugin_obj, checks):
67+
"""Repair rsct subsystem checks"""
68+
69+
self.log.info("RSCT Subsystem Repair")
70+
check_dir = {}
71+
for check in checks:
72+
check_dir[check.get_name()] = check
73+
74+
rsct_package_check = check_dir["RSCT package check"]
75+
self.log.debug("package_check: %s", rsct_package_check.get_name())
76+
if not rsct_package_check.get_status():
77+
rsct_power_repo_check = \
78+
check_dir["IBM Power Repo Package check"]
79+
self.log.debug("rsct_power_repo_check %s",
80+
rsct_power_repo_check.get_name())
81+
if not rsct_power_repo_check.get_status():
82+
rsct_power_repo_check.set_note(Notes.MANUAL_FIX + " install \
83+
ibm-power-repo package, run /opt/ibm/lop/configure to agree with the license")
84+
return
85+
if rsct_package_check.get_status() is False:
86+
self.fix_rsct_package(plugin_obj, rsct_package_check)
87+
elif rsct_package_check.get_status() is None:
88+
rsct_package_check.set_note(Notes.FAIL_TO_FIX)
89+
90+
if "RSCT Installation path" in check_dir.keys():
91+
rsct_install_exists = check_dir["RSCT Installation path"]
92+
if rsct_install_exists.get_status() is False:
93+
self.fix_rsct_install_path(plugin_obj, rsct_install_exists)
94+
elif rsct_install_exists.get_status() is None:
95+
rsct_install_exists.set_note(Notes.FAIL_TO_FIX)
96+
97+
if "RSCT service status" in check_dir.keys():
98+
rsct_service_check = check_dir["RSCT service status"]
99+
self.log.debug("rsct_service_check %s %s",
100+
rsct_service_check.get_status(),
101+
rsct_service_check.get_service())
102+
if rsct_service_check.get_status() is False:
103+
self.enable_subsystem(plugin_obj, rsct_service_check)
104+
elif rsct_service_check.get_status() is None:
105+
rsct_service_check.set_note(Notes.FAIL_TO_FIX)
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# (C) Copyright IBM Corp. 2020
4+
# Author: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
5+
6+
"""Plugin to check RSCT configuration"""
7+
8+
import os
9+
10+
from servicereportpkg.check import Check
11+
from servicereportpkg.validate.plugins import Plugin
12+
from servicereportpkg.utils import execute_command
13+
from servicereportpkg.check import PackageCheck, ServiceCheck
14+
from servicereportpkg.utils import is_package_installed
15+
from servicereportpkg.validate.schemes.schemes import PSeriesScheme
16+
17+
18+
class RSCT(Plugin, PSeriesScheme):
19+
"""RSCT configuration check"""
20+
21+
def __init__(self):
22+
Plugin.__init__(self)
23+
self.name = RSCT.__name__
24+
self.description = RSCT.__doc__
25+
self.optional = True
26+
self.installation_path = "/opt/rsct/bin"
27+
self.packages = [
28+
"rsct.core",
29+
"rsct.core.utils",
30+
"rsct.basic",
31+
"src",
32+
"devices.chrp.base.ServiceRM",
33+
"DynamicRM",
34+
]
35+
self.subsystems = ["ctrmc", "IBM.DRM", "IBM.HostRM",
36+
"IBM.ServiceRM", "IBM.MgmtDomainRM"]
37+
38+
def check_rsct_installation_path(self):
39+
"""RSCT Installation path"""
40+
41+
installation_path_exists = True
42+
self.log.info("RSCT Installation path check")
43+
if not os.path.isdir(self.installation_path):
44+
self.log.error("Missing RSCT installation directory %s",
45+
self.installation_path)
46+
installation_path_exists = False
47+
48+
return Check(self.check_rsct_installation_path.__doc__,
49+
installation_path_exists)
50+
51+
def get_subsystem_status(self, subsystem):
52+
"""Checks the subsystem status"""
53+
54+
command = ["lssrc", "-s", subsystem]
55+
(return_code, stdout, err) = execute_command(command)
56+
57+
if return_code is None or ("active" not in str(stdout)):
58+
self.log.info("Subsystem %s error %s", subsystem, str(err))
59+
return False
60+
61+
return True
62+
63+
def check_rsct_subsystem_check(self):
64+
"""RSCT service status"""
65+
66+
subsys_list = []
67+
subsys_status = True
68+
status = True
69+
self.log.info("RSCT Subsystem status check")
70+
for subsystem in self.subsystems:
71+
if not self.get_subsystem_status(subsystem):
72+
self.log.debug("%s Subsystem is not active", subsystem)
73+
subsys_status = False
74+
status = False
75+
subsys_list.append((subsystem, subsys_status))
76+
else:
77+
subsys_status = True
78+
subsys_list.append((subsystem, subsys_status))
79+
80+
return ServiceCheck(self.check_rsct_subsystem_check.__doc__,
81+
subsys_list, status)
82+
83+
def check_rsct_package_check(self):
84+
"""RSCT package check"""
85+
86+
pkg_list = []
87+
pkg_status = True
88+
status = True
89+
self.log.info("RSCT Package check")
90+
for package in self.packages:
91+
if not is_package_installed(package):
92+
self.log.error("%s package is not installed", package)
93+
status = False
94+
pkg_status = False
95+
pkg_list.append((package, pkg_status))
96+
else:
97+
pkg_status = True
98+
pkg_list.append((package, pkg_status))
99+
100+
return PackageCheck(self.check_rsct_package_check.__doc__,
101+
pkg_list, status)
102+
103+
def check_rsct_ibm_power_repo_check(self):
104+
"""IBM Power Repo Package check"""
105+
106+
status = True
107+
power_repo_package = "ibm-power-repo"
108+
self.log.info("ibm-power-repo Package check")
109+
if not is_package_installed(power_repo_package):
110+
self.log.error("ibm-power-repo package is not installed")
111+
status = False
112+
113+
return PackageCheck(self.check_rsct_ibm_power_repo_check.__doc__,
114+
power_repo_package, status)

0 commit comments

Comments
 (0)