Skip to content

Commit

Permalink
[RSCT] Add plugin to validate and repair RSCT configuration
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Seeteena Thoufeek committed May 30, 2023
1 parent 20c21fb commit 1e11534
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 0 deletions.
110 changes: 110 additions & 0 deletions servicereportpkg/repair/plugins/rsct_repair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#SPDX-License-Identifier: GPL-2.0-only
#
# (C) Copyright IBM Corp. 2020
# Author: Seeteena Thoufeek <[email protected]>

"""Plugin to repair the rsct configuration check"""


from servicereportpkg.repair.plugins import RepairPlugin
from servicereportpkg.check import Notes
from servicereportpkg.utils import execute_command
from servicereportpkg.validate.schemes.schemes import PSeriesScheme
from servicereportpkg.utils import install_package


class RSCTRepair(RepairPlugin, PSeriesScheme):
"""Plugin to repair the RSCT configuration check"""

def __init__(self):
RepairPlugin.__init__(self)
self.name = 'RSCT'
self.optional = True

def enable_subsystem(self, plugin_obj, check):
"""Enables the subsystem if not active"""

subsys_list = check.get_service()
for subsystem in subsys_list:
subsystem_status = subsystem[1]
if subsystem_status is False:
command = ["startsrc", "-s", subsystem[0]]
execute_command(command)
re_check = plugin_obj.check_rsct_subsystem_check()
if re_check.get_status():
self.log.debug("Subsystems active")
check.set_status(True)
check.set_note(Notes.FIXED)
else:
self.log.debug("Subsystems not active")
check.set_note(Notes.FAIL_TO_FIX)

def fix_rsct_package(self, plugin_obj, check):
"""fix rsct package"""

self.log.info("RSCT package repair")
pkg_list = check.get_package_name()
for package in pkg_list:
install_package(package[0])
re_check = plugin_obj.check_rsct_package_check()
if re_check.get_status():
check.set_status(True)
check.set_note(Notes.FIXED)
else:
check.set_note(Notes.FAIL_TO_FIX)

def fix_rsct_install_path(self, plugin_obj, check):
"""Fix rsct install path"""

re_check = plugin_obj.check_rsct_installation_path()
if re_check.get_status():
check.set_status(True)
check.set_note(Notes.FIXED)
else:
check.set_note(Notes.FAIL_TO_FIX)

def repair(self, plugin_obj, checks):
"""Repair rsct subsystem checks"""

self.log.info("RSCT Subsystem Repair")
check_dir = {}
for check in checks:
check_dir[check.get_name()] = check

rsct_package_check = check_dir["RSCT package check"]
self.log.debug("package_check: %s", rsct_package_check.get_name())
if not rsct_package_check.get_status():
rsct_power_repo_check = \
check_dir["IBM Power Repo Package Check"]
self.log.debug("rsct_power_repo_check %s",
rsct_power_repo_check.get_name())
if not rsct_power_repo_check.get_status():
rsct_power_repo_check.set_note(Notes.NOT_FIXABLE + "\n \n \
WARNING!!!! ibm-power-repo package needs to be enabled to install rsct \
packages on this machine. \n Please follow below steps to install \
ibm-power-repo package. \n 1. Download and install ibm-power-repo package. \
\n 2. run /opt/ibm/lop/configure to agree with the license. \
\n Refer https://www.ibm.com/support/pages/service-and-productivity-tools \
for more details")
return
if rsct_package_check.get_status() is False:
self.fix_rsct_package(plugin_obj, rsct_package_check)
elif rsct_package_check.get_status() is None:
rsct_package_check.set_note(Notes.FAIL_TO_FIX)

if "RSCT Installation path" in check_dir.keys():
rsct_install_exists = check_dir["RSCT Installation path"]
if rsct_install_exists.get_status() is False:
self.fix_rsct_install_path(plugin_obj, rsct_install_exists)
elif rsct_install_exists.get_status() is None:
rsct_install_exists.set_note(Notes.FAIL_TO_FIX)

if "RSCT service status" in check_dir.keys():
rsct_service_check = check_dir["RSCT service status"]
self.log.debug("rsct_service_check %s %s",
rsct_service_check.get_status(),
rsct_service_check.get_service())
if rsct_service_check.get_status() is False:
self.enable_subsystem(plugin_obj, rsct_service_check)
elif rsct_service_check.get_status() is None:
rsct_service_check.set_note(Notes.FAIL_TO_FIX)
116 changes: 116 additions & 0 deletions servicereportpkg/validate/plugins/rsct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# (C) Copyright IBM Corp. 2020
# Author: Seeteena Thoufeek <[email protected]>

"""Plugin to check RSCT configuration"""

import os

from servicereportpkg.check import Check
from servicereportpkg.validate.plugins import Plugin
from servicereportpkg.utils import execute_command
from servicereportpkg.check import PackageCheck, ServiceCheck
from servicereportpkg.utils import is_package_installed
from servicereportpkg.validate.schemes.schemes import PSeriesScheme


class RSCT(Plugin, PSeriesScheme):
"""RSCT configuration check"""

def __init__(self):
Plugin.__init__(self)
self.name = RSCT.__name__
self.description = RSCT.__doc__
self.optional = True
self.installation_path = "/opt/rsct/bin"
self.packages = [
"rsct.core",
"rsct.core.utils",
"rsct.basic",
"src",
"devices.chrp.base.ServiceRM",
"DynamicRM",
]
self.subsystems = ["ctrmc", "IBM.DRM", "IBM.HostRM",
"IBM.ServiceRM", "IBM.MgmtDomainRM"]

def check_rsct_installation_path(self):
"""RSCT Installation path"""

installation_path_exists = True
self.log.info("RSCT Installation path check")
if not os.path.isdir(self.installation_path):
self.log.error("Missing RSCT installation directory %s",
self.installation_path)
installation_path_exists = False

return Check(self.check_rsct_installation_path.__doc__,
installation_path_exists)

def get_subsystem_status(self, subsystem):
"""Checks the subsystem status"""

command = ["lssrc", "-s", subsystem]
(return_code, stdout, err) = execute_command(command)

if return_code is None or ("active" not in str(stdout)):
self.log.info("Subsystem %s error %s", subsystem, str(err))
return False

return True

def check_rsct_subsystem_check(self):
"""RSCT service status"""

subsys_list = []
subsys_status = True
status = True
self.log.info("RSCT Subsystem status check")
for subsystem in self.subsystems:
if not self.get_subsystem_status(subsystem):
self.log.debug("%s Subsystem is not active", subsystem)
subsys_status = False
status = False
subsys_list.append((subsystem, subsys_status))
else:
subsys_status = True
subsys_list.append((subsystem, subsys_status))

return ServiceCheck(self.check_rsct_subsystem_check.__doc__,
subsys_list, status)

def check_rsct_package_check(self):
"""RSCT package check"""

pkg_list = []
pkg_status = True
status = True
self.log.info("RSCT Package check")
for package in self.packages:
if not is_package_installed(package):
self.log.error("%s package is not installed", package)
status = False
pkg_status = False
pkg_list.append((package, pkg_status))
else:
pkg_status = True
pkg_list.append((package, pkg_status))

return PackageCheck(self.check_rsct_package_check.__doc__,
pkg_list, status)


def check_rsct_warning_check(self):
"""IBM Power Repo Package Check"""

status = True
power_repo_package = "ibm-power-repo"
self.log.info("ibm-power-repo Package check")
if not is_package_installed(power_repo_package):
self.log.error("ibm-power-repo package is not installed")
status = False

return PackageCheck(self.check_rsct_warning_check.__doc__,
power_repo_package, status)

0 comments on commit 1e11534

Please sign in to comment.