本文整理汇总了Python中common.OpTestIPMI.OpTestIPMI.ipmitool_execute_command方法的典型用法代码示例。如果您正苦于以下问题:Python OpTestIPMI.ipmitool_execute_command方法的具体用法?Python OpTestIPMI.ipmitool_execute_command怎么用?Python OpTestIPMI.ipmitool_execute_command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.OpTestIPMI.OpTestIPMI
的用法示例。
在下文中一共展示了OpTestIPMI.ipmitool_execute_command方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OpTestOOBIPMI
# 需要导入模块: from common.OpTestIPMI import OpTestIPMI [as 别名]
# 或者: from common.OpTestIPMI.OpTestIPMI import ipmitool_execute_command [as 别名]
#.........这里部分代码省略.........
if "OEM" in l_output:
print "IPMI: Enabling of fan control creates an OEM SEL event"
return BMC_CONST.FW_SUCCESS
else:
l_msg = "IPMI: Enabling of fan control doesn't create an OEM SEL event"
raise OpTestError(l_msg)
else:
l_msg = "IPMI: Fan control thread still in not running state, enable failed"
raise OpTestError(l_msg)
else:
l_msg = "IPMI: Fan control thread still running, disable failed"
raise OpTestError(l_msg)
##
# @brief It will check basic channel functionalities: info and authentication capabilities.
#
# @return l_res @type list: output of command or raise OpTestError
#
@staticmethod
def test_channel(self):
print "OOB IPMI: Channel Tests"
self.run_ipmi_cmd(BMC_CONST.IPMI_CHANNEL_AUTHCAP)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHANNEL_INFO)
##
# @brief It will execute and test the return code of ipmi command.
#
# @param i_cmd @type string:The ipmitool command, for example: chassis power on; echo $?
#
# @return l_res @type list: output of command or raise OpTestError
#
def run_ipmi_cmd(self, i_cmd):
l_cmd = i_cmd
l_res = self.cv_IPMI.ipmitool_execute_command(l_cmd)
print l_res
l_res = l_res.splitlines()
if int(l_res[-1]):
l_msg = "IPMI: command failed %c" % l_cmd
raise OpTestError(l_msg)
return l_res
##
# @brief It will execute and test the ipmi chassis <cmd> commands
# cmd: status, poh, restart_cause, policy list and policy set
#
# @return l_res @type list: output of command or raise OpTestError
#
@staticmethod
def test_chassis(self):
print "OOB IPMI: Chassis tests"
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_STATUS)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POH)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_RESTART_CAUSE)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POLICY_LIST)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POLICY_ALWAYS_OFF)
##
# @brief It will execute and test the ipmi chassis identify commands
#
# @return l_res @type list: output of command or raise OpTestError
#
@staticmethod
def test_chassisIdentifytests(self):
print "OOB IPMI: chassis identify tests"
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY_5)
示例2: OpTestEnergyScale
# 需要导入模块: from common.OpTestIPMI import OpTestIPMI [as 别名]
# 或者: from common.OpTestIPMI.OpTestIPMI import ipmitool_execute_command [as 别名]
#.........这里部分代码省略.........
print "System is in standby/Soft-off state"
else:
l_msg = "System failed to reach standby/Soft-off state"
raise OpTestError(l_msg)
print "Performing a IPMI Power ON Operation"
# Perform a IPMI Power ON Operation
self.cv_IPMI.ipmi_power_on()
self.cv_SYSTEM.sys_check_host_status()
self.util.PingFunc(self.cv_HOST.ip, BMC_CONST.PING_RETRY_POWERCYCLE)
l_status = self.cv_IPMI.ipmi_get_occ_status()
print l_status
if BMC_CONST.OCC_DEVICE_ENABLED in l_status:
print "OCC's are up and active"
else:
l_msg = "OCC's are not in active state"
raise OpTestError(l_msg)
print "Get All dcmi readings at runtime"
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_DISCOVER)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_GET_LIMIT)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_SENSORS)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_MC_ID_STRING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_TEMP_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_CONF_PARAM)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_OOB_DISCOVER)
##
# @brief This function will test below dcmi commands at both standby and runtime states
# ipmitool dcmi discover :This command is used to discover
# supported capabilities in DCMI.
# ipmitool dcmi power reading :Get power related readings from the system.
# ipmitool dcmi power get_limit :Get the configured power limits.
# ipmitool dcmi power sensors :Prints the available DCMI sensors.
# ipmitool dcmi get_temp_reading :Get Temperature Sensor Readings.
# ipmitool dcmi get_mc_id_string :Get management controller identifier string.
# ipmitool dcmi get_conf_param :Get DCMI Configuration Parameters.
# ipmitool dcmi oob_discover :Ping/Pong Message for DCMI Discovery.
#
# @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
#
def test_dcmi_at_standby_and_runtime_states(self):
self.cv_SYSTEM.sys_bmc_power_on_validate_host()
print "Energy scale Test 3: Get Sensors, Temperature and Power reading's at power off and runtime"
print "Performing a IPMI Power OFF Operation"
# Perform a IPMI Power OFF Operation(Immediate Shutdown)
self.cv_IPMI.ipmi_power_off()
if int(self.cv_SYSTEM.sys_wait_for_standby_state(BMC_CONST.SYSTEM_STANDBY_STATE_DELAY)) == 0:
print "System is in standby/Soft-off state"
else:
l_msg = "System failed to reach standby/Soft-off state"
raise OpTestError(l_msg)
print "Get All dcmi readings at power off"
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_DISCOVER)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_GET_LIMIT)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_SENSORS)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_MC_ID_STRING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_TEMP_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_CONF_PARAM)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_OOB_DISCOVER)
print "Performing a IPMI Power ON Operation"
# Perform a IPMI Power ON Operation
self.cv_IPMI.ipmi_power_on()
self.cv_SYSTEM.sys_check_host_status()
self.util.PingFunc(self.cv_HOST.ip, BMC_CONST.PING_RETRY_POWERCYCLE)
l_status = self.cv_IPMI.ipmi_get_occ_status()
print l_status
if BMC_CONST.OCC_DEVICE_ENABLED in l_status:
print "OCC's are up and active"
else:
l_msg = "OCC's are not in active state"
raise OpTestError(l_msg)
print "Get All dcmi readings at runtime"
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_DISCOVER)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_POWER_GET_LIMIT)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_SENSORS)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_MC_ID_STRING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_TEMP_READING)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_GET_CONF_PARAM)
self.run_ipmi_cmd(BMC_CONST.IPMI_DCMI_OOB_DISCOVER)
##
# @brief It will execute and test the return code of ipmi command.
#
# @param i_cmd @type string:The ipmitool command, for example: chassis power on; echo $?
#
# @return l_res @type list: output of command or raise OpTestError
#
def run_ipmi_cmd(self, i_cmd):
l_cmd = i_cmd
l_res = self.cv_IPMI.ipmitool_execute_command(l_cmd)
print l_res
l_res = l_res.splitlines()
if int(l_res[-1]):
l_msg = "IPMI: command failed %c" % l_cmd
raise OpTestError(l_msg)
return l_res
示例3: OpTestIPMILockMode
# 需要导入模块: from common.OpTestIPMI import OpTestIPMI [as 别名]
# 或者: from common.OpTestIPMI.OpTestIPMI import ipmitool_execute_command [as 别名]
class OpTestIPMILockMode():
## Initialize this object
# @param i_bmcIP The IP address of the BMC
# @param i_bmcUser The userid to log into the BMC with
# @param i_bmcPasswd The password of the userid to log into the BMC with
# @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
# @param i_bmcPasswdIpmi The password of BMC IPMI userid
# @param i_ffdcDir Optional param to indicate where to write FFDC
#
# "Only required for inband tests" else Default = None
# @param i_lparIP The IP address of the LPAR
# @param i_lparuser The userid to log into the LPAR
# @param i_lparPasswd The password of the userid to log into the LPAR with
#
def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_lparip=None,
i_lparuser=None, i_lparPasswd=None):
self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi,
i_ffdcDir, i_lparip, i_lparuser, i_lparPasswd)
self.cv_LPAR = OpTestLpar(i_lparip, i_lparuser, i_lparPasswd, i_bmcIP)
self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_lparip,
i_lparuser, i_lparPasswd)
self.util = OpTestUtil()
##
# @brief This function will cover following test steps
# 1. It will get the OS level installed on power platform
# 2. It will check for kernel version installed on the Open Power Machine
# 3. It will check for ipmitool command existence and ipmitool package
# 4. Load the necessary ipmi modules based on config values
# 5. Issue a ipmi lock command through out-of-band authenticated interface
# 6. Now BMC IPMI is in locked mode, at this point only white listed
# in-band ipmi commands sholud work(No other in-band ipmi command should work)
# 7. Execute and test the functionality of whitelisted in-band ipmi
# commands in locked mode
# 8. At the end of test issue a ipmi unlock command to revert the availablity of all
# in-band ipmi commands in unlocked mode.
#
# @return BMC_CONST.FW_SUCCESS or raise OpTestError
#
def test_ipmi_lock_mode(self):
# Get OS level
l_oslevel = self.cv_LPAR.lpar_get_OS_Level()
# Get kernel version
l_kernel = self.cv_LPAR.lpar_get_kernel_version()
# Checking for ipmitool command and lm_sensors package
self.cv_LPAR.lpar_check_command("ipmitool")
l_pkg = self.cv_LPAR.lpar_check_pkg_for_utility(l_oslevel, "ipmitool")
print "Installed package: %s" % l_pkg
# loading below ipmi modules based on config option
# ipmi_devintf, ipmi_powernv and ipmi_masghandler
self.cv_LPAR.lpar_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_DEVICE_INTERFACE,
BMC_CONST.IPMI_DEV_INTF)
self.cv_LPAR.lpar_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_POWERNV,
BMC_CONST.IPMI_POWERNV)
self.cv_LPAR.lpar_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_HANDLER,
BMC_CONST.IPMI_MSG_HANDLER)
# Issue a ipmi lock command through authenticated interface
print "Issuing ipmi lock command through authenticated interface"
l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LOCK_CMD)
l_res = l_res.splitlines()
if int(l_res[-1]):
l_msg = "IPMI:Lock command failed, There may be two reasons here.\n\
a. check the corresponding parches available in AMI driver code,\n\
b. if patches available then command is failing"
print l_msg
raise OpTestError(l_msg)
print "IPMI:Lock command executed successfully"
try:
self.run_inband_ipmi_whitelisted_cmds()
except:
l_msg = "One of white listed in-band ipmi command execution failed"
print sys.exc_info()
finally:
# Issue a ipmi unlock command at the end of test.
print "Issuing ipmi unlock command through authenticated interface"
self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_UNLOCK_CMD)
##
# @brief This function will execute whitelisted in-band ipmi commands
# and test the functionality in locked mode.
#
# @return BMC_CONST.FW_SUCCESS or raise OpTestError
#
def run_inband_ipmi_whitelisted_cmds(self):
l_con = self.cv_SYSTEM.sys_get_ipmi_console()
self.cv_IPMI.ipmi_lpar_login(l_con)
self.cv_IPMI.ipmi_lpar_set_unique_prompt(l_con)
self.cv_IPMI.run_lpar_cmd_on_ipmi_console("uname -a")
# Test IPMI white listed commands those should be allowed through un-authenticated
# in-band interface
#.........这里部分代码省略.........
示例4: OpTestOOBIPMI
# 需要导入模块: from common.OpTestIPMI import OpTestIPMI [as 别名]
# 或者: from common.OpTestIPMI.OpTestIPMI import ipmitool_execute_command [as 别名]
#.........这里部分代码省略.........
print "OOB IPMI: dcmi tests"
self.test_dcmi()
print "OOB IPMI: echo tests"
self.test_echo()
print "OOB IPMI: event tests"
self.test_event()
print "OOB IPMI: Firewall test"
self.test_firewall()
print "OOB IPMI: Pef tests"
self.test_pef()
print "OOB IPMI: raw command execution tests"
self.test_raw()
print "OOB IPMI: exec tests"
self.test_exec()
##
# @brief It will check basic channel functionalities: info and authentication capabilities.
#
# @return l_res @type list: output of command or raise OpTestError
#
def test_channel(self):
self.run_ipmi_cmd(BMC_CONST.IPMI_CHANNEL_AUTHCAP)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHANNEL_INFO)
##
# @brief It will execute and test the return code of ipmi command.
#
# @param i_cmd @type string:The ipmitool command, for example: chassis power on; echo $?
#
# @return l_res @type list: output of command or raise OpTestError
#
def run_ipmi_cmd(self, i_cmd):
l_cmd = i_cmd
l_res = self.cv_IPMI.ipmitool_execute_command(l_cmd)
print l_res
l_res = l_res.splitlines()
if int(l_res[-1]):
l_msg = "IPMI: command failed %c" % l_cmd
raise OpTestError(l_msg)
return l_res
##
# @brief It will execute and test the ipmi chassis <cmd> commands
# cmd: status, poh, restart_cause, policy list and policy set
#
# @return l_res @type list: output of command or raise OpTestError
#
def test_chassis(self):
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_STATUS)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POH)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_RESTART_CAUSE)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POLICY_LIST)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_POLICY_ALWAYS_OFF)
##
# @brief It will execute and test the ipmi chassis identify commands
#
# @return l_res @type list: output of command or raise OpTestError
#
def test_chassisIdentifytests(self):
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY_5)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY_FORCE)
self.run_ipmi_cmd(BMC_CONST.IPMI_CHASSIS_IDENTIFY)