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 # 1.[App] Get Device ID print "Testing Get Device ID command" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_DEVICE_ID) if l_res[-1] != "0": l_msg = "IPMI: Get Device ID command failed" raise OpTestError(l_msg) # 2.[App] Get Device GUID print "Testing Get Device GUID" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_DEVICE_GUID) if l_res[-1] != "0": l_msg = "IPMI: Get Device GUID command failed" raise OpTestError(l_msg) # 3.[App] Get System GUID print "Testing Get system GUID" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_GUID) if l_res[-1] != "0": l_msg = "IPMI: Get System GUID command failed" raise OpTestError(l_msg) # 4.[Storage] Get SEL info print "Testing Get SEL info" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_INFO) if l_res[-1] != "0": l_msg = "IPMI: Get SEL info command failed" raise OpTestError(l_msg) # 5.[Storage] Get SEL time print "Testing Get SEL time" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME_RAW) if l_res[-1] != "0": l_msg = "IPMI: Get SEL time command failed" raise OpTestError(l_msg) # 6. [Storage] Reserve SEL print "Testing Reserve SEL" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_RESERVE_SEL) if l_res[-1] != "0": l_msg = "IPMI: Reserve SEL command failed" raise OpTestError(l_msg) # 7. [Storage] Set SEL time (required for RTC) print "Testing Set SEL time" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_SEL_TIME + " \'" + l_res[-1] + "\'; echo $?") if l_res[-1] != "0": l_msg = "IPMI: Set SEL time command failed" raise OpTestError(l_msg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME) # 8. [Transport] Get LAN parameters print "Testing Get LAN parameters" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_LAN_PARAMETERS) if l_res[-1] != "0": l_msg = "IPMI: Get LAN parameters command failed" raise OpTestError(l_msg) # 9.[Chassis] Get System Boot Options print "Testing Get System Boot Options" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_BOOT_OPTIONS) if l_res[-1] != "0": l_msg = "IPMI: Get System Boot Options command failed" raise OpTestError(l_msg) # 10.[Chassis] Set System Boot Options print "Testing Set System Boot Options" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_SYTEM_BOOT_OPTIONS) if l_res[-1] != "0": l_msg = "IPMI: Set System Boot Options command failed" raise OpTestError(l_msg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_BOOT_OPTIONS) # 11. [App] Get BMC Global Enables print "Testing Get BMC Global Enables" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES_RAW) if l_res[-1] != "0": l_msg = "IPMI: Get BMC Global Enables command failed" raise OpTestError(l_msg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES) # 12. [App] Set BMC Global Enables print "Testing Set BMC Global Enables" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_BMC_GLOBAL_ENABLES_SEL_OFF) if l_res[-1] != "0": l_msg = "IPMI: Set BMC Global Enables sel=off command failed" raise OpTestError(l_msg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_BMC_GLOBAL_ENABLES_SEL_ON) # 13.[App] Get System Interface Capabilities print "Testing Get System Interface Capabilities" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_INTERFACE_CAPABILITIES_SSIF) if l_res[-1] != "0": l_msg = "IPMI: Get System Interface Capabilities SSIF command failed" raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_INTERFACE_CAPABILITIES_KCS) if l_res[-1] != "0": l_msg = "IPMI: Get System Interface Capabilities KCS command failed" raise OpTestError(l_msg) # 14.[App] Get Message Flags print "Testing Get Message Flags" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_MESSAGE_FLAGS) if l_res[-1] != "0": l_msg = "IPMI: Get Message Flags command failed" raise OpTestError(l_msg) # 15. [App] Get BT Capabilities print "Testing Get BT Capabilities" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BT_CAPABILITIES) if l_res[-1] != "0": l_msg = "IPMI: Get BT Capabilities command failed" raise OpTestError(l_msg) # 16. [App] Clear Message Flags print "Testing Clear Message Flags" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_CLEAR_MESSAGE_FLAGS) if l_res[-1] != "0": l_msg = "IPMI: Clear Message Flags command failed" raise OpTestError(l_msg) # 17. [OEM] PNOR Access Status print "Testing the PNOR Access Status" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_DENY) if l_res[-1] != "0": l_msg = "IPMI: PNOR Access Status:deny command failed" raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_GRANT) if l_res[-1] != "0": l_msg = "IPMI: PNOR Access Status:grant command failed" raise OpTestError(l_msg) # 18. [Storage] Add SEL Entry print "Testing Add SEL Entry" print "Clearing the SEL list" self.cv_IPMI.ipmi_sdr_clear() l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_ADD_SEL_ENTRY) if l_res[-1] != "0": l_msg = "IPMI: Add SEL Entry command failed" raise OpTestError(l_msg) l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT) print "Checking for Reserved entry creation in SEL" if "Reserved" not in l_res: l_msg = "IPMI: Add SEL Entry command, doesn't create an SEL event" raise OpTestError(l_msg) # 19. [App] Set Power State print "Testing Set Power State" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_ACPI_POWER_STATE) if l_res[-1] != "0": l_msg = "IPMI: Set Power State command failed" raise OpTestError(l_msg) # 20. [App] Set watchdog print "Testing Set watchdog" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_WATCHDOG) if l_res[-1] != "0": l_msg = "IPMI: Set watchdog command failed" raise OpTestError(l_msg) self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_MC_WATCHDOG_GET) # 21. [Sensor/Event] Get Sensor Type print "Testing Get Sensor Type" l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_SDR_GET_WATCHDOG) matchObj = re.search( "Watchdog \((0x\d{1,})\)", l_res) if matchObj: print "Got sensor Id for watchdog: %s" % matchObj.group(1) else: l_msg = "Failed to get sensor id for watchdog sensor" raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SENSOR_TYPE_FOR_WATCHDOG + " " + matchObj.group(1) + " ;echo $?") if l_res[-1] != "0": l_msg = "IPMI: Get Sensor Type command failed" raise OpTestError(l_msg) # 22.[Sensor/Event] Get Sensor Reading print "Testing Get Sensor Reading" l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_SDR_GET_WATCHDOG) matchObj = re.search( "Watchdog \((0x\d{1,})\)", l_res) if matchObj: print "Got sensor Id for watchdog: %s" % matchObj.group(1) else: l_msg = "Failed to get sensor id for watchdog sensor" raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SENSOR_READING + " " + matchObj.group(1) + " ;echo $?") if l_res[-1] != "0": l_msg = "IPMI: Get Sensor Reading command failed" raise OpTestError(l_msg) # 23.[Sensor/Event] Platform Event (0x02) print "Testing Platform Event" self.cv_IPMI.ipmi_sdr_clear() l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PLATFORM_EVENT) if l_res[-1] != "0": l_msg = "IPMI: Platform Event command failed" raise OpTestError(l_msg) l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT) if "Reserved" not in l_res: l_msg = "IPMI: Platform Event command failed to log SEL event" raise OpTestError(l_msg) # 24. [OEM] PNOR Access Response (0x08) print "Testing PNOR Access Response" self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_GRANT) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_RESPONSE) if l_res[-1] != "0": l_msg = "IPMI: PNOR Access Response command failed" raise OpTestError(l_msg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_DENY) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_RESPONSE) if l_res[-1] != "0": l_msg = "IPMI: PNOR Access Response command failed" raise OpTestError(l_msg) # 25.[Chassis] Chassis Control print "Testing chassis power on" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_CHASSIS_POWER_ON) if l_res[-1] != "0": l_msg = "IPMI: chassis power on command failed" raise OpTestError(l_msg) # 26.[App] 0x38 Get Channel Authentication Cap print "Testing Get Channel Authentication Capabilities" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_CHANNEL_AUTH_CAP) if l_res[-1] != "0": l_msg = "IPMI: Get Channel Authentication Capabilities command failed" raise OpTestError(l_msg) # 27.[App] Reset Watchdog (0x22) print "Testing reset watchdog" self.cv_IPMI.ipmi_sdr_clear() l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_RESET_WATCHDOG) if l_res[-1] != "0": l_msg = "IPMI: Reset Watchdog command failed" raise OpTestError(l_msg) time.sleep(10) # Reset watchdog should create a SEL event log l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT) if "Watchdog" not in l_res: l_msg = "IPMI: Reset Watchdog command, doesn't create an SEL event" raise OpTestError(l_msg) # 28. [App] Get ACPI Power State (0x06) print "Testing Get ACPI Power State" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_ACPI_POWER_STATE) if l_res[-1] != "0": l_msg = "IPMI: Get ACPI Power State command failed" raise OpTestError(l_msg)
class OpTestHMIHandling: ## 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 is a common function for all the hmi test cases. This will be executed before # any test case starts. Basically this provides below requirements. # 1. Validates all required lpar commands # 2. It will clone skiboot source repository # 3. Compile the necessary tools xscom-utils and gard utility to test HMI. # 4. Get the list Of Chips and cores in the form of dictionary. # Ex: [['00000000', ['4', '5', '6', 'c', 'd', 'e']], ['00000001', ['4', '5', '6', 'c', 'd', 'e']], ['00000010', ['4', '5', '6', 'c', 'd', 'e']]] # 5. In-order to inject HMI errors on cpu's, cpu should be running, # so disabling the sleep states 1 and 2 of all CPU's. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_init(self): # Get OS level self.cv_LPAR.lpar_get_OS_Level() # Check whether git and gcc commands are available on lpar self.cv_LPAR.lpar_check_command("git") self.cv_LPAR.lpar_check_command("gcc") # It will clone skiboot source repository l_dir = "/tmp/skiboot" self.cv_LPAR.lpar_clone_skiboot_source(l_dir) # Compile the necessary tools xscom-utils and gard utility self.cv_LPAR.lpar_compile_xscom_utilities(l_dir) self.cv_LPAR.lpar_compile_gard_utility(l_dir) # Getting list of processor chip Id's(executing getscom -l to get chip id's) l_res = self.cv_LPAR.lpar_run_command("cd %s/external/xscom-utils/; ./getscom -l" % l_dir) l_res = l_res.splitlines() l_chips = [] for line in l_res: matchObj = re.search("(\d{8}).*processor", line) if matchObj: l_chips.append(matchObj.group(1)) if not l_chips: l_msg = "Getscom failed to list processor chip id's" raise OpTestError(l_msg) l_chips.sort() print l_chips # ['00000000', '00000001', '00000010'] # Currently getting the list of active core id's with respect to each chip is by using opal msg log # TODO: Need to identify best way to get list of cores(If Opal msg log is empty) l_cmd = "cat /sys/firmware/opal/msglog | grep -i CHIP" l_res = self.cv_LPAR.lpar_run_command(l_cmd) l_cores = {} self.l_dic = [] l_res = l_res.splitlines() for line in l_res: matchObj = re.search("Chip (\d{1,2}) Core ([a-z0-9])", line) if matchObj: if l_cores.has_key(int(matchObj.group(1))): (l_cores[int(matchObj.group(1))]).append(matchObj.group(2)) else: l_cores[int(matchObj.group(1))] = list(matchObj.group(2)) if not l_cores: l_msg = "Failed in getting core id's information from OPAL msg log" raise OpTestError(l_msg) print l_cores # {0: ['4', '5', '6', 'c', 'd', 'e'], 1: ['4', '5', '6', 'c', 'd', 'e'], 10: ['4', '5', '6', 'c', 'd', 'e']} l_cores = sorted(l_cores.iteritems()) print l_cores i = 0 for tup in l_cores: new_list = [l_chips[i], tup[1]] self.l_dic.append(new_list) i += 1 print self.l_dic # self.l_dic is a list of chip id's, core id's . and is of below format # [['00000000', ['4', '5', '6', 'c', 'd', 'e']], ['00000001', ['4', '5', '6', 'c', 'd', 'e']], ['00000010', ['4', '5', '6', 'c', 'd', 'e']]] self.l_dir = l_dir # In-order to inject HMI errors on cpu's, cpu should be running, so disabling the sleep states 1 and 2 of all CPU's self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE2) self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE1) self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE0) self.cv_LPAR.lpar_run_command(BMC_CONST.DISABLE_CPU_SLEEP_STATE1) self.cv_LPAR.lpar_run_command(BMC_CONST.DISABLE_CPU_SLEEP_STATE2) self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE2) self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE1) self.cv_LPAR.lpar_run_command(BMC_CONST.GET_CPU_SLEEP_STATE0) ## # @brief This function is mainly used to clear hardware gard entries. # It will perform below steps # 1. Reboot the system(Power off/on) # 2. Clear any Hardware gard entries # 3. Again reboot the system, to make use of garded Hardware. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def clearGardEntries(self): # Power off and on the system. self.cv_IPMI.ipmi_power_off() self.cv_IPMI.ipmi_power_on() if int(self.cv_SYSTEM.sys_ipl_wait_for_working_state()): l_msg = "System failed to boot host OS" raise OpTestError(l_msg) time.sleep(BMC_CONST.LPAR_BRINGUP_TIME) # Clearing gard entries after lpar comes up self.cv_LPAR.lpar_get_OS_Level() 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") l_dir = "/tmp/skiboot" self.cv_IPMI.run_lpar_cmd_on_ipmi_console("cd %s/external/gard/;" % l_dir) l_cmd = "./gard list; echo $?" self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) l_cmd = "./gard clear all; echo $?" l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if int(l_res[-1]): l_msg = "Clearing gard entries through gard tool is failed" raise OpTestError(l_msg) l_cmd = "./gard list; echo $?" self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) # Rebooting the system again to make use of garded hardware self.cv_IPMI.ipmi_power_off() self.cv_IPMI.ipmi_power_on() if int(self.cv_SYSTEM.sys_ipl_wait_for_working_state()): l_msg = "System failed to boot host OS" raise OpTestError(l_msg) time.sleep(BMC_CONST.LPAR_BRINGUP_TIME) self.cv_LPAR.lpar_get_OS_Level() self.cv_SYSTEM.sys_ipmi_close_console(l_con) ## # @brief This function executes HMI test case based on the i_test value, Before test starts # disabling kdump service to make sure system reboots, after injecting non-recoverable errors. # # @param i_test @type int: this is the type of test case want to execute # BMC_CONST.HMI_PROC_RECV_DONE: Processor recovery done # BMC_CONST.HMI_PROC_RECV_ERROR_MASKED: proc_recv_error_masked # BMC_CONST.HMI_MALFUNCTION_ALERT: malfunction_alert # BMC_CONST.HMI_HYPERVISOR_RESOURCE_ERROR: hypervisor resource error # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def testHMIHandling(self, i_test): l_test = i_test self.test_init() 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") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("cat /etc/os-release") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("service kdump status") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("service kdump stop") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("service kdump status") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("cd %s/external/xscom-utils/;" % self.l_dir) self.cv_IPMI.run_lpar_cmd_on_ipmi_console("lscpu") self.cv_IPMI.run_lpar_cmd_on_ipmi_console("dmesg -D") if l_test == BMC_CONST.HMI_PROC_RECV_DONE: self.test_proc_recv_done() elif l_test == BMC_CONST.HMI_PROC_RECV_ERROR_MASKED: self.test_proc_recv_error_masked() elif l_test == BMC_CONST.HMI_MALFUNCTION_ALERT: self.test_malfunction_allert() elif l_test == BMC_CONST.HMI_HYPERVISOR_RESOURCE_ERROR: self.test_hyp_resource_err() else: l_msg = "Please provide valid test case" raise OpTestError(l_msg) self.cv_SYSTEM.sys_ipmi_close_console(l_con) return BMC_CONST.FW_SUCCESS ## # @brief This function is used to test HMI: processor recovery done # and also this function injecting error on all the cpus one by one and # verify whether cpu is recovered or not. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_proc_recv_done(self): for l_pair in self.l_dic: l_chip = l_pair[0] for l_core in l_pair[1]: l_reg = "1%s013100" % l_core l_cmd = "./putscom -c %s %s 0000000000100000; echo $?" % (l_chip, l_reg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console("dmesg -C") time.sleep(10) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) time.sleep(10) if l_res[-1] == "0": print "Injected thread hang recoverable error" else: if any("Kernel panic - not syncing" in line for line in l_res): l_msg = "Processor recovery failed: Kernel got panic" elif any("Petitboot" in line for line in l_res): l_msg = "System reached petitboot:Processor recovery failed" elif any("ISTEP" in line for line in l_res): l_msg = "System started booting: Processor recovery failed" else: l_msg = "Failed to inject thread hang recoverable error" print l_msg raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console("dmesg") if any("Processor Recovery done" in line for line in l_res) and any( "Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res ): print "Processor recovery done" else: l_msg = "HMI handling failed to log message: for proc_recv_done" raise OpTestError(l_msg) time.sleep(BMC_CONST.HMI_TEST_CASE_SLEEP_TIME) return BMC_CONST.FW_SUCCESS ## # @brief This function is used to test HMI: proc_recv_error_masked # Processor went through recovery for an error which is actually masked for reporting # this function also injecting the error on all the cpu's one-by-one. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_proc_recv_error_masked(self): for l_pair in self.l_dic: l_chip = l_pair[0] for l_core in l_pair[1]: l_reg = "1%s013100" % l_core l_cmd = "./putscom -c %s %s 0000000000080000; echo $?" % (l_chip, l_reg) self.cv_IPMI.run_lpar_cmd_on_ipmi_console("dmesg -C") time.sleep(10) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) time.sleep(10) if l_res[-1] == "0": print "Injected thread hang recoverable error" else: if any("Kernel panic - not syncing" in line for line in l_res): l_msg = "Processor recovery failed: Kernel got panic" elif any("Petitboot" in line for line in l_res): l_msg = "System reached petitboot:Processor recovery failed" elif any("ISTEP" in line for line in l_res): l_msg = "System started booting: Processor recovery failed" else: l_msg = "Failed to inject thread hang recoverable error" print l_msg raise OpTestError(l_msg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console("dmesg") if any("Processor Recovery done" in line for line in l_res) and any( "Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res ): print "Processor recovery done" else: l_msg = "HMI handling failed to log message" raise OpTestError(l_msg) time.sleep(BMC_CONST.HMI_TEST_CASE_SLEEP_TIME) return BMC_CONST.FW_SUCCESS ## # @brief This function is used to test hmi malfunction alert:Core checkstop # A processor core in the system has to be checkstopped (failed recovery). # Injecting core checkstop on random core of random chip # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_malfunction_allert(self): # Get random pair of chip vs cores l_pair = random.choice(self.l_dic) # Get random chip id l_chip = l_pair[0] # Get random core number l_core = random.choice(l_pair[1]) l_reg = "1%s013100" % l_core l_cmd = "./putscom -c %s %s 1000000000000000" % (l_chip, l_reg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if any("Kernel panic - not syncing" in line for line in l_res): print "Malfunction alert: kernel got panic" elif any("login:"******"System booted to host OS without any kernel panic message" elif any("Petitboot" in line for line in l_res): print "System reached petitboot without any kernel panic message" elif any("ISTEP" in line for line in l_res): print "System started booting without any kernel panic message" else: l_msg = "HMI: Malfunction alert failed" raise OpTestError(l_msg) return BMC_CONST.FW_SUCCESS ## # @brief This function is used to test HMI: Hypervisor resource error # Injecting Hypervisor resource error on random core of random chip # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_hyp_resource_err(self): # Get random pair of chip vs cores l_pair = random.choice(self.l_dic) # Get random chip id l_chip = l_pair[0] # Get random core number l_core = random.choice(l_pair[1]) l_reg = "1%s013100" % l_core l_cmd = "./putscom -c %s %s 0000000000008000" % (l_chip, l_reg) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if any("Kernel panic - not syncing" in line for line in l_res) and any( "Hypervisor Resource error - core check stop" in line for line in l_res ): print "Hypervisor resource error: kernel got panic" elif any("login:"******"System booted to host OS without any kernel panic message" elif any("Petitboot" in line for line in l_res): print "System reached petitboot without any kernel panic message" elif any("ISTEP" in line for line in l_res): print "System started booting without any kernel panic message" else: l_msg = "HMI: Hypervisor resource error failed" raise OpTestError(l_msg) return BMC_CONST.FW_SUCCESS
class OpTestPrdDriver(): ## 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 performs below steps # 1. Initially connecting to lpar and ipmi consoles for execution. # 2. check for IPOLL mask register value to see whether opal-prd is running or not # if it is 0-->opal-prd is running-->continue # else start opal-prd service again # 3. call test_prd_for_fir() function for each core FIR error and this function # can be used for any number of errors, like it is a generic function # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def testPrdDriver(self): self.test_init() 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("cd %s/external/xscom-utils/;" % BMC_CONST.CLONE_SKIBOOT_DIR) # check for IPOLL mask register value to check opal-prd is running or not l_cmd = "./getscom -c 0x0 %s" % BMC_CONST.IPOLL_MASK_REGISTER l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if l_res[-1] == "0": print "Opal-prd is running" else: self.cv_IPMI.run_lpar_cmd_on_ipmi_console("service opal-prd start") l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if l_res[-1] == "0": print "Opal-prd is running" else: l_msg = "IPOLL MASK REGISTER is not getting cleared by opal-prd" raise OpTestError(l_msg) # test for PBA FIR with different core errors # 1.PBAFIR_OCI_APAR_ERR-->OCI Address Parity Error self.test_prd_for_fir(BMC_CONST.PBA_FAULT_ISOLATION_REGISTER, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, BMC_CONST.PBAFIR_OCI_APAR_ERR) # 2.PBAFIR_PB_CE_FW-->PB Read Data CE Error for Forwarded Request self.test_prd_for_fir(BMC_CONST.PBA_FAULT_ISOLATION_REGISTER, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, BMC_CONST.PBAFIR_PB_CE_FW) # 3.PBAFIR_PB_RDDATATO_FW-->PB Read Data Timeout for Forwarded Request self.test_prd_for_fir(BMC_CONST.PBA_FAULT_ISOLATION_REGISTER, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, BMC_CONST.PBAFIR_PB_RDDATATO_FW) # 4.PBAFIR_PB_RDADRERR_FW-->PB CRESP Addr Error Received for Forwarded Read Request self.test_prd_for_fir(BMC_CONST.PBA_FAULT_ISOLATION_REGISTER, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, BMC_CONST.PBAFIR_PB_RDADRERR_FW) return BMC_CONST.FW_SUCCESS ## # @brief This function injects some core FIR errors and verifies whether opal-prd clears the errors. # and also this function injects errors on random chip. # # @param FIR @type str: Local Fault Isolation register # @param FIMR @type str: Local Fault Isolation mask register # @param ERROR @type int: Core FIR error, this error will be written to FIR. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_prd_for_fir(self, FIR, FIMR, ERROR): chip_id = "0x" + self.random_chip print chip_id print "OPAL-PRD: Injecting error 0x%x on FIR: %s" % (ERROR, FIR) # Read Local Fault Isolation register l_cmd = "./getscom -c %s %s" % (chip_id, FIR) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) # Reading Local Fault Isolation mask register l_cmd = "./getscom -c %s %s" % (chip_id, FIMR) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) print l_res # Changing the FIMR value to un-masked value. LEN = 16 l_len = len(l_res[-1]) l_val = hex(int(("0x" + "0"*(LEN - l_len) + l_res[-1]), 16)& (ERROR ^ 0xffffffffffffffff)) # Writing the same value to Local Fault Isolation mask register again l_cmd = "./putscom -c %s %s %s" % (chip_id, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, l_val) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) # Inject a core error on FIR l_cmd = "./putscom -c %s %s %s" % (chip_id, FIR, hex(ERROR)) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) time.sleep(30) # Read Local Fault Isolation register again l_cmd = "./getscom -c %s %s" % (chip_id, FIR) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) print l_res # Check FIR got cleared by opal-prd if l_res[-1] == "0": print "Opal-prd handles core hardware error" else: l_msg = "Opal-prd not clearing hardware errors in runtime" print l_msg raise OpTestError(l_msg) # Reading the Local Fault Isolation Mask Register again l_cmd = "./getscom -c %s %s" % (chip_id, FIMR) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) print l_res # check for IPOLL mask register value to see opal-prd cleared the value l_cmd = "./getscom -c %s %s" % (chip_id, BMC_CONST.IPOLL_MASK_REGISTER) l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(l_cmd) if l_res[-1] == "0": print "Opal-prd cleared the IPOLL MASK REGISTER" return BMC_CONST.FW_SUCCESS else: l_msg = "Opal-prd is not clearing the IPOLL MASK REGISTER after injecting core FIR error" print l_msg raise OpTestError(l_msg) ## # @brief This is a common function for all the PRD test cases. This will be executed before # any test case starts. Basically this provides below requirements. # 1. Validates all required lpar commands # 2. It will clone skiboot source repository # 3. Compile the necessary tools -xscom-utils(getscom and putscom) # 4. Get the list Of Chips. # Ex: ['00000000', '00000001', '00000010'] # 5. generate a random chip. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_init(self): # Get OS level self.cv_LPAR.lpar_get_OS_Level() # Check whether git and gcc commands are available on lpar self.cv_LPAR.lpar_check_command("git") self.cv_LPAR.lpar_check_command("gcc") # It will clone skiboot source repository self.cv_LPAR.lpar_clone_skiboot_source(BMC_CONST.CLONE_SKIBOOT_DIR) # Compile the necessary tools xscom-utils and gard utility self.cv_LPAR.lpar_compile_xscom_utilities(BMC_CONST.CLONE_SKIBOOT_DIR) # Getting list of processor chip Id's(executing getscom -l to get chip id's) l_res = self.cv_LPAR.lpar_run_command("cd %s/external/xscom-utils/; ./getscom -l" % BMC_CONST.CLONE_SKIBOOT_DIR) l_res = l_res.splitlines() l_chips = [] for line in l_res: matchObj = re.search("(\d{8}).*processor", line) if matchObj: l_chips.append(matchObj.group(1)) if not l_chips: l_msg = "Getscom failed to list processor chip id's" raise OpTestError(l_msg) l_chips.sort() print l_chips # ['00000000', '00000001', '00000010'] self.random_chip = random.choice(l_chips) # Below will be useful for debug purposes to compare chip information l_res = self.cv_LPAR.lpar_read_msglog_core() print l_res