Skip to content

Commit 0eb9df9

Browse files
author
Seeteena Thoufeek
committed
[RSCT] Add plugin to validate and repair RSCT configuration
The RSCT plugin performs following checks to validate RSCT configuations. 1. Check for RSCT installation path 2. Check for RSCT Package information 3. Check for RSCT Service check 4. Check for ibm-power-repo package The RSCT plugin performs following checks to repair RSCT configurations. 1. Repair and fix RSCT installation path 2. Repair and fix RSCT Package information if any of the RSCT package is missing 3. Repair and fix RSCT Service check if any of the RSCT services is down 4. Notifies/WARN user to enable and accept licensing for ibm-power-repo package if RSCT Packages is not available on the system. ibm-power-repo package needs to be enabled and accept licensing in order to install RSCT packages on the system More info on RSCT: https://www.ibm.com/support/knowledgecenter/SGVKBA_3.2/admin/bl503_ovrv.html https://www.ibm.com/support/pages/service-and-productivity-tools Signed-off-by: Seeteena Thoufeek [email protected] Signed-off-by: Sourabh Jain [email protected]
1 parent 20c21fb commit 0eb9df9

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# (C) Copyright IBM Corp. 2020
4+
# Author: Seeteena Thoufeek <[email protected]>
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.NOT_FIXABLE + "\n \n \
83+
WARNING!!!! ibm-power-repo package needs to be enabled to install rsct \
84+
packages on this machine. \n Please follow below steps to install \
85+
ibm-power-repo package. \n 1. Download and install ibm-power-repo package. \
86+
\n 2. run /opt/ibm/lop/configure to agree with the license. \
87+
\n Refer https://www.ibm.com/support/pages/service-and-productivity-tools \
88+
for more details")
89+
return
90+
if rsct_package_check.get_status() is False:
91+
self.fix_rsct_package(plugin_obj, rsct_package_check)
92+
elif rsct_package_check.get_status() is None:
93+
rsct_package_check.set_note(Notes.FAIL_TO_FIX)
94+
95+
if "RSCT Installation path" in check_dir.keys():
96+
rsct_install_exists = check_dir["RSCT Installation path"]
97+
if rsct_install_exists.get_status() is False:
98+
self.fix_rsct_install_path(plugin_obj, rsct_install_exists)
99+
elif rsct_install_exists.get_status() is None:
100+
rsct_install_exists.set_note(Notes.FAIL_TO_FIX)
101+
102+
if "RSCT service status" in check_dir.keys():
103+
rsct_service_check = check_dir["RSCT service status"]
104+
self.log.debug("rsct_service_check %s %s",
105+
rsct_service_check.get_status(),
106+
rsct_service_check.get_service())
107+
if rsct_service_check.get_status() is False:
108+
self.enable_subsystem(plugin_obj, rsct_service_check)
109+
elif rsct_service_check.get_status() is None:
110+
rsct_service_check.set_note(Notes.FAIL_TO_FIX)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# (C) Copyright IBM Corp. 2020
4+
# Author: Seeteena Thoufeek <[email protected]>
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+
104+
def check_rsct_warning_check(self):
105+
"""IBM Power Repo Package Check"""
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_warning_check.__doc__,
114+
power_repo_package, status)
115+

0 commit comments

Comments
 (0)