Files
test/keywords/bmc/ipmitool/is_ipmitool_keywords.py
Abhishek jaiswal 7db1cdf885 fixed incorrect "No command provided!" in ipmitool
The check for "No command provided!" in ipmitool output was failing due
to the output being a list with newline characters. This commit adjusts
the check to:
- Confirm the output list is not empty.
- Use `strip()` to compare the first list element against "No command provided!".
- DOC109 there are no type hints in the docstring arg list
- DOC110 not all args in the docstring arg list have type hints
- DOC105 type hints in these args do not match: ssh_connection

Change-Id: Ifee7b85042863c83dd4c825577d3ee342e6d3ef1
Signed-off-by: Abhishek jaiswal <abhishek.jaiswal@windriver.com>
2025-03-21 07:03:21 -04:00

34 lines
1.0 KiB
Python

from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword
class IsIPMIToolKeywords(BaseKeyword):
"""
Class that checks if IPMI Tools are available on the system.
"""
def __init__(self, ssh_connection: SSHConnection):
"""Constructor
Args:
ssh_connection (SSHConnection): SSH connection object.
"""
self.ssh_connection = ssh_connection
def is_ipmi_tool_available(self) -> bool:
"""
This function will check if ipmi tool is available on the system.
Args: none.
Returns: True if the ipmi tool is available, false otherwise.
"""
output = self.ssh_connection.send_as_sudo("ipmitool")
if len(output) > 1 and output[0].strip() == "No command provided!":
return True
# Output is either "ipmitool: command not found" or, if sudo isn't used:
# "Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory"
return False