George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 1 | *** Settings *** |
George Keishing | bec365b | 2017-01-19 01:28:41 -0600 | [diff] [blame] | 2 | Resource ../lib/utils.robot |
| 3 | Variables ../data/variables.py |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 4 | |
| 5 | *** Variables *** |
| 6 | |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 7 | ${BMC_READY_STATE} Ready |
| 8 | ${BMC_NOT_READY_STATE} NotReady |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 9 | ${QUIET} ${0} |
| 10 | |
Michael Walsh | b286954 | 2017-04-12 15:41:02 -0500 | [diff] [blame] | 11 | # "1" indicates that the new "xyz" interface should be used. |
| 12 | ${OBMC_STATES_VERSION} ${1} |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 13 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 14 | *** Keywords *** |
| 15 | |
| 16 | Initiate Host Boot |
| 17 | [Documentation] Initiate host power on. |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 18 | [Arguments] ${wait}=${1} |
| 19 | |
| 20 | # Description of arguments: |
| 21 | # wait Indicates that this keyword should wait for host running state. |
| 22 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 23 | ${args}= Create Dictionary data=${HOST_POWERON_TRANS} |
| 24 | Write Attribute |
| 25 | ... ${HOST_STATE_URI} RequestedHostTransition data=${args} |
| 26 | |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 27 | # Does caller want to wait for status? |
| 28 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 29 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 30 | Wait Until Keyword Succeeds |
| 31 | ... 10 min 10 sec Is Host Running |
| 32 | |
| 33 | |
| 34 | Initiate Host PowerOff |
| 35 | [Documentation] Initiate host power off. |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 36 | [Arguments] ${wait}=${1} |
| 37 | |
| 38 | # Description of arguments: |
| 39 | # wait Indicates that this keyword should wait for host off state. |
| 40 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 41 | ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS} |
| 42 | Write Attribute |
| 43 | ... ${HOST_STATE_URI} RequestedHostTransition data=${args} |
| 44 | |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 45 | # Does caller want to wait for status? |
| 46 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 47 | |
George Keishing | 2c54e69 | 2017-07-10 13:07:02 -0500 | [diff] [blame] | 48 | # TODO: Reference to open-power/skiboot#81. |
| 49 | # Revert to 3 minutes once fixed. |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 50 | Wait Until Keyword Succeeds |
George Keishing | 2c54e69 | 2017-07-10 13:07:02 -0500 | [diff] [blame] | 51 | ... 6 min 10 sec Is Host Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 52 | |
| 53 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 54 | Initiate Host Reboot |
| 55 | [Documentation] Initiate host reboot via REST. |
| 56 | |
| 57 | ${args}= Create Dictionary data=${HOST_REBOOT_TRANS} |
| 58 | Write Attribute |
| 59 | ... ${HOST_STATE_URI} RequestedHostTransition data=${args} |
| 60 | Is Host Rebooted |
| 61 | |
| 62 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 63 | Is Host Running |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 64 | [Documentation] Check if host state is "Running". |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 65 | # Chassis state should be "On" before we check the host state. |
| 66 | Is Chassis On |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 67 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 68 | Should Be Equal Running ${host_state} |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 69 | # Check to verify that the host is really booted. |
| 70 | Is OS Starting |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 71 | |
| 72 | |
| 73 | Is Host Off |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 74 | [Documentation] Check if host state is "Off". |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 75 | # Chassis state should be "Off" before we check the host state. |
| 76 | Is Chassis Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 77 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 78 | Should Be Equal Off ${host_state} |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 79 | # Check to verify that the host shutdown completely. |
Andrew Geissler | 854e9fe | 2017-07-29 09:51:13 -0500 | [diff] [blame] | 80 | # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off |
| 81 | #Is OS Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 82 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 83 | |
| 84 | Is Host Rebooted |
| 85 | [Documentation] Checks if host rebooted. |
| 86 | |
| 87 | ${host_trans_state}= Get Host Trans State |
| 88 | Should Be Equal ${host_trans_state} Reboot |
| 89 | Is Host Running |
| 90 | |
| 91 | |
| 92 | Is Chassis On |
| 93 | [Documentation] Check if chassis state is "On". |
| 94 | ${power_state}= Get Chassis Power State |
| 95 | Should Be Equal On ${power_state} |
| 96 | |
| 97 | |
| 98 | Is Chassis Off |
| 99 | [Documentation] Check if chassis state is "Off". |
| 100 | ${power_state}= Get Chassis Power State |
| 101 | Should Be Equal Off ${power_state} |
| 102 | |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 103 | Is Host Quiesced |
| 104 | [Documentation] Check if host state is quiesced. |
| 105 | ${host_state}= Get Host State |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 106 | ${status}= Run Keyword And Return Status Should Be Equal |
| 107 | ... ${host_state} Quiesced |
| 108 | [Return] ${status} |
| 109 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 110 | |
Rahul Maheshwari | 09439a2 | 2017-02-23 01:10:05 -0600 | [diff] [blame] | 111 | Recover Quiesced Host |
| 112 | [Documentation] Recover host from quisced state. |
| 113 | |
| 114 | ${resp}= Run Keyword And Return Status Is Host Quiesced |
| 115 | Run Keyword If '${resp}' == 'True' |
| 116 | ... Run Keywords Initiate Host PowerOff AND |
| 117 | ... Log HOST is recovered from quiesced state |
| 118 | |
| 119 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 120 | Get Host State |
| 121 | [Documentation] Return the state of the host as a string. |
| 122 | [Arguments] ${quiet}=${QUIET} |
| 123 | # quiet - Suppress REST output logging to console. |
| 124 | ${state}= |
| 125 | ... Read Attribute ${HOST_STATE_URI} CurrentHostState |
| 126 | ... quiet=${quiet} |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 127 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 128 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 129 | Get Host Trans State |
| 130 | [Documentation] Return the transition state of host as a string. |
| 131 | ... e.g. On, Off, Reboot |
| 132 | [Arguments] ${quiet}=${QUIET} |
| 133 | # Description of arguments: |
| 134 | # quiet Suppress REST output logging to console. |
| 135 | |
| 136 | ${state}= |
| 137 | ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition |
| 138 | ... quiet=${quiet} |
| 139 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 140 | |
| 141 | Get Chassis Power State |
| 142 | [Documentation] Return the power state of the Chassis |
| 143 | ... as a string. |
| 144 | [Arguments] ${quiet}=${QUIET} |
| 145 | # quiet - Suppress REST output logging to console. |
| 146 | ${state}= |
| 147 | ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState |
| 148 | ... quiet=${quiet} |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 149 | [Return] ${state.rsplit('.', 1)[1]} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 150 | |
| 151 | |
| 152 | Get BMC State |
| 153 | [Documentation] Return the state of the BMC. |
| 154 | [Arguments] ${quiet}=${QUIET} |
| 155 | # quiet - Suppress REST output logging to console. |
| 156 | ${state}= |
| 157 | ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet} |
| 158 | [Return] ${state.rsplit('.', 1)[1]} |
| 159 | |
| 160 | |
| 161 | Put BMC State |
| 162 | [Documentation] Put BMC in given state. |
| 163 | [Arguments] ${expected_state} |
| 164 | # expected_state - expected BMC state |
| 165 | |
| 166 | ${bmc_state}= Get BMC State |
| 167 | Run Keyword If '${bmc_state}' == '${expected_state}' |
| 168 | ... Log BMC is already in ${expected_state} state |
| 169 | ... ELSE Run Keywords Initiate BMC Reboot AND |
| 170 | ... Wait for BMC state ${expected_state} |
| 171 | |
| 172 | |
| 173 | Initiate BMC Reboot |
| 174 | [Documentation] Initiate BMC reboot. |
| 175 | ${args}= Create Dictionary data=${BMC_REBOOT_TRANS} |
Rahul Maheshwari | 55a68e2 | 2017-04-20 04:36:21 -0500 | [diff] [blame] | 176 | |
| 177 | Run Keyword And Ignore Error Write Attribute |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 178 | ... ${BMC_STATE_URI} RequestedBMCTransition data=${args} |
| 179 | |
| 180 | ${session_active}= Check If BMC Reboot Is Initiated |
| 181 | Run Keyword If '${session_active}' == '${True}' |
| 182 | ... Fail msg=BMC Reboot didn't occur |
| 183 | |
| 184 | Check If BMC is Up |
| 185 | |
| 186 | Check If BMC Reboot Is Initiated |
| 187 | [Documentation] Checks whether BMC Reboot is initiated by checking |
| 188 | ... BMC connection loss. |
| 189 | # Reboot adds 3 seconds delay before forcing reboot |
| 190 | # To minimize race conditions, we wait for 7 seconds |
| 191 | Sleep 7s |
| 192 | ${alive}= Run Keyword and Return Status |
| 193 | ... Open Connection And Log In |
| 194 | Return From Keyword If '${alive}' == '${False}' ${False} |
| 195 | [Return] ${True} |
| 196 | |
| 197 | Is BMC Ready |
| 198 | [Documentation] Check if BMC state is Ready. |
| 199 | ${bmc_state}= Get BMC State |
| 200 | Should Be Equal ${BMC_READY_STATE} ${bmc_state} |
| 201 | |
| 202 | Is BMC Not Ready |
| 203 | [Documentation] Check if BMC state is Not Ready. |
| 204 | ${bmc_state}= Get BMC State |
| 205 | Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state} |
| 206 | |
| 207 | Wait for BMC state |
| 208 | [Documentation] Wait until given BMC state is reached. |
| 209 | [Arguments] ${state} |
| 210 | # state - BMC state to wait for |
| 211 | Run Keyword If '${state}' == '${BMC_READY_STATE}' |
| 212 | ... Wait Until Keyword Succeeds |
| 213 | ... 10 min 10 sec Is BMC Ready |
| 214 | ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}' |
| 215 | ... Wait Until Keyword Succeeds |
| 216 | ... 10 min 10 sec Is BMC Not Ready |
| 217 | ... ELSE Fail msg=Invalid BMC state |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 218 | |
| 219 | |
| 220 | Set State Interface Version |
| 221 | [Documentation] Set version to indicate which interface to use. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 222 | ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI} |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 223 | ${status}= Run Keyword And Return Status |
| 224 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 225 | Run Keyword If '${status}' == '${True}' |
| 226 | ... Set Global Variable ${OBMC_STATES_VERSION} ${1} |
| 227 | ... ELSE |
| 228 | ... Set Global Variable ${OBMC_STATES_VERSION} ${0} |
| 229 | |
| 230 | |
| 231 | Power Off Request |
| 232 | [Documentation] Select appropriate poweroff keyword. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 233 | Run Keyword If '${OBMC_STATES_VERSION}' == '${0}' |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 234 | ... Initiate Power Off |
| 235 | ... ELSE |
| 236 | ... Initiate Host PowerOff |
| 237 | |
| 238 | |
| 239 | Wait For BMC Ready |
| 240 | [Documentation] Check BMC state and wait for BMC Ready. |
| 241 | @{states}= Create List BMC_READY HOST_POWERED_OFF |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 242 | Run Keyword If '${OBMC_STATES_VERSION}' == '${0}' |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 243 | ... Wait Until Keyword Succeeds 10 min 10 sec |
| 244 | ... Verify BMC State ${states} |
| 245 | ... ELSE |
| 246 | ... Wait Until Keyword Succeeds 10 min 10 sec |
| 247 | ... Is BMC Ready |
| 248 | |
| 249 | |