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 | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 65 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 66 | Should Be Equal Running ${host_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 67 | |
| 68 | |
| 69 | Is Host Off |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 70 | [Documentation] Check if host state is "Off". |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 71 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 72 | Should Be Equal Off ${host_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 73 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 74 | |
| 75 | Is Host Rebooted |
| 76 | [Documentation] Checks if host rebooted. |
| 77 | |
| 78 | ${host_trans_state}= Get Host Trans State |
| 79 | Should Be Equal ${host_trans_state} Reboot |
| 80 | Is Host Running |
| 81 | |
| 82 | |
| 83 | Is Chassis On |
| 84 | [Documentation] Check if chassis state is "On". |
| 85 | ${power_state}= Get Chassis Power State |
| 86 | Should Be Equal On ${power_state} |
| 87 | |
| 88 | |
| 89 | Is Chassis Off |
| 90 | [Documentation] Check if chassis state is "Off". |
| 91 | ${power_state}= Get Chassis Power State |
| 92 | Should Be Equal Off ${power_state} |
| 93 | |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 94 | Is Host Quiesced |
| 95 | [Documentation] Check if host state is quiesced. |
| 96 | ${host_state}= Get Host State |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 97 | ${status}= Run Keyword And Return Status Should Be Equal |
| 98 | ... ${host_state} Quiesced |
| 99 | [Return] ${status} |
| 100 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 101 | |
Rahul Maheshwari | 09439a2 | 2017-02-23 01:10:05 -0600 | [diff] [blame] | 102 | Recover Quiesced Host |
| 103 | [Documentation] Recover host from quisced state. |
| 104 | |
| 105 | ${resp}= Run Keyword And Return Status Is Host Quiesced |
| 106 | Run Keyword If '${resp}' == 'True' |
| 107 | ... Run Keywords Initiate Host PowerOff AND |
| 108 | ... Log HOST is recovered from quiesced state |
| 109 | |
| 110 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 111 | Get Host State |
| 112 | [Documentation] Return the state of the host as a string. |
| 113 | [Arguments] ${quiet}=${QUIET} |
| 114 | # quiet - Suppress REST output logging to console. |
| 115 | ${state}= |
| 116 | ... Read Attribute ${HOST_STATE_URI} CurrentHostState |
| 117 | ... quiet=${quiet} |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 118 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 119 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 120 | Get Host Trans State |
| 121 | [Documentation] Return the transition state of host as a string. |
| 122 | ... e.g. On, Off, Reboot |
| 123 | [Arguments] ${quiet}=${QUIET} |
| 124 | # Description of arguments: |
| 125 | # quiet Suppress REST output logging to console. |
| 126 | |
| 127 | ${state}= |
| 128 | ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition |
| 129 | ... quiet=${quiet} |
| 130 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 131 | |
| 132 | Get Chassis Power State |
| 133 | [Documentation] Return the power state of the Chassis |
| 134 | ... as a string. |
| 135 | [Arguments] ${quiet}=${QUIET} |
| 136 | # quiet - Suppress REST output logging to console. |
| 137 | ${state}= |
| 138 | ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState |
| 139 | ... quiet=${quiet} |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 140 | [Return] ${state.rsplit('.', 1)[1]} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 141 | |
| 142 | |
| 143 | Get BMC State |
| 144 | [Documentation] Return the state of the BMC. |
| 145 | [Arguments] ${quiet}=${QUIET} |
| 146 | # quiet - Suppress REST output logging to console. |
| 147 | ${state}= |
| 148 | ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet} |
| 149 | [Return] ${state.rsplit('.', 1)[1]} |
| 150 | |
| 151 | |
| 152 | Put BMC State |
| 153 | [Documentation] Put BMC in given state. |
| 154 | [Arguments] ${expected_state} |
| 155 | # expected_state - expected BMC state |
| 156 | |
| 157 | ${bmc_state}= Get BMC State |
| 158 | Run Keyword If '${bmc_state}' == '${expected_state}' |
| 159 | ... Log BMC is already in ${expected_state} state |
| 160 | ... ELSE Run Keywords Initiate BMC Reboot AND |
| 161 | ... Wait for BMC state ${expected_state} |
| 162 | |
| 163 | |
| 164 | Initiate BMC Reboot |
| 165 | [Documentation] Initiate BMC reboot. |
| 166 | ${args}= Create Dictionary data=${BMC_REBOOT_TRANS} |
Rahul Maheshwari | 55a68e2 | 2017-04-20 04:36:21 -0500 | [diff] [blame] | 167 | |
| 168 | Run Keyword And Ignore Error Write Attribute |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 169 | ... ${BMC_STATE_URI} RequestedBMCTransition data=${args} |
| 170 | |
| 171 | ${session_active}= Check If BMC Reboot Is Initiated |
| 172 | Run Keyword If '${session_active}' == '${True}' |
| 173 | ... Fail msg=BMC Reboot didn't occur |
| 174 | |
| 175 | Check If BMC is Up |
| 176 | |
| 177 | Check If BMC Reboot Is Initiated |
| 178 | [Documentation] Checks whether BMC Reboot is initiated by checking |
| 179 | ... BMC connection loss. |
| 180 | # Reboot adds 3 seconds delay before forcing reboot |
| 181 | # To minimize race conditions, we wait for 7 seconds |
| 182 | Sleep 7s |
| 183 | ${alive}= Run Keyword and Return Status |
| 184 | ... Open Connection And Log In |
| 185 | Return From Keyword If '${alive}' == '${False}' ${False} |
| 186 | [Return] ${True} |
| 187 | |
| 188 | Is BMC Ready |
| 189 | [Documentation] Check if BMC state is Ready. |
| 190 | ${bmc_state}= Get BMC State |
| 191 | Should Be Equal ${BMC_READY_STATE} ${bmc_state} |
| 192 | |
| 193 | Is BMC Not Ready |
| 194 | [Documentation] Check if BMC state is Not Ready. |
| 195 | ${bmc_state}= Get BMC State |
| 196 | Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state} |
| 197 | |
| 198 | Wait for BMC state |
| 199 | [Documentation] Wait until given BMC state is reached. |
| 200 | [Arguments] ${state} |
| 201 | # state - BMC state to wait for |
| 202 | Run Keyword If '${state}' == '${BMC_READY_STATE}' |
| 203 | ... Wait Until Keyword Succeeds |
| 204 | ... 10 min 10 sec Is BMC Ready |
| 205 | ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}' |
| 206 | ... Wait Until Keyword Succeeds |
| 207 | ... 10 min 10 sec Is BMC Not Ready |
| 208 | ... ELSE Fail msg=Invalid BMC state |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 209 | |
| 210 | |
| 211 | Set State Interface Version |
| 212 | [Documentation] Set version to indicate which interface to use. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 213 | ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI} |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 214 | ${status}= Run Keyword And Return Status |
| 215 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 216 | Run Keyword If '${status}' == '${True}' |
| 217 | ... Set Global Variable ${OBMC_STATES_VERSION} ${1} |
| 218 | ... ELSE |
| 219 | ... Set Global Variable ${OBMC_STATES_VERSION} ${0} |
| 220 | |
| 221 | |
| 222 | Power Off Request |
| 223 | [Documentation] Select appropriate poweroff keyword. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 224 | Run Keyword If '${OBMC_STATES_VERSION}' == '${0}' |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 225 | ... Initiate Power Off |
| 226 | ... ELSE |
| 227 | ... Initiate Host PowerOff |
| 228 | |
| 229 | |
| 230 | Wait For BMC Ready |
| 231 | [Documentation] Check BMC state and wait for BMC Ready. |
| 232 | @{states}= Create List BMC_READY HOST_POWERED_OFF |
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 | ... Wait Until Keyword Succeeds 10 min 10 sec |
| 235 | ... Verify BMC State ${states} |
| 236 | ... ELSE |
| 237 | ... Wait Until Keyword Succeeds 10 min 10 sec |
| 238 | ... Is BMC Ready |
| 239 | |
| 240 | |