-
Notifications
You must be signed in to change notification settings - Fork 13
Add RSCT Validate/Repair check in ServiceReport tool #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 <s1seetee@linux.vnet.ibm.com> | ||
|
|
||
| """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") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's have a variable to store the above string. |
||
| 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) | ||
| 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 <s1seetee@linux.vnet.ibm.com> | ||
|
|
||
| """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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope that no changes are required if this plugin is executed on different distributions. |
||
| """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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding rsct in the function makes it more meaning full. |
||
| """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)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's have only one subsys_list.append call. Take it out from if and else. The same goes for the RSCT package check. |
||
|
|
||
| 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""" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming the function to a name that is more closely associated with the package check it is performing, as the current function name does not align with its intended purpose. |
||
|
|
||
| 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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding RSCT full form at least once in the plugin and commit message.