1*** Settings *** 2 3Documentation Module to test IPMI chassis functionality. 4Resource ../lib/ipmi_client.robot 5Resource ../lib/openbmc_ffdc.robot 6Resource ../lib/boot_utils.robot 7Library ../lib/ipmi_utils.py 8Variables ../data/ipmi_raw_cmd_table.py 9 10Suite Setup Redfish.Login 11Suite Teardown Redfish.Logout 12Test Teardown Test Teardown Execution 13 14 15*** Test Cases *** 16 17IPMI Chassis Status On 18 [Documentation] This test case verfies system power on status 19 ... using IPMI Get Chassis status command. 20 [Tags] IPMI_Chassis_Status_On 21 22 Redfish Power On stack_mode=skip quiet=1 23 ${resp}= Run IPMI Standard Command chassis status 24 ${power_status}= Get Lines Containing String ${resp} System Power 25 Should Contain ${power_status} on 26 27IPMI Chassis Status Off 28 [Documentation] This test case verfies system power off status 29 ... using IPMI Get Chassis status command. 30 [Tags] IPMI_Chassis_Status_Off 31 32 Redfish Power Off stack_mode=skip quiet=1 33 ${resp}= Run IPMI Standard Command chassis status 34 ${power_status}= Get Lines Containing String ${resp} System Power 35 Should Contain ${power_status} off 36 37Verify Host PowerOff Via IPMI 38 [Documentation] Verify host power off operation using external IPMI command. 39 [Tags] Verify_Host_PowerOff_Via_IPMI 40 41 IPMI Power Off 42 ${ipmi_state}= Get Host State Via External IPMI 43 Valid Value ipmi_state ['off'] 44 45Verify Host PowerOn Via IPMI 46 [Documentation] Verify host power on operation using external IPMI command. 47 [Tags] Verify_Host_PowerOn_Via_IPMI 48 49 IPMI Power On 50 ${ipmi_state}= Get Host State Via External IPMI 51 Valid Value ipmi_state ['on'] 52 53 54Verify Soft Shutdown 55 [Documentation] Verify host OS shutdown softly via IPMI command. 56 [Tags] Verify_Soft_Shutdown 57 58 Redfish Power On stack_mode=skip 59 Run IPMI Standard Command chassis power soft 60 Wait Until Keyword Succeeds 3 min 10 sec Is Host Off Via IPMI 61 62 63Verify Chassis Power Cycle And Check Chassis Status Via IPMI 64 [Documentation] Verify chassis power Cycle operation and check the Chassis 65 ... Power Status using external IPMI command. 66 [Tags] Verify_Chassis_Power_Cycle_And_Check_Chassis_Status_Via_IPMI 67 68 # Chassis power cycle command via IPMI 69 IPMI Power Cycle 70 ${ipmi_state}= Get Host State Via External IPMI 71 Valid Value ipmi_state ['on'] 72 73 74Verify Chassis Power Reset And Check Chassis Status Via IPMI 75 [Documentation] Verify chassis power Reset operation and check the Chassis 76 ... Power Status using external IPMI command. 77 [Tags] Verify_Chassis_Power_Reset_And_Check_Chassis_Status_Via_IPMI 78 79 # Chassis power reset command via IPMI 80 IPMI Power Reset 81 ${ipmi_state}= Get Host State Via External IPMI 82 Valid Value ipmi_state ['on'] 83 84 85Verify Chassis Power Policy 86 [Documentation] Verify setting chassis power policy via IPMI command. 87 [Tags] Verify_Chassis_Power_Policy 88 [Setup] Test Setup Execution 89 [Teardown] Run Keywords FFDC On Test Case Fail AND 90 ... Run IPMI Standard Command chassis policy ${initial_power_policy} 91 [Template] Set Chassis Power Policy Via IPMI And Verify 92 93 # power_policy 94 always-off 95 always-on 96 previous 97 98 99Verify Chassis Status Via IPMI 100 [Documentation] Verify Chassis Status via IPMI command. 101 [Tags] Verify_Chassis_Status_Via_IPMI 102 [Setup] Test Setup Execution 103 [Teardown] Run Keywords FFDC On Test Case Fail AND 104 ... Run IPMI Standard Command chassis policy ${initial_power_policy} 105 [Template] Check Chassis Status Via IPMI 106 107 # power_policy 108 always-off 109 always-on 110 previous 111 112 113*** Keywords *** 114 115Set Chassis Power Policy Via IPMI And Verify 116 [Documentation] Set chasiss power policy via IPMI and verify. 117 [Arguments] ${power_policy} 118 119 # Description of argument(s): 120 # power_policy Chassis power policy to be set(e.g. "always-off", "always-on"). 121 122 Run IPMI Standard Command chassis policy ${power_policy} 123 ${resp}= Get Chassis Status 124 Valid Value resp['power_restore_policy'] ['${power_policy}'] 125 126 127Check Chassis Status Via IPMI 128 [Documentation] Set Chassis Status via IPMI and verify and verify chassis status. 129 [Arguments] ${power_policy} 130 131 # Sets power policy according to requested policy 132 Set Chassis Power Policy Via IPMI And Verify ${power_policy} 133 134 # Gets chassis status via IPMI raw command and validate byte 1 135 ${status}= Run External IPMI Raw Command ${IPMI_RAW_CMD['Chassis_status']['get'][0]} 136 ${status}= Split String ${status} 137 ${state}= Convert To Binary ${status[0]} base=16 138 ${state}= Zfill Data ${state} 8 139 140 # Last bit corresponds whether Power is on 141 Should Be Equal As Strings ${state[-1]} 1 142 # bit 1-2 corresponds to power restore policy 143 ${policy}= Set Variable ${state[1:3]} 144 145 # condition to verify each power policy 146 IF '${power_policy}' == 'always-off' 147 Should Be Equal As Strings ${policy} 00 148 ELSE IF '${power_policy}' == 'always-on' 149 Should Be Equal As Strings ${policy} 10 150 ELSE IF '${power_policy}' == 'previous' 151 Should Be Equal As Strings ${policy} 01 152 ELSE 153 Log Power Restore Policy is Unknown 154 Should Be Equal As Strings ${policy} 11 155 END 156 157 # Last Power Event - 4th bit should be 1b i.e, last ‘Power is on’ state was entered via IPMI command 158 ${last_power_event}= Convert To Binary ${status[1]} base=16 159 ${last_power_event}= Zfill Data ${last_power_event} 8 160 Should Be Equal As Strings ${last_power_event[3]} 1 161 162 163Test Setup Execution 164 [Documentation] Do test setup tasks. 165 166 ${chassis_status}= Get Chassis Status 167 Set Test Variable ${initial_power_policy} ${chassis_status['power_restore_policy']} 168 169 170Test Teardown Execution 171 [Documentation] Do Test Teardown tasks. 172 173 ${resp}= Run IPMI Standard Command chassis status 174 ${power_status}= Get Lines Containing String ${resp} System Power 175 @{powertolist}= Split String ${power_status} : 176 ${status}= Get From List ${powertolist} 1 177 # Chassis Power ON if status is off 178 Run Keyword If '${status.strip()}' != 'on' 179 ... Redfish Power On 180 FFDC On Test Case Fail 181