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 | |
George Keishing | b2a8dea | 2018-07-20 10:25:51 -0500 | [diff] [blame] | 20 | # Description of argument(s): |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 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. |
George Keishing | fbea604 | 2017-08-01 06:31:51 -0500 | [diff] [blame] | 36 | # 1. Request soft power off |
| 37 | # 2. Hard power off, if failed. |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 38 | [Arguments] ${wait}=${1} |
| 39 | |
George Keishing | b2a8dea | 2018-07-20 10:25:51 -0500 | [diff] [blame] | 40 | # Description of argument(s): |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 41 | # wait Indicates that this keyword should wait for host off state. |
| 42 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 43 | ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS} |
| 44 | Write Attribute |
| 45 | ... ${HOST_STATE_URI} RequestedHostTransition data=${args} |
| 46 | |
Michael Walsh | 67ef622 | 2017-03-21 14:48:26 -0500 | [diff] [blame] | 47 | # Does caller want to wait for status? |
| 48 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 49 | |
George Keishing | fbea604 | 2017-08-01 06:31:51 -0500 | [diff] [blame] | 50 | ${status}= Run Keyword And Return Status Wait For PowerOff |
| 51 | |
| 52 | Run Keyword if '${status}' == '${False}' Hard Power Off |
| 53 | |
| 54 | |
| 55 | Wait For PowerOff |
| 56 | [Documentation] Wait for power off state. |
| 57 | |
George Keishing | 2c54e69 | 2017-07-10 13:07:02 -0500 | [diff] [blame] | 58 | # TODO: Reference to open-power/skiboot#81. |
| 59 | # Revert to 3 minutes once fixed. |
George Keishing | fbea604 | 2017-08-01 06:31:51 -0500 | [diff] [blame] | 60 | Wait Until Keyword Succeeds 6 min 10 sec Is Host Off |
| 61 | |
| 62 | |
| 63 | Hard Power Off |
| 64 | [Documentation] Do a hard power off. |
Michael Walsh | 245db7c | 2017-09-05 15:45:03 -0500 | [diff] [blame] | 65 | [Arguments] ${wait}=${1} |
| 66 | |
| 67 | # Description of argument(s): |
| 68 | # wait Indicates that this keyword should wait for host off state. |
George Keishing | fbea604 | 2017-08-01 06:31:51 -0500 | [diff] [blame] | 69 | |
| 70 | ${args}= Create Dictionary data=${CHASSIS_POWEROFF_TRANS} |
| 71 | Write Attribute |
| 72 | ... ${CHASSIS_STATE_URI} RequestedPowerTransition data=${args} |
| 73 | |
Michael Walsh | 245db7c | 2017-09-05 15:45:03 -0500 | [diff] [blame] | 74 | # Does caller want to wait for status? |
| 75 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 76 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 77 | Wait Until Keyword Succeeds |
George Keishing | fbea604 | 2017-08-01 06:31:51 -0500 | [diff] [blame] | 78 | ... 1 min 10 sec Run Keywords Is Chassis Off AND Is Host Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 79 | |
| 80 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 81 | Initiate Host Reboot |
| 82 | [Documentation] Initiate host reboot via REST. |
George Keishing | b2a8dea | 2018-07-20 10:25:51 -0500 | [diff] [blame] | 83 | [Arguments] ${wait}=${1} |
| 84 | |
| 85 | # Description of argument(s): |
| 86 | # wait Indicates that this keyword should wait for host reboot state. |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 87 | |
| 88 | ${args}= Create Dictionary data=${HOST_REBOOT_TRANS} |
| 89 | Write Attribute |
| 90 | ... ${HOST_STATE_URI} RequestedHostTransition data=${args} |
George Keishing | b2a8dea | 2018-07-20 10:25:51 -0500 | [diff] [blame] | 91 | |
| 92 | # Does caller want to wait for host booted status? |
| 93 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 94 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 95 | Is Host Rebooted |
| 96 | |
| 97 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 98 | Is Host Running |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 99 | [Documentation] Check if host state is "Running". |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 100 | # Chassis state should be "On" before we check the host state. |
| 101 | Is Chassis On |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 102 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 103 | Should Be Equal Running ${host_state} |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 104 | # Check to verify that the host is really booted. |
George Keishing | 2bd6fc0 | 2017-08-10 01:15:16 -0500 | [diff] [blame] | 105 | Is OS Booted |
| 106 | |
| 107 | |
| 108 | Get Host State Attribute |
| 109 | [Documentation] Return the state of the host as a string. |
| 110 | [Arguments] ${host_attribute} ${quiet}=${QUIET} |
| 111 | |
| 112 | # Description of argument(s): |
| 113 | # host_attribute Host attribute name. |
| 114 | # quiet Suppress REST output logging to console. |
| 115 | |
Tim Lee | 29e073a | 2022-04-12 12:07:17 +0800 | [diff] [blame] | 116 | ${HOST_STATE_URI}= Set Variable If '${PLATFORM_ARCH_TYPE}' == 'x86' and '${host_attribute}' == 'OperatingSystemState' |
| 117 | ... ${OS_STATE_URI} ${HOST_STATE_URI} |
| 118 | |
George Keishing | 2bd6fc0 | 2017-08-10 01:15:16 -0500 | [diff] [blame] | 119 | ${state}= |
| 120 | ... Read Attribute ${HOST_STATE_URI} ${host_attribute} quiet=${quiet} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 121 | RETURN ${state} |
George Keishing | 2bd6fc0 | 2017-08-10 01:15:16 -0500 | [diff] [blame] | 122 | |
| 123 | |
| 124 | Is OS Booted |
| 125 | [Documentation] Check OS status. |
| 126 | |
| 127 | # Example: |
| 128 | # "/xyz/openbmc_project/state/host0": { |
| 129 | # "AttemptsLeft": 0, |
| 130 | # "BootProgress": "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart", |
| 131 | # "CurrentHostState": "xyz.openbmc_project.State.Host.HostState.Running", |
| 132 | # "OperatingSystemState": "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete", |
| 133 | # "RequestedHostTransition": "xyz.openbmc_project.State.Host.Transition.On" |
| 134 | # } |
| 135 | |
George Keishing | 2bd6fc0 | 2017-08-10 01:15:16 -0500 | [diff] [blame] | 136 | ${boot_stage}= Get Host State Attribute BootProgress |
| 137 | Should Be Equal ${OS_BOOT_START} ${boot_stage} |
| 138 | |
| 139 | ${os_state}= Get Host State Attribute OperatingSystemState |
| 140 | Should Be Equal ${OS_BOOT_COMPLETE} ${os_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 141 | |
| 142 | |
| 143 | Is Host Off |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 144 | [Documentation] Check if host state is "Off". |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 145 | # Chassis state should be "Off" before we check the host state. |
| 146 | Is Chassis Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 147 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 148 | Should Be Equal Off ${host_state} |
George Keishing | 13cc210 | 2017-07-25 07:48:58 -0500 | [diff] [blame] | 149 | # Check to verify that the host shutdown completely. |
Andrew Geissler | 854e9fe | 2017-07-29 09:51:13 -0500 | [diff] [blame] | 150 | # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off |
| 151 | #Is OS Off |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 152 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 153 | |
| 154 | Is Host Rebooted |
| 155 | [Documentation] Checks if host rebooted. |
| 156 | |
| 157 | ${host_trans_state}= Get Host Trans State |
| 158 | Should Be Equal ${host_trans_state} Reboot |
| 159 | Is Host Running |
| 160 | |
| 161 | |
| 162 | Is Chassis On |
| 163 | [Documentation] Check if chassis state is "On". |
| 164 | ${power_state}= Get Chassis Power State |
| 165 | Should Be Equal On ${power_state} |
| 166 | |
| 167 | |
| 168 | Is Chassis Off |
| 169 | [Documentation] Check if chassis state is "Off". |
| 170 | ${power_state}= Get Chassis Power State |
| 171 | Should Be Equal Off ${power_state} |
| 172 | |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 173 | Is Host Quiesced |
| 174 | [Documentation] Check if host state is quiesced. |
| 175 | ${host_state}= Get Host State |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 176 | ${status}= Run Keyword And Return Status Should Be Equal |
| 177 | ... ${host_state} Quiesced |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 178 | RETURN ${status} |
Rahul Maheshwari | d01596e | 2017-02-20 00:04:42 -0600 | [diff] [blame] | 179 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 180 | |
Rahul Maheshwari | 09439a2 | 2017-02-23 01:10:05 -0600 | [diff] [blame] | 181 | Recover Quiesced Host |
| 182 | [Documentation] Recover host from quisced state. |
| 183 | |
| 184 | ${resp}= Run Keyword And Return Status Is Host Quiesced |
| 185 | Run Keyword If '${resp}' == 'True' |
| 186 | ... Run Keywords Initiate Host PowerOff AND |
| 187 | ... Log HOST is recovered from quiesced state |
| 188 | |
| 189 | |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 190 | Get Host State |
| 191 | [Documentation] Return the state of the host as a string. |
| 192 | [Arguments] ${quiet}=${QUIET} |
| 193 | # quiet - Suppress REST output logging to console. |
| 194 | ${state}= |
| 195 | ... Read Attribute ${HOST_STATE_URI} CurrentHostState |
| 196 | ... quiet=${quiet} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 197 | RETURN ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 198 | |
Rahul Maheshwari | f7ead24 | 2017-02-14 01:59:42 -0600 | [diff] [blame] | 199 | Get Host Trans State |
| 200 | [Documentation] Return the transition state of host as a string. |
| 201 | ... e.g. On, Off, Reboot |
| 202 | [Arguments] ${quiet}=${QUIET} |
| 203 | # Description of arguments: |
| 204 | # quiet Suppress REST output logging to console. |
| 205 | |
| 206 | ${state}= |
| 207 | ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition |
| 208 | ... quiet=${quiet} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 209 | RETURN ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 210 | |
| 211 | Get Chassis Power State |
| 212 | [Documentation] Return the power state of the Chassis |
| 213 | ... as a string. |
| 214 | [Arguments] ${quiet}=${QUIET} |
| 215 | # quiet - Suppress REST output logging to console. |
| 216 | ${state}= |
| 217 | ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState |
| 218 | ... quiet=${quiet} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 219 | RETURN ${state.rsplit('.', 1)[1]} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 220 | |
| 221 | |
| 222 | Get BMC State |
| 223 | [Documentation] Return the state of the BMC. |
| 224 | [Arguments] ${quiet}=${QUIET} |
| 225 | # quiet - Suppress REST output logging to console. |
| 226 | ${state}= |
| 227 | ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 228 | RETURN ${state.rsplit('.', 1)[1]} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 229 | |
| 230 | |
| 231 | Put BMC State |
| 232 | [Documentation] Put BMC in given state. |
| 233 | [Arguments] ${expected_state} |
| 234 | # expected_state - expected BMC state |
| 235 | |
| 236 | ${bmc_state}= Get BMC State |
| 237 | Run Keyword If '${bmc_state}' == '${expected_state}' |
George Keishing | 334df29 | 2021-02-08 05:08:47 -0600 | [diff] [blame] | 238 | ... Log BMC is already in ${expected_state} state |
| 239 | ... ELSE |
| 240 | ... OBMC Reboot (off) |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 241 | |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 242 | Initiate BMC Reboot |
| 243 | [Documentation] Initiate BMC reboot. |
Michael Walsh | 8b38868 | 2017-09-08 10:57:45 -0500 | [diff] [blame] | 244 | [Arguments] ${wait}=${1} |
| 245 | |
| 246 | # Description of argument(s): |
| 247 | # wait Indicates that this keyword should wait for ending state.. |
| 248 | |
| 249 | ${args}= Create Dictionary data=${BMC_REBOOT_TRANS} |
Rahul Maheshwari | 55a68e2 | 2017-04-20 04:36:21 -0500 | [diff] [blame] | 250 | |
| 251 | Run Keyword And Ignore Error Write Attribute |
Michael Walsh | 8b38868 | 2017-09-08 10:57:45 -0500 | [diff] [blame] | 252 | ... ${BMC_STATE_URI} RequestedBMCTransition data=${args} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 253 | |
Michael Walsh | 8b38868 | 2017-09-08 10:57:45 -0500 | [diff] [blame] | 254 | # Does caller want to wait for status? |
| 255 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 256 | |
| 257 | ${session_active}= Check If BMC Reboot Is Initiated |
| 258 | Run Keyword If '${session_active}' == '${True}' |
| 259 | ... Fail msg=BMC Reboot didn't occur. |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 260 | |
| 261 | Check If BMC is Up |
| 262 | |
| 263 | Check If BMC Reboot Is Initiated |
| 264 | [Documentation] Checks whether BMC Reboot is initiated by checking |
| 265 | ... BMC connection loss. |
| 266 | # Reboot adds 3 seconds delay before forcing reboot |
| 267 | # To minimize race conditions, we wait for 7 seconds |
| 268 | Sleep 7s |
| 269 | ${alive}= Run Keyword and Return Status |
| 270 | ... Open Connection And Log In |
| 271 | Return From Keyword If '${alive}' == '${False}' ${False} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 272 | RETURN ${True} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 273 | |
| 274 | Is BMC Ready |
| 275 | [Documentation] Check if BMC state is Ready. |
| 276 | ${bmc_state}= Get BMC State |
| 277 | Should Be Equal ${BMC_READY_STATE} ${bmc_state} |
| 278 | |
| 279 | Is BMC Not Ready |
| 280 | [Documentation] Check if BMC state is Not Ready. |
| 281 | ${bmc_state}= Get BMC State |
| 282 | Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state} |
| 283 | |
| 284 | Wait for BMC state |
| 285 | [Documentation] Wait until given BMC state is reached. |
| 286 | [Arguments] ${state} |
| 287 | # state - BMC state to wait for |
| 288 | Run Keyword If '${state}' == '${BMC_READY_STATE}' |
| 289 | ... Wait Until Keyword Succeeds |
| 290 | ... 10 min 10 sec Is BMC Ready |
| 291 | ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}' |
| 292 | ... Wait Until Keyword Succeeds |
| 293 | ... 10 min 10 sec Is BMC Not Ready |
| 294 | ... ELSE Fail msg=Invalid BMC state |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 295 | |
| 296 | |
| 297 | Set State Interface Version |
| 298 | [Documentation] Set version to indicate which interface to use. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 299 | ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI} |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 300 | ${status}= Run Keyword And Return Status |
| 301 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 302 | Run Keyword If '${status}' == '${True}' |
| 303 | ... Set Global Variable ${OBMC_STATES_VERSION} ${1} |
| 304 | ... ELSE |
| 305 | ... Set Global Variable ${OBMC_STATES_VERSION} ${0} |
| 306 | |
| 307 | |
| 308 | Power Off Request |
| 309 | [Documentation] Select appropriate poweroff keyword. |
Rahul Maheshwari | 073f8ad | 2017-03-02 00:55:22 -0600 | [diff] [blame] | 310 | Run Keyword If '${OBMC_STATES_VERSION}' == '${0}' |
George Keishing | 43a021f | 2017-01-30 11:10:13 -0600 | [diff] [blame] | 311 | ... Initiate Power Off |
| 312 | ... ELSE |
| 313 | ... Initiate Host PowerOff |
| 314 | |
| 315 | |
| 316 | Wait For BMC Ready |
| 317 | [Documentation] Check BMC state and wait for BMC Ready. |
George Keishing | b2a8dea | 2018-07-20 10:25:51 -0500 | [diff] [blame] | 318 | Wait Until Keyword Succeeds 10 min 10 sec Is BMC Ready |
chithrag | a6be41e | 2022-03-01 13:20:23 +0000 | [diff] [blame] | 319 | |
| 320 | |
| 321 | Get Host State Via Redfish |
| 322 | [Documentation] Return the state of the host Via Redfish as a string. |
| 323 | |
| 324 | ${powerstate}= |
| 325 | ... Redfish.Get Attribute ${REDFISH_CHASSIS_URI}/${CHASSIS_ID} PowerState |
| 326 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 327 | RETURN ${powerstate} |