-
Notifications
You must be signed in to change notification settings - Fork 13
Add RSCT validity check in ServiceReport tool #11
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# 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.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 self.get_subsystem_status(subsystem) == 0: | ||
self.log.debug("%s Subsystem is not active", subsystem) | ||
subsys_status = False | ||
status = False | ||
subsys_list.append((subsystem, subsys_status)) | ||
else: | ||
subsys_status = True | ||
|
||
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 | ||
|
||
return PackageCheck(self.check_rsct_package_check.__doc__, | ||
pkg_list, status) | ||
|
||
def check_rsct_ibm_power_repo_package_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_ibm_power_repo_package_check.__doc__, | ||
power_repo_package, status) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will you need installation path /opt/rsct/bin in the repair plugin?
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.
yes. In repair, with plugin_obj.check_rsct_installation_path() ...I am checking the installation path.