blob: 0e5efdda8aacf1410211e83a71846bc586bd311d [file] [log] [blame]
George Keishingb88df3d2017-01-10 07:28:08 -06001*** Settings ***
George Keishingbec365b2017-01-19 01:28:41 -06002Resource ../lib/utils.robot
3Variables ../data/variables.py
George Keishingb88df3d2017-01-10 07:28:08 -06004
5*** Variables ***
6
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -06007${BMC_READY_STATE} Ready
8${BMC_NOT_READY_STATE} NotReady
George Keishingb88df3d2017-01-10 07:28:08 -06009${QUIET} ${0}
10
Michael Walshb2869542017-04-12 15:41:02 -050011# "1" indicates that the new "xyz" interface should be used.
12${OBMC_STATES_VERSION} ${1}
George Keishing43a021f2017-01-30 11:10:13 -060013
George Keishingb88df3d2017-01-10 07:28:08 -060014*** Keywords ***
15
16Initiate Host Boot
17 [Documentation] Initiate host power on.
Michael Walsh67ef6222017-03-21 14:48:26 -050018 [Arguments] ${wait}=${1}
19
George Keishingb2a8dea2018-07-20 10:25:51 -050020 # Description of argument(s):
Michael Walsh67ef6222017-03-21 14:48:26 -050021 # wait Indicates that this keyword should wait for host running state.
22
George Keishingb88df3d2017-01-10 07:28:08 -060023 ${args}= Create Dictionary data=${HOST_POWERON_TRANS}
24 Write Attribute
25 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
26
Michael Walsh67ef6222017-03-21 14:48:26 -050027 # Does caller want to wait for status?
28 Run Keyword If '${wait}' == '${0}' Return From Keyword
29
George Keishingb88df3d2017-01-10 07:28:08 -060030 Wait Until Keyword Succeeds
31 ... 10 min 10 sec Is Host Running
32
33
34Initiate Host PowerOff
35 [Documentation] Initiate host power off.
George Keishingfbea6042017-08-01 06:31:51 -050036 # 1. Request soft power off
37 # 2. Hard power off, if failed.
Michael Walsh67ef6222017-03-21 14:48:26 -050038 [Arguments] ${wait}=${1}
39
George Keishingb2a8dea2018-07-20 10:25:51 -050040 # Description of argument(s):
Michael Walsh67ef6222017-03-21 14:48:26 -050041 # wait Indicates that this keyword should wait for host off state.
42
George Keishingb88df3d2017-01-10 07:28:08 -060043 ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS}
44 Write Attribute
45 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
46
Michael Walsh67ef6222017-03-21 14:48:26 -050047 # Does caller want to wait for status?
48 Run Keyword If '${wait}' == '${0}' Return From Keyword
49
George Keishingfbea6042017-08-01 06:31:51 -050050 ${status}= Run Keyword And Return Status Wait For PowerOff
51
52 Run Keyword if '${status}' == '${False}' Hard Power Off
53
54
55Wait For PowerOff
56 [Documentation] Wait for power off state.
57
George Keishing2c54e692017-07-10 13:07:02 -050058 # TODO: Reference to open-power/skiboot#81.
59 # Revert to 3 minutes once fixed.
George Keishingfbea6042017-08-01 06:31:51 -050060 Wait Until Keyword Succeeds 6 min 10 sec Is Host Off
61
62
63Hard Power Off
64 [Documentation] Do a hard power off.
Michael Walsh245db7c2017-09-05 15:45:03 -050065 [Arguments] ${wait}=${1}
66
67 # Description of argument(s):
68 # wait Indicates that this keyword should wait for host off state.
George Keishingfbea6042017-08-01 06:31:51 -050069
70 ${args}= Create Dictionary data=${CHASSIS_POWEROFF_TRANS}
71 Write Attribute
72 ... ${CHASSIS_STATE_URI} RequestedPowerTransition data=${args}
73
Michael Walsh245db7c2017-09-05 15:45:03 -050074 # Does caller want to wait for status?
75 Run Keyword If '${wait}' == '${0}' Return From Keyword
76
George Keishingb88df3d2017-01-10 07:28:08 -060077 Wait Until Keyword Succeeds
George Keishingfbea6042017-08-01 06:31:51 -050078 ... 1 min 10 sec Run Keywords Is Chassis Off AND Is Host Off
George Keishingb88df3d2017-01-10 07:28:08 -060079
80
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060081Initiate Host Reboot
82 [Documentation] Initiate host reboot via REST.
George Keishingb2a8dea2018-07-20 10:25:51 -050083 [Arguments] ${wait}=${1}
84
85 # Description of argument(s):
86 # wait Indicates that this keyword should wait for host reboot state.
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060087
88 ${args}= Create Dictionary data=${HOST_REBOOT_TRANS}
89 Write Attribute
90 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
George Keishingb2a8dea2018-07-20 10:25:51 -050091
92 # Does caller want to wait for host booted status?
93 Run Keyword If '${wait}' == '${0}' Return From Keyword
94
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060095 Is Host Rebooted
96
97
George Keishingb88df3d2017-01-10 07:28:08 -060098Is Host Running
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060099 [Documentation] Check if host state is "Running".
George Keishing13cc2102017-07-25 07:48:58 -0500100 # Chassis state should be "On" before we check the host state.
101 Is Chassis On
George Keishingb88df3d2017-01-10 07:28:08 -0600102 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -0600103 Should Be Equal Running ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -0500104 # Check to verify that the host is really booted.
George Keishing2bd6fc02017-08-10 01:15:16 -0500105 Is OS Booted
106
107
108Get 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
116 ${state}=
117 ... Read Attribute ${HOST_STATE_URI} ${host_attribute} quiet=${quiet}
118 [Return] ${state}
119
120
121Is OS Booted
122 [Documentation] Check OS status.
123
124 # Example:
125 # "/xyz/openbmc_project/state/host0": {
126 # "AttemptsLeft": 0,
127 # "BootProgress": "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
128 # "CurrentHostState": "xyz.openbmc_project.State.Host.HostState.Running",
129 # "OperatingSystemState": "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete",
130 # "RequestedHostTransition": "xyz.openbmc_project.State.Host.Transition.On"
131 # }
132
George Keishing2bd6fc02017-08-10 01:15:16 -0500133 ${boot_stage}= Get Host State Attribute BootProgress
134 Should Be Equal ${OS_BOOT_START} ${boot_stage}
135
136 ${os_state}= Get Host State Attribute OperatingSystemState
137 Should Be Equal ${OS_BOOT_COMPLETE} ${os_state}
George Keishingb88df3d2017-01-10 07:28:08 -0600138
139
140Is Host Off
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600141 [Documentation] Check if host state is "Off".
George Keishing13cc2102017-07-25 07:48:58 -0500142 # Chassis state should be "Off" before we check the host state.
143 Is Chassis Off
George Keishingb88df3d2017-01-10 07:28:08 -0600144 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -0600145 Should Be Equal Off ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -0500146 # Check to verify that the host shutdown completely.
Andrew Geissler854e9fe2017-07-29 09:51:13 -0500147 # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off
148 #Is OS Off
George Keishingb88df3d2017-01-10 07:28:08 -0600149
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600150
151Is Host Rebooted
152 [Documentation] Checks if host rebooted.
153
154 ${host_trans_state}= Get Host Trans State
155 Should Be Equal ${host_trans_state} Reboot
156 Is Host Running
157
158
159Is Chassis On
160 [Documentation] Check if chassis state is "On".
161 ${power_state}= Get Chassis Power State
162 Should Be Equal On ${power_state}
163
164
165Is Chassis Off
166 [Documentation] Check if chassis state is "Off".
167 ${power_state}= Get Chassis Power State
168 Should Be Equal Off ${power_state}
169
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600170Is Host Quiesced
171 [Documentation] Check if host state is quiesced.
172 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600173 ${status}= Run Keyword And Return Status Should Be Equal
174 ... ${host_state} Quiesced
175 [Return] ${status}
176
George Keishingb88df3d2017-01-10 07:28:08 -0600177
Rahul Maheshwari09439a22017-02-23 01:10:05 -0600178Recover Quiesced Host
179 [Documentation] Recover host from quisced state.
180
181 ${resp}= Run Keyword And Return Status Is Host Quiesced
182 Run Keyword If '${resp}' == 'True'
183 ... Run Keywords Initiate Host PowerOff AND
184 ... Log HOST is recovered from quiesced state
185
186
George Keishingb88df3d2017-01-10 07:28:08 -0600187Get Host State
188 [Documentation] Return the state of the host as a string.
189 [Arguments] ${quiet}=${QUIET}
190 # quiet - Suppress REST output logging to console.
191 ${state}=
192 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
193 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600194 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600195
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600196Get Host Trans State
197 [Documentation] Return the transition state of host as a string.
198 ... e.g. On, Off, Reboot
199 [Arguments] ${quiet}=${QUIET}
200 # Description of arguments:
201 # quiet Suppress REST output logging to console.
202
203 ${state}=
204 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
205 ... quiet=${quiet}
206 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600207
208Get Chassis Power State
209 [Documentation] Return the power state of the Chassis
210 ... as a string.
211 [Arguments] ${quiet}=${QUIET}
212 # quiet - Suppress REST output logging to console.
213 ${state}=
214 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
215 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600216 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600217
218
219Get BMC State
220 [Documentation] Return the state of the BMC.
221 [Arguments] ${quiet}=${QUIET}
222 # quiet - Suppress REST output logging to console.
223 ${state}=
224 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
225 [Return] ${state.rsplit('.', 1)[1]}
226
227
228Put BMC State
229 [Documentation] Put BMC in given state.
230 [Arguments] ${expected_state}
231 # expected_state - expected BMC state
232
233 ${bmc_state}= Get BMC State
234 Run Keyword If '${bmc_state}' == '${expected_state}'
235 ... Log BMC is already in ${expected_state} state
236 ... ELSE Run Keywords Initiate BMC Reboot AND
237 ... Wait for BMC state ${expected_state}
238
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600239Initiate BMC Reboot
240 [Documentation] Initiate BMC reboot.
Michael Walsh8b388682017-09-08 10:57:45 -0500241 [Arguments] ${wait}=${1}
242
243 # Description of argument(s):
244 # wait Indicates that this keyword should wait for ending state..
245
246 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
Rahul Maheshwari55a68e22017-04-20 04:36:21 -0500247
248 Run Keyword And Ignore Error Write Attribute
Michael Walsh8b388682017-09-08 10:57:45 -0500249 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600250
Michael Walsh8b388682017-09-08 10:57:45 -0500251 # Does caller want to wait for status?
252 Run Keyword If '${wait}' == '${0}' Return From Keyword
253
254 ${session_active}= Check If BMC Reboot Is Initiated
255 Run Keyword If '${session_active}' == '${True}'
256 ... Fail msg=BMC Reboot didn't occur.
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600257
258 Check If BMC is Up
259
260Check If BMC Reboot Is Initiated
261 [Documentation] Checks whether BMC Reboot is initiated by checking
262 ... BMC connection loss.
263 # Reboot adds 3 seconds delay before forcing reboot
264 # To minimize race conditions, we wait for 7 seconds
265 Sleep 7s
266 ${alive}= Run Keyword and Return Status
267 ... Open Connection And Log In
268 Return From Keyword If '${alive}' == '${False}' ${False}
269 [Return] ${True}
270
271Is BMC Ready
272 [Documentation] Check if BMC state is Ready.
273 ${bmc_state}= Get BMC State
274 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
275
276Is BMC Not Ready
277 [Documentation] Check if BMC state is Not Ready.
278 ${bmc_state}= Get BMC State
279 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
280
281Wait for BMC state
282 [Documentation] Wait until given BMC state is reached.
283 [Arguments] ${state}
284 # state - BMC state to wait for
285 Run Keyword If '${state}' == '${BMC_READY_STATE}'
286 ... Wait Until Keyword Succeeds
287 ... 10 min 10 sec Is BMC Ready
288 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
289 ... Wait Until Keyword Succeeds
290 ... 10 min 10 sec Is BMC Not Ready
291 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600292
293
294Set State Interface Version
295 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600296 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600297 ${status}= Run Keyword And Return Status
298 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
299 Run Keyword If '${status}' == '${True}'
300 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
301 ... ELSE
302 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
303
304
305Power Off Request
306 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600307 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600308 ... Initiate Power Off
309 ... ELSE
310 ... Initiate Host PowerOff
311
312
313Wait For BMC Ready
314 [Documentation] Check BMC state and wait for BMC Ready.
George Keishingb2a8dea2018-07-20 10:25:51 -0500315 Wait Until Keyword Succeeds 10 min 10 sec Is BMC Ready
George Keishingc3d9bc72020-06-15 09:44:21 -0500316
317
318Redfish Get BMC State
319 [Documentation] Return BMC health state.
320
321 # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady
322
323 # Example:
324 # "Status": {
325 # "Health": "OK",
326 # "HealthRollup": "OK",
327 # "State": "Enabled"
328 # },
329
330 ${status}= Redfish.Get Attribute /redfish/v1/Managers/bmc Status
331 [Return] ${status["State"]}
332
333
334Redfish Get Host State
335 [Documentation] Return host power and health state.
336
337 # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status
338
339 # Example:
340 # "PowerState": "Off",
341 # "Status": {
342 # "Health": "OK",
343 # "HealthRollup": "OK",
344 # "State": "StandbyOffline"
345 # },
346
347 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis/chassis
348 [Return] ${chassis["PowerState"]} ${chassis["Status"]["State"]}
George Keishing7b83a7f2020-12-07 23:43:15 -0600349
350
351Redfish Get Boot Progress
352 [Documentation] Return boot progress state.
353
354 # Example: /redfish/v1/Systems/system/
355 # "BootProgress": {
356 # "LastState": "OSRunning"
357 # },
358
359 ${boot_progress}= Redfish.Get Properties /redfish/v1/Systems/system/
360 [Return] ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]}
361
362
363Redfish Get States
364 [Documentation] Return all the BMC and host states in dictionary.
365
366 # Refer: openbmc/docs/designs/boot-progress.md
367
368 ${bmc_state}= Redfish Get BMC State
369 ${chassis_state} ${chassis_status}= Redfish Get Host State
370 ${boot_progress} ${host_state}= Redfish Get Boot Progress
371
372 ${states}= Create Dictionary
373 ... bmc=${bmc_state}
374 ... chassis=${chassis_state}
375 ... host=${host_state}
376 ... boot_progress=${boot_progress}
377
378 [Return] ${states}