blob: e25b0a5c2f9418491a00f973d34c5352c50dbd72 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
Steven Sombar0acb3412018-01-24 09:38:42 -06002
Steven Sombarf60cbcf2018-12-07 08:12:18 -06003Documentation Utilities for Robot keywords that use REST.
Steven Sombar0acb3412018-01-24 09:38:42 -06004
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06005Resource ../lib/resource.robot
Chris Austenb29d2e82016-06-07 12:25:35 -05006Resource ../lib/rest_client.robot
George Keishing5e870cd2016-08-24 10:05:47 -05007Resource ../lib/connection_client.robot
Rahul Maheshwarid1f45f22018-10-26 05:16:39 -05008Resource ../lib/boot_utils.robot
Steven Sombarf60cbcf2018-12-07 08:12:18 -06009Resource ../lib/common_utils.robot
George Keishingc0701102021-09-30 12:12:04 -050010Resource ../lib/bmc_redfish_utils.robot
Michael Walsh391ba9b2017-08-24 11:36:24 -050011Library String
George Keishing30c12ff2016-09-02 10:25:29 -050012Library DateTime
13Library Process
Chris Austenb29d2e82016-06-07 12:25:35 -050014Library OperatingSystem
Michael Walsha6723f22016-11-22 11:12:01 -060015Library gen_print.py
Steven Sombaraaaab222018-12-19 13:16:23 -060016Library gen_misc.py
Michael Walsha6723f22016-11-22 11:12:01 -060017Library gen_robot_print.py
Michael Walsh5f3f4142017-05-22 17:09:47 -050018Library gen_cmd.py
Sunil Macd110a2017-05-23 04:14:32 -050019Library gen_robot_keyword.py
Michael Walshe53e47a2017-06-30 17:03:24 -050020Library bmc_ssh_utils.py
Michael Walshfdc5ced2017-08-17 13:15:15 -050021Library utils.py
Charles Paul Hofer35816152017-10-02 11:55:11 -050022Library var_funcs.py
George Keishingb5c119e2025-03-25 20:45:03 +053023Library SCPLibrary AS scp
George Keishing61364e52019-10-01 12:01:19 -050024Library gen_robot_valid.py
George Keishing83c737b2022-05-17 12:12:04 -050025Library pldm_utils.py
Chris Austenb29d2e82016-06-07 12:25:35 -050026
Steven Sombarf60cbcf2018-12-07 08:12:18 -060027
Chris Austenb29d2e82016-06-07 12:25:35 -050028*** Variables ***
Steven Sombar0acb3412018-01-24 09:38:42 -060029
Steven Sombar0acb3412018-01-24 09:38:42 -060030${SYSTEM_SHUTDOWN_TIME} ${5}
31
Michael Walsha6723f22016-11-22 11:12:01 -060032# Assign default value to QUIET for programs which may not define it.
33${QUIET} ${0}
Steven Sombar0acb3412018-01-24 09:38:42 -060034
Sridevi Ramesh1699d372016-12-06 00:20:22 -060035${HOST_SETTING} ${SETTINGS_URI}host0
Steven Sombar0acb3412018-01-24 09:38:42 -060036
Steven Sombar0acb3412018-01-24 09:38:42 -060037${boot_prog_method} ${EMPTY}
Michael Walshfdc5ced2017-08-17 13:15:15 -050038${power_policy_setup} ${0}
39${bmc_power_policy_method} ${EMPTY}
Sridevi Ramesh13d84bf2022-10-31 09:14:52 -050040@{BOOT_PROGRESS_STATES} SystemHardwareInitializationComplete OSBootStarted OSRunning
Michael Walshfdc5ced2017-08-17 13:15:15 -050041
Sushil Singhfd0f91b2023-11-10 07:35:11 -060042${REDFISH_SYS_STATE_WAIT_TIMEOUT} 120 Seconds
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050043
Chris Austenb29d2e82016-06-07 12:25:35 -050044*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060045
Steven Sombar0acb3412018-01-24 09:38:42 -060046
George Keishing5e870cd2016-08-24 10:05:47 -050047Verify Ping and REST Authentication
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050048 [Documentation] Verify ping and rest authentication.
Michael Walsha6723f22016-11-22 11:12:01 -060049 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050050 ... Ping Host ${OPENBMC_HOST}
George Keishing0628c4f2025-06-24 23:58:47 +053051 IF '${l_ping}' == '${False}' Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -050052
Michael Walsha6723f22016-11-22 11:12:01 -060053 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050054 ... Initialize OpenBMC
George Keishing0628c4f2025-06-24 23:58:47 +053055 IF '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -050056
57 # Just to make sure the SSH is working for SCP
58 Open Connection And Log In
59 ${system} ${stderr}= Execute Command hostname return_stderr=True
60 Should Be Empty ${stderr}
61
Steven Sombar0acb3412018-01-24 09:38:42 -060062
George Keishing90b555a2021-05-20 11:54:16 -050063Verify Ping SSH And Redfish Authentication
64 [Documentation] Verify ping, SSH and redfish authentication.
65
66 ${l_ping}= Run Keyword And Return Status Ping Host ${OPENBMC_HOST}
George Keishing0628c4f2025-06-24 23:58:47 +053067 IF '${l_ping}' == '${False}' Fail msg=Ping Failed
George Keishing90b555a2021-05-20 11:54:16 -050068
69 ${l_rest}= Run Keyword And Return Status Redfish.Login
George Keishing0628c4f2025-06-24 23:58:47 +053070 IF '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
George Keishing90b555a2021-05-20 11:54:16 -050071
72 # Just to make sure the SSH is working.
73 Open Connection And Log In
74 ${system} ${stderr}= Execute Command hostname return_stderr=True
75 Should Be Empty ${stderr}
76
77
George Keishingc4d3dc02016-09-19 03:45:55 -050078Check If BMC is Up
79 [Documentation] Wait for Host to be online. Checks every X seconds
80 ... interval for Y minutes and fails if timed out.
81 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -060082 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -050083 ... ${interval}=10 sec
84
Steven Sombar0acb3412018-01-24 09:38:42 -060085 # Description of argument(s):
86 # max_timeout Maximum time to wait.
87 # This should be expressed in Robot Framework's time format
88 # (e.g. "10 minutes").
George Keishing16b3c7b2021-01-28 09:23:37 -060089 # interval Interval to wait between status checks.
Steven Sombar0acb3412018-01-24 09:38:42 -060090 # This should be expressed in Robot Framework's time format
91 # (e.g. "5 seconds").
92
George Keishingc4d3dc02016-09-19 03:45:55 -050093 Wait Until Keyword Succeeds
94 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
95
George Keishingb3700812016-08-31 03:03:30 -050096
George Keishing06ae4aa2016-08-30 01:41:28 -050097Flush REST Sessions
98 [Documentation] Removes all the active session objects
99 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500100
Steven Sombar0acb3412018-01-24 09:38:42 -0600101
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600102Trigger Host Watchdog Error
George Keishing37cfa6b2017-06-15 10:25:55 -0500103 [Documentation] Inject host watchdog timeout error via REST.
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600104 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Steven Sombar0acb3412018-01-24 09:38:42 -0600105
Michael Walshb5839d02017-04-12 16:11:20 -0500106 # Description of argument(s):
107 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
108 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600109 # sleep_time Time delay for host watchdog error to get injected.
110 # Default is 5 seconds.
111
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500112 ${data}= Create Dictionary
113 ... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
114 ${status} ${result}= Run Keyword And Ignore Error
115 ... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction
George Keishing0628c4f2025-06-24 23:58:47 +0530116 IF '${status}' == 'PASS'
117 Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
118 END
George Keishing37cfa6b2017-06-15 10:25:55 -0500119
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600120 ${int_milliseconds}= Convert To Integer ${milliseconds}
121 ${data}= Create Dictionary data=${int_milliseconds}
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500122 Write Attribute ${HOST_WATCHDOG_URI} Interval data=${data}
123
124 ${data}= Create Dictionary data=${True}
125 Write Attribute ${HOST_WATCHDOG_URI} Enabled data=${data}
George Keishing37cfa6b2017-06-15 10:25:55 -0500126
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600127 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500128
Steven Sombar0acb3412018-01-24 09:38:42 -0600129
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500130Login To OS Host
Steven Sombar0acb3412018-01-24 09:38:42 -0600131 [Documentation] Login to OS Host and return the Login response code.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500132 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
133 ... ${os_password}=${OS_PASSWORD}
Steven Sombar0acb3412018-01-24 09:38:42 -0600134
Gunnar Mills28e403b2017-10-25 16:16:38 -0500135 # Description of arguments:
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500136 # ${os_host} IP address of the OS Host.
137 # ${os_username} OS Host Login user name.
138 # ${os_password} OS Host Login passwrd.
139
George Keishing1856d332021-11-15 08:38:53 -0600140 Redfish Power On stack_mode=skip quiet=1
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500141
George Keishing3f223b82017-06-28 03:50:35 -0500142 SSHLibrary.Open Connection ${os_host}
George Keishinge0030882019-02-21 03:48:27 -0600143 ${resp}= SSHLibrary.Login ${os_username} ${os_password}
George Keishing409df052024-01-17 22:36:14 +0530144 RETURN ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500145
Steven Sombar0acb3412018-01-24 09:38:42 -0600146
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600147Initiate Auto Reboot
148 [Documentation] Initiate an auto reboot.
149 [Arguments] ${milliseconds}=5000
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500150
151 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600152 # milliseconds The number of milliseconds for the watchdog timer.
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500153
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600154 # Set the auto reboot policy.
155 Set Auto Reboot ${1}
156 # Set the watchdog timer.
157 Trigger Host Watchdog Error ${milliseconds}
158
159
160Initiate OS Host Reboot
161 [Documentation] Initiate an OS reboot.
162 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
163 ... ${os_password}=${OS_PASSWORD}
164
165 # Description of argument(s):
166 # os_host The host name or IP address of the OS.
167 # os_username The username to be used to sign in to the OS.
168 # os_password The password to be used to sign in to the OS.
169
170 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
171 ... Set Variable reboot
172 ... ELSE
173 ... Set Variable echo ${os_password} | sudo -S reboot
174
175 ${output} ${stderr} ${rc}= OS Execute Command
176 ... ${cmd_buf} fork=${1}
177
178
179Initiate OS Host Power Off
180 [Documentation] Initiate an OS reboot.
181 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
182 ... ${os_password}=${OS_PASSWORD} ${hard}=${0}
183
184 # Description of argument(s):
185 # os_host The DNS name or IP of the OS.
186 # os_username The username to be used to sign in to the OS.
187 # os_password The password to be used to sign in to the OS.
188 # hard Indicates whether to do a hard vs. soft power off.
189
190 ${time_string}= Run Keyword If ${hard} Set Variable ${SPACE}now
191 ... ELSE Set Variable ${EMPTY}
192
193 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
194 ... Set Variable shutdown${time_string}
195 ... ELSE
196 ... Set Variable echo ${os_password} | sudo -S shutdown${time_string}
197
198 ${output} ${stderr} ${rc}= OS Execute Command
199 ... ${cmd_buf} fork=${1}
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500200
George Keishing3987a1e2017-09-20 09:13:02 -0500201
Steven Sombar5f3af442018-02-14 08:30:15 -0600202Set System LED State
203 [Documentation] Set given system LED via REST.
204 [Arguments] ${led_name} ${led_state}
205 # Description of argument(s):
206 # led_name System LED name (e.g. heartbeat, identify, beep).
207 # led_state LED state to be set (e.g. On, Off).
208
209 ${args}= Create Dictionary
210 ... data=xyz.openbmc_project.Led.Physical.Action.${led_state}
211 Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args}
212
213 Verify LED State ${led_name} ${led_state}
214
215
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600216Old Get Boot Progress
217 [Documentation] Get the boot progress the old way (via org location).
218 [Arguments] ${quiet}=${QUIET}
George Keishing034902d2017-11-10 13:15:38 -0600219
220 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600221 # quiet Indicates whether this keyword should run without any output to
222 # the console.
223
224 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
225 ... value quiet=${quiet}
226
George Keishing409df052024-01-17 22:36:14 +0530227 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600228
229
230Set Boot Progress Method
231 [Documentation] Set the boot_prog_method to either 'Old' or 'New'.
232
233 # The boot progress data has moved from an 'org' location to an 'xyz'
234 # location. This keyword will determine whether the new method of getting
235 # the boot progress is valid and will set the global boot_prog_method
236 # variable accordingly. If boot_prog_method is already set (either by a
237 # prior call to this function or via a -v parm), this keyword will simply
238 # return.
239
240 # Note: There are interim builds that contain boot_progress in both the
241 # old and the new location values. It is nearly impossible for this
242 # keyword to determine whether the old boot_progress or the new one is
243 # active. When using such builds where the old boot_progress is active,
244 # the only recourse users will have is that they may specify
245 # -v boot_prog_method:Old to force old behavior on such builds.
246
George Keishing0628c4f2025-06-24 23:58:47 +0530247 IF '${boot_prog_method}' != '${EMPTY}' Return From Keyword
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600248
249 ${new_status} ${new_value}= Run Keyword And Ignore Error
250 ... New Get Boot Progress
251 # If the new style read fails, the method must necessarily be "Old".
George Keishing0628c4f2025-06-24 23:58:47 +0530252 IF '${new_status}' == 'PASS'
253 Set Global Variable ${boot_prog_method} New
254 Rqpvars boot_prog_method
255 Return From Keyword
256 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600257
258 # Default method is "Old".
259 Set Global Variable ${boot_prog_method} Old
260 Rqpvars boot_prog_method
261
262
263Initiate Power On
264 [Documentation] Initiates the power on and waits until the Is Power On
265 ... keyword returns that the power state has switched to on.
266 [Arguments] ${wait}=${1}
267
268 # Description of argument(s):
269 # wait Indicates whether to wait for a powered on state after issuing
270 # the power on command.
271
272 @{arglist}= Create List
273 ${args}= Create Dictionary data=@{arglist}
274 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
275 ... data=${args}
276 should be equal as strings ${resp.status_code} ${HTTP_OK}
277
278 # Does caller want to wait for power on status?
George Keishing0628c4f2025-06-24 23:58:47 +0530279 IF '${wait}' == '${0}' Return From Keyword
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600280 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
281
282
283Initiate Power Off
284 [Documentation] Initiates the power off and waits until the Is Power Off
285 ... keyword returns that the power state has switched to off.
286
287 @{arglist}= Create List
288 ${args}= Create Dictionary data=@{arglist}
289 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
290 ... data=${args}
291 should be equal as strings ${resp.status_code} ${HTTP_OK}
292 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
293
294
295Get Boot Progress
296 [Documentation] Get the boot progress and return it.
297 [Arguments] ${quiet}=${QUIET}
298
299 # Description of argument(s):
300 # quiet Indicates whether this keyword should run without any output to
301 # the console.
302
303 Set Boot Progress Method
304 ${state}= Run Keyword If '${boot_prog_method}' == 'New'
305 ... New Get Boot Progress quiet=${quiet}
306 ... ELSE
307 ... Old Get Boot Progress quiet=${quiet}
308
George Keishing409df052024-01-17 22:36:14 +0530309 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600310
311
312New Get Boot Progress
313 [Documentation] Get the boot progress the new way (via xyz location).
314 [Arguments] ${quiet}=${QUIET}
315
316 # Description of argument(s):
317 # quiet Indicates whether this keyword should run without any output to
318 # the console.
319
320 ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet}
321
George Keishing409df052024-01-17 22:36:14 +0530322 RETURN ${state.rsplit('.', 1)[1]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600323
324
325New Get Power Policy
326 [Documentation] Returns the BMC power policy (new method).
327 ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy
328
George Keishing409df052024-01-17 22:36:14 +0530329 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600330
331
332Old Get Power Policy
333 [Documentation] Returns the BMC power policy (old method).
334 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
335
George Keishing409df052024-01-17 22:36:14 +0530336 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600337
338
George Keishinga54e06f2020-06-12 10:42:41 -0500339Redfish Get Power Restore Policy
340 [Documentation] Returns the BMC power restore policy.
341
Yi Huc32434a2024-01-11 17:33:10 -0800342 ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} PowerRestorePolicy
George Keishing409df052024-01-17 22:36:14 +0530343 RETURN ${power_restore_policy}
344
George Keishinga54e06f2020-06-12 10:42:41 -0500345
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600346Get Auto Reboot
347 [Documentation] Returns auto reboot setting.
348 ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
349
George Keishing409df052024-01-17 22:36:14 +0530350 RETURN ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600351
352
George Keishingc8a6dd22020-06-12 12:01:33 -0500353Redfish Get Auto Reboot
354 [Documentation] Returns auto reboot setting.
355
George Keishing43909f32024-08-20 22:08:02 +0530356 ${resp}= Wait Until Keyword Succeeds 1 min 20 sec
357 ... Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing409df052024-01-17 22:36:14 +0530358 RETURN ${resp["AutomaticRetryConfig"]}
George Keishingc8a6dd22020-06-12 12:01:33 -0500359
360
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600361Trigger Warm Reset
362 [Documentation] Initiate a warm reset.
363
364 log to console "Triggering warm reset"
365 ${data}= create dictionary data=@{EMPTY}
George Keishingfbd67002022-08-01 11:24:03 -0500366 ${resp}= Openbmc Post Request
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600367 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
368 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
369 ${session_active}= Check If warmReset is Initiated
George Keishing0628c4f2025-06-24 23:58:47 +0530370 IF '${session_active}' == '${True}' Fail msg=warm reset didn't occur
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600371
372 Sleep ${SYSTEM_SHUTDOWN_TIME}min
373 Check If BMC Is Up
374
375
376Get Power State
377 [Documentation] Returns the power state as an integer. Either 0 or 1.
378 [Arguments] ${quiet}=${QUIET}
379
380 # Description of argument(s):
381 # quiet Indicates whether this keyword should run without any output to
382 # the console.
383
384 @{arglist}= Create List
385 ${args}= Create Dictionary data=@{arglist}
386
387 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
388 ... data=${args} quiet=${quiet}
389 Should be equal as strings ${resp.status_code} ${HTTP_OK}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600390
George Keishing409df052024-01-17 22:36:14 +0530391 RETURN ${resp.json()["data"]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600392
393
394Clear BMC Gard Record
395 [Documentation] Clear gard records from the system.
396
397 @{arglist}= Create List
398 ${args}= Create Dictionary data=@{arglist}
399 ${resp}= Call Method
400 ... ${OPENPOWER_CONTROL}gard Reset data=${args}
401 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
402
403
404Flash PNOR
405 [Documentation] Calls flash bios update method to flash PNOR image
406 [Arguments] ${pnor_image}
407
408 # Description of argument(s):
409 # pnor_image The filename and path of the PNOR image
410 # (e.g. "/home/image/zaius.pnor").
411
412 @{arglist}= Create List ${pnor_image}
413 ${args}= Create Dictionary data=@{arglist}
414 ${resp}= Call Method /org/openbmc/control/flash/bios/ update
415 ... data=${args}
416 should be equal as strings ${resp.status_code} ${HTTP_OK}
417 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
418
419
420Get Flash BIOS Status
421 [Documentation] Returns the status of the flash BIOS API as a string. For
422 ... example 'Flashing', 'Flash Done', etc
423 ${data}= Read Properties /org/openbmc/control/flash/bios
George Keishing409df052024-01-17 22:36:14 +0530424 RETURN ${data['status']}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600425
426
427Is PNOR Flashing
428 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
429 ... flashing has started.
430 ${status}= Get Flash BIOS Status
431 Should Contain ${status} Flashing
432
433
434Is PNOR Flash Done
435 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
436 ... PNOR flashing has completed.
437 ${status}= Get Flash BIOS Status
438 should be equal as strings ${status} Flash Done
439
440
441Create OS Console File Path
442 [Documentation] Create OS console file path name and return it.
443 [Arguments] ${log_file_path}=${EMPTY}
444
445 # Description of arguments:
446 # file_path The caller's candidate value. If this value is ${EMPTY}, this
447 # keyword will compose a file path name. Otherwise, this
448 # keyword will use the caller's file_path value. In either
449 # case, the value will be returned.
450
451 ${status}= Run Keyword And Return Status Variable Should Exist
452 ... ${TEST_NAME}
453
454 ${default_file_path}= Set Variable If ${status} == ${TRUE}
George Keishing9161b102021-12-10 02:26:30 -0600455 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt
456 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_os_console.txt
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600457
458 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
459 ... ${default_file_path} ${log_file_path}
460
George Keishing409df052024-01-17 22:36:14 +0530461 RETURN ${log_file_path}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600462
463
464Get Endpoint Paths
465 [Documentation] Returns all url paths ending with given endpoint
466 ... Example:
467 ... Given the following endpoint: cpu
468 ... This keyword will return: list of all urls ending with
469 ... cpu -
470 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
471 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
472 [Arguments] ${path} ${endpoint}
473
474 # Description of arguments:
475 # path URL path for enumeration.
476 # endpoint Endpoint string (url path ending).
477
Steven Sombaraaaab222018-12-19 13:16:23 -0600478 # Make sure path ends with slash.
479 ${path}= Add Trailing Slash ${path}
480
481 ${resp}= Read Properties ${path}enumerate timeout=30
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600482 Log Dictionary ${resp}
483
484 ${list}= Get Dictionary Keys ${resp}
485 # For a given string, look for prefix and suffix for matching expression.
486 # Start of string followed by zero or more of any character followed by
487 # any digit or lower case character.
George Keishing585afa32020-07-09 04:55:15 -0500488 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[_0-9a-z]*$ case_insensitive=${True}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600489
George Keishing409df052024-01-17 22:36:14 +0530490 RETURN ${resp}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600491
492
493Set BMC Power Policy
494 [Documentation] Set the given BMC power policy.
495 [Arguments] ${policy}
496
497 # Note that this function will translate the old style "RESTORE_LAST_STATE"
498 # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy.
499 # Policy.Restore" for you.
500
501 # Description of argument(s):
502 # policy Power restore policy (e.g "RESTORE_LAST_STATE",
503 # ${RESTORE_LAST_STATE}).
504
505 # Set the bmc_power_policy_method to either 'Old' or 'New'.
506 Set Power Policy Method
507 # This translation helps bridge between old and new method for calling.
508 ${policy}= Translate Power Policy Value ${policy}
509 # Run the appropriate keyword.
510 Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy}
511 ${currentPolicy}= Get System Power Policy
512 Should Be Equal ${currentPolicy} ${policy}
513
514
515Delete Error Logs
516 [Documentation] Delete error logs.
Michael Sheposcc490b42020-08-26 12:53:01 -0500517 [Arguments] ${quiet}=${0}
518 # Description of argument(s):
519 # quiet If enabled, turns off logging to console.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600520
521 # Check if error logs entries exist, if not return.
Steven Sombara8800da2018-12-18 16:19:05 -0600522 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600523 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
524
525 # Get the list of error logs entries and delete them all.
526 ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY}
David Shaw79247e42020-06-18 17:16:02 -0500527 FOR ${entry} IN @{elog_entries}
Michael Sheposcc490b42020-08-26 12:53:01 -0500528 Delete Error Log Entry ${entry} quiet=${quiet}
David Shaw79247e42020-06-18 17:16:02 -0500529 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600530
531
532Delete All Error Logs
533 [Documentation] Delete all error log entries using "DeleteAll" interface.
534
George Keishingfbd67002022-08-01 11:24:03 -0500535 ${args}= Set Variable {"data": []}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600536 ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
George Keishingfbd67002022-08-01 11:24:03 -0500537 ... data=${args}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600538 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
539
540
541Get Elog URL List
542 [Documentation] Return error log entry list of URLs.
543
544 ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/
545 Sort List ${url_list}
George Keishing409df052024-01-17 22:36:14 +0530546 RETURN ${url_list}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600547
548
549Get BMC Flash Chip Boot Side
550 [Documentation] Return the BMC flash chip boot side.
George Keishing034902d2017-11-10 13:15:38 -0600551
552 # Example:
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600553 # 0 - indicates chip select is current side.
554 # 32 - indicates chip select is alternate side.
George Keishing034902d2017-11-10 13:15:38 -0600555
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600556 ${boot_side} ${stderr} ${rc}= BMC Execute Command
557 ... cat /sys/class/watchdog/watchdog1/bootstatus
558
George Keishing409df052024-01-17 22:36:14 +0530559 RETURN ${boot_side}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600560
561
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600562Watchdog Object Should Exist
563 [Documentation] Check that watchdog object exists.
564
565 ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0
566 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
567 ... msg=Expected watchdog object does not exist.
Sweta Potthurif39022d2018-02-06 03:40:07 -0600568
569
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600570Get System LED State
571 [Documentation] Return the state of given system LED.
572 [Arguments] ${led_name}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600573
574 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600575 # led_name System LED name (e.g. heartbeat, identify, beep).
Sweta Potthurif39022d2018-02-06 03:40:07 -0600576
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600577 ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
George Keishing409df052024-01-17 22:36:14 +0530578 RETURN ${state.rsplit('.', 1)[1]}
George Keishingb9f407b2018-02-20 00:07:46 -0600579
580
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600581Verify LED State
582 [Documentation] Checks if LED is in given state.
583 [Arguments] ${led_name} ${led_state}
584 # Description of argument(s):
585 # led_name System LED name (e.g. heartbeat, identify, beep).
586 # led_state LED state to be verified (e.g. On, Off).
George Keishingb9f407b2018-02-20 00:07:46 -0600587
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600588 ${state}= Get System LED State ${led_name}
589 Should Be Equal ${state} ${led_state}
George Keishingb9f407b2018-02-20 00:07:46 -0600590
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600591
592Get LED State XYZ
593 [Documentation] Returns state of given LED.
594 [Arguments] ${led_name}
595
596 # Description of argument(s):
597 # led_name Name of LED.
598
599 ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted
600 # Returns the state of the LED, either On or Off.
George Keishing409df052024-01-17 22:36:14 +0530601 RETURN ${state}
George Keishingb9f407b2018-02-20 00:07:46 -0600602
George Keishing78ce8dc2018-03-30 11:49:06 -0500603
604Verify Identify LED State
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500605 [Documentation] Verify that the identify state of the LED group matches caller's expectations.
George Keishing78ce8dc2018-03-30 11:49:06 -0500606 [Arguments] ${expected_state}
607
608 # Description of argument(s):
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500609 # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted).
George Keishing78ce8dc2018-03-30 11:49:06 -0500610
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500611 ${led_state}= Get LED State XYZ enclosure_identify
612 Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state.
Sweta Potthuri39255032018-03-28 10:12:14 -0500613
614Verify The Attribute
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500615 [Documentation] Verify the given attribute.
Sweta Potthuri39255032018-03-28 10:12:14 -0500616 [Arguments] ${uri} ${attribute_name} ${attribute_value}
617
618 # Description of argument(s):
619 # uri URI path
620 # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable").
621 # attribute_name Name of attribute to be verified (e.g. "TPMEnable").
622 # attribute_value The expected value of attribute (e.g. "1", "0", etc.)
623
624 ${output}= Read Attribute ${uri} ${attribute_name}
625 Should Be Equal ${attribute_value} ${output}
626 ... msg=Attribute "${attribute_name} does not have the expected value.
George Keishingcf0d7772018-05-04 08:22:50 -0500627
628
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600629New Set Power Policy
630 [Documentation] Set the given BMC power policy (new method).
631 [Arguments] ${policy}
George Keishingb4adfc72018-10-26 09:39:32 -0500632
633 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600634 # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}).
George Keishingc5fef582018-07-18 08:41:28 -0500635
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600636 ${valueDict}= Create Dictionary data=${policy}
637 Write Attribute
638 ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict}
George Keishing216e5842018-08-31 14:58:15 -0500639
640
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600641Old Set Power Policy
642 [Documentation] Set the given BMC power policy (old method).
643 [Arguments] ${policy}
George Keishing3c004dc2018-10-10 07:16:47 -0500644
645 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600646 # policy Power restore policy (e.g. "ALWAYS_POWER_OFF").
647
648 ${valueDict}= create dictionary data=${policy}
649 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
George Keishing3c004dc2018-10-10 07:16:47 -0500650
651
George Keishinga54e06f2020-06-12 10:42:41 -0500652Redfish Set Power Restore Policy
653 [Documentation] Set the BMC power restore policy.
654 [Arguments] ${power_restore_policy}
655
656 # Description of argument(s):
657 # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
658
Yi Huc32434a2024-01-11 17:33:10 -0800659 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"PowerRestorePolicy": "${power_restore_policy}"}
George Keishinga54e06f2020-06-12 10:42:41 -0500660 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
661
662
George Keishing9a288602021-12-10 04:50:25 -0600663IPMI Set Power Restore Policy
664 [Documentation] Set the BMC power restore policy using IPMI.
665 [Arguments] ${power_restore_policy}=always-off
666
667 # Description of argument(s):
668 # power_restore_policy Power restore policies
669 # always-on : turn on when power is restored
670 # previous : return to previous state when power is restored
671 # always-off : stay off after power is restored
672
673 ${resp}= Run IPMI Standard Command chassis policy ${power_restore_policy}
674 # Example: Set chassis power restore policy to always-off
675 Should Contain ${resp} ${power_restore_policy}
676
677
George Keishinga5cedb32020-07-17 15:50:34 -0500678Set Auto Reboot Setting
679 [Documentation] Set the given auto reboot setting (REST or Redfish).
680 [Arguments] ${value}
681
682 # Description of argument(s):
683 # value The reboot setting, 1 for enabling and 0 for disabling.
684
685 # This is to cater to boot call points and plugin script which will always
686 # send using value 0 or 1. This dictionary maps to redfish string values.
687 ${rest_redfish_dict}= Create Dictionary
688 ... 1=RetryAttempts
689 ... 0=Disabled
690
George Keishing0628c4f2025-06-24 23:58:47 +0530691 IF ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
692 Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
693 ELSE
694 Set Auto Reboot ${value}
695 END
George Keishinga5cedb32020-07-17 15:50:34 -0500696
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600697Set Auto Reboot
698 [Documentation] Set the given auto reboot setting.
699 [Arguments] ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500700
701 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600702 # setting The reboot setting, 1 for enabling and 0 for disabling.
George Keishing3c004dc2018-10-10 07:16:47 -0500703
Sridevi Ramesh68d72ff2019-02-04 09:24:46 -0600704 ${valueDict}= Convert To Integer ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600705 ${data}= Create Dictionary data=${valueDict}
706 Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data}
707 ${current_setting}= Get Auto Reboot
708 Should Be Equal As Integers ${current_setting} ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500709
George Keishingc25c55d2018-10-30 02:23:44 -0500710
George Keishingc8a6dd22020-06-12 12:01:33 -0500711Redfish Set Auto Reboot
712 [Documentation] Set the given auto reboot setting.
713 [Arguments] ${setting}
714
715 # Description of argument(s):
716 # setting The reboot setting, "RetryAttempts" and "Disabled".
717
Yi Huc32434a2024-01-11 17:33:10 -0800718 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
George Keishinga8cb28d2020-06-15 03:10:29 -0500719 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
George Keishinga8cb28d2020-06-15 03:10:29 -0500720
George Keishingc8a6dd22020-06-12 12:01:33 -0500721 ${current_setting}= Redfish Get Auto Reboot
722 Should Be Equal As Strings ${current_setting} ${setting}
723
724
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600725Set Control Boot Mode
726 [Documentation] Set given boot mode on the boot object path attribute.
727 [Arguments] ${boot_path} ${boot_mode}
George Keishingc25c55d2018-10-30 02:23:44 -0500728
729 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600730 # boot_path Boot object path.
731 # Example:
732 # /xyz/openbmc_project/control/host0/boot
733 # /xyz/openbmc_project/control/host0/boot/one_time
734 # boot_mode Boot mode which need to be set.
735 # Example:
736 # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
George Keishingc25c55d2018-10-30 02:23:44 -0500737
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600738 ${valueDict}= Create Dictionary data=${boot_mode}
739 Write Attribute ${boot_path} BootMode data=${valueDict}
George Keishingc25c55d2018-10-30 02:23:44 -0500740
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600741
742Is Power On
743 [Documentation] Verify that the BMC chassis state is on.
744 ${state}= Get Power State
745 Should be equal ${state} ${1}
746
747
748Is Power Off
749 [Documentation] Verify that the BMC chassis state is off.
750 ${state}= Get Power State
751 Should be equal ${state} ${0}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500752
753
754CLI Get BMC DateTime
755 [Documentation] Returns BMC date time from date command.
756
rramyasr-ined0c14a2025-03-03 03:35:04 -0600757 ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%dT%H:%M:%S" print_err=1
George Keishing409df052024-01-17 22:36:14 +0530758 RETURN ${bmc_time_via_date}
George Keishing61364e52019-10-01 12:01:19 -0500759
760
761Update Root Password
762 [Documentation] Update system "root" user password.
763 [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD}
764
765 # Description of argument(s):
766 # openbmc_password The root password for the open BMC system.
767
768 @{password}= Create List ${openbmc_password}
769 ${data}= Create Dictionary data=@{password}
770
771 ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
George Keishingfbd67002022-08-01 11:24:03 -0500772 ${resp}= POST On Session openbmc ${BMC_USER_URI}root/action/SetPassword
George Keishing61364e52019-10-01 12:01:19 -0500773 ... data=${data} headers=${headers}
774 Valid Value resp.status_code [${HTTP_OK}]
Sushil Singh6624ce52020-01-22 00:53:41 -0600775
776
777Get Post Boot Action
778 [Documentation] Get post boot action.
779
George Keishing879f0842020-02-05 11:00:47 -0600780 # Post code update action dictionary.
Sushil Singh6624ce52020-01-22 00:53:41 -0600781 #
782 # {
783 # BMC image: {
784 # OnReset: Redfish OBMC Reboot (off),
785 # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
786 # },
787 # Host image: {
George Keishinge523fc02020-03-23 12:28:01 -0500788 # OnReset: RF SYS GracefulRestart,
Sushil Singh6624ce52020-01-22 00:53:41 -0600789 # Immediate: Wait State os_running_match_state 10 mins
790 # }
791 # }
792
793 ${code_base_dir_path}= Get Code Base Dir Path
794 ${post_code_update_actions}= Evaluate
795 ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
796 Rprint Vars post_code_update_actions
797
George Keishing409df052024-01-17 22:36:14 +0530798 RETURN ${post_code_update_actions}
Sushil Singh6624ce52020-01-22 00:53:41 -0600799
George Keishing1eeff9c2020-06-16 04:03:34 -0500800
Sushil Singh1560e652022-08-03 13:25:01 -0500801Get Task State From File
802 [Documentation] Get task states from pre-define data/task_state.json file.
803
804 # Example: Task state JSON format.
805 #
806 # {
807 # "TaskRunning": {
808 # "TaskState": "Running",
809 # "TaskStatus": "OK"
810 # },
811 # "TaskCompleted": {
812 # "TaskState": "Completed",
813 # "TaskStatus": "OK"
814 # },
815 # "TaskException": {
816 # "TaskState": "Exception",
817 # "TaskStatus": "Warning"
818 # }
819 # }
820
821 # Python module: get_code_base_dir_path()
822 ${code_base_dir_path}= Get Code Base Dir Path
823 ${task_state}= Evaluate
824 ... json.load(open('${code_base_dir_path}data/task_state.json')) modules=json
825 Rprint Vars task_state
826
George Keishing409df052024-01-17 22:36:14 +0530827 RETURN ${task_state}
Sushil Singh1560e652022-08-03 13:25:01 -0500828
829
George Keishing1eeff9c2020-06-16 04:03:34 -0500830Redfish Set Boot Default
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300831 [Documentation] Set and Verify Boot source override
832 [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI
George Keishing1eeff9c2020-06-16 04:03:34 -0500833
834 # Description of argument(s):
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300835 # override_enabled Boot source override enable type.
George Keishing1eeff9c2020-06-16 04:03:34 -0500836 # ('Once', 'Continuous', 'Disabled').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300837 # override_target Boot source override target.
George Keishing1eeff9c2020-06-16 04:03:34 -0500838 # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300839 # override_mode Boot source override mode (relevant only for x86 arch).
840 # ('Legacy', 'UEFI').
George Keishing1eeff9c2020-06-16 04:03:34 -0500841
842 ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled}
843 ... BootSourceOverrideTarget=${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300844
George Keishing0628c4f2025-06-24 23:58:47 +0530845 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
846 Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
847 END
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300848
George Keishing1eeff9c2020-06-16 04:03:34 -0500849 ${payload}= Create Dictionary Boot=${data}
850
Yi Huc32434a2024-01-11 17:33:10 -0800851 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body=&{payload}
George Keishing1eeff9c2020-06-16 04:03:34 -0500852 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
853
Yi Huc32434a2024-01-11 17:33:10 -0800854 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing1eeff9c2020-06-16 04:03:34 -0500855 Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled}
856 Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target}
George Keishing0628c4f2025-06-24 23:58:47 +0530857 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
858 Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
859 END
George Keishinge1879642020-12-09 13:20:15 -0600860
861
862# Redfish state keywords.
863
864Redfish Get BMC State
865 [Documentation] Return BMC health state.
866
867 # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady
868
869 # Example:
870 # "Status": {
871 # "Health": "OK",
872 # "HealthRollup": "OK",
873 # "State": "Enabled"
874 # },
875
George Keishing43909f32024-08-20 22:08:02 +0530876 ${status}= Wait Until Keyword Succeeds 1 min 20 sec
877 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
George Keishing409df052024-01-17 22:36:14 +0530878 RETURN ${status["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600879
880
Sushil Singh472177b2023-08-28 05:28:30 -0500881Redfish Verify BMC State
882 [Documentation] Verify BMC state is enabled.
883 [Arguments] ${match_state}=Enabled
884
885 # Description of argument(s):
886 # match_state Expected match state (e.g. Enabled, Starting, Error)
887
George Keishing43909f32024-08-20 22:08:02 +0530888 ${Status}= Wait Until Keyword Succeeds 1 min 20 sec
889 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
Sushil Singh472177b2023-08-28 05:28:30 -0500890
891 Should Be Equal As Strings ${match_state} ${Status['State']}
892
893
George Keishinge1879642020-12-09 13:20:15 -0600894Redfish Get Host State
895 [Documentation] Return host power and health state.
896
897 # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status
898
899 # Example:
900 # "PowerState": "Off",
901 # "Status": {
902 # "Health": "OK",
903 # "HealthRollup": "OK",
904 # "State": "StandbyOffline"
905 # },
906
George Keishing43909f32024-08-20 22:08:02 +0530907 ${chassis}= Wait Until Keyword Succeeds 1 min 20 sec
908 ... Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}
George Keishing409df052024-01-17 22:36:14 +0530909 RETURN ${chassis["PowerState"]} ${chassis["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600910
911
912Redfish Get Boot Progress
913 [Documentation] Return boot progress state.
914
915 # Example: /redfish/v1/Systems/system/
916 # "BootProgress": {
917 # "LastState": "OSRunning"
918 # },
919
George Keishing43909f32024-08-20 22:08:02 +0530920 ${boot_progress}= Wait Until Keyword Succeeds 1 min 20 sec
921 ... Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/
George Keishingb51d1502021-03-25 03:30:33 -0500922
923 Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86"
924 ... NA ${boot_progress["Status"]["State"]}
925
George Keishing409df052024-01-17 22:36:14 +0530926 RETURN ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600927
928
929Redfish Get States
930 [Documentation] Return all the BMC and host states in dictionary.
Sushil Singhfd0f91b2023-11-10 07:35:11 -0600931 [Timeout] ${REDFISH_SYS_STATE_WAIT_TIMEOUT}
George Keishinge1879642020-12-09 13:20:15 -0600932
933 # Refer: openbmc/docs/designs/boot-progress.md
934
George Keishing205f95f2021-03-10 02:25:53 -0600935 Redfish.Login
George Keishinge1879642020-12-09 13:20:15 -0600936
937 ${bmc_state}= Redfish Get BMC State
938 ${chassis_state} ${chassis_status}= Redfish Get Host State
939 ${boot_progress} ${host_state}= Redfish Get Boot Progress
940
941 ${states}= Create Dictionary
942 ... bmc=${bmc_state}
943 ... chassis=${chassis_state}
944 ... host=${host_state}
945 ... boot_progress=${boot_progress}
946
George Keishing64293c52021-03-24 08:21:23 -0500947 # Disable loggoing state to prevent huge log.html record when boot
948 # test is run in loops.
949 #Log ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600950
George Keishing409df052024-01-17 22:36:14 +0530951 RETURN ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600952
953
Sushil Singh80029902023-03-06 01:33:00 -0600954Is BMC Not Quiesced
955 [Documentation] Verify BMC state is not quiesced.
956
957 ${bmc_state}= Redfish Get States
958
959 Log To Console BMC State : ${bmc_state}
960
961 Should Not Be Equal As Strings Quiesced ${bmc_state['bmc']}
962
963
George Keishing95cf8652021-02-08 11:32:33 -0600964Is BMC Standby
965 [Documentation] Check if BMC is ready and host at standby.
966
967 ${standby_states}= Create Dictionary
968 ... bmc=Enabled
969 ... chassis=Off
970 ... host=Disabled
971 ... boot_progress=None
972
George Keishing0628c4f2025-06-24 23:58:47 +0530973 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
974 Set To Dictionary ${standby_states} boot_progress=NA
975 END
aravinth0510de1863d2022-06-27 17:26:14 +0000976
George Keishing95cf8652021-02-08 11:32:33 -0600977 Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States
978
Rahul Maheshwari258d5922022-11-27 01:04:39 -0600979 Wait Until Keyword Succeeds 5 min 10 sec Match State ${standby_states}
George Keishing95cf8652021-02-08 11:32:33 -0600980
981
982Match State
983 [Documentation] Check if the expected and current states are matched.
984 [Arguments] ${match_state}
985
986 # Description of argument(s):
987 # match_state Expected states in dictionary.
988
989 ${current_state}= Redfish Get States
990 Dictionaries Should Be Equal ${match_state} ${current_state}
Peter D Phan49739b22021-09-29 14:30:08 -0500991
992
praphullasuresh95589b32023-08-24 08:59:28 -0500993Wait For Host Boot Progress To Reach Required State
994 [Documentation] Wait till host boot progress reaches required state.
praphullasuresheacfac92023-08-25 06:51:01 -0500995 [Arguments] ${expected_boot_state}=OSRunning
praphullasuresh95589b32023-08-24 08:59:28 -0500996
997 # Description of argument(s):
998 # expected_boot_state Expected boot state. E.g. OSRunning, SystemInitComplete etc.
999
1000 Wait Until Keyword Succeeds ${power_on_timeout} 20 sec
1001 ... Is Boot Progress At Required State ${expected_boot_state}
1002
1003
Peter D Phan49739b22021-09-29 14:30:08 -05001004Redfish Initiate Auto Reboot
1005 [Documentation] Initiate an auto reboot.
1006 [Arguments] ${interval}=2000
1007
1008 # Description of argument(s):
1009 # interval Value in milliseconds to set Watchdog interval
1010
1011 # Set auto reboot policy
1012 Redfish Set Auto Reboot RetryAttempts
1013
George Keishingc0701102021-09-30 12:12:04 -05001014 Redfish Power Operation On
George Keishinga4e13522022-04-13 11:14:53 -05001015
1016 Wait Until Keyword Succeeds 2 min 5 sec Is Boot Progress Changed
George Keishingc0701102021-09-30 12:12:04 -05001017
Peter D Phan49739b22021-09-29 14:30:08 -05001018 # Set watchdog timer
1019 Set Watchdog Interval Using Busctl ${interval}
1020
1021
George Keishinga4e13522022-04-13 11:14:53 -05001022Is Boot Progress Changed
1023 [Documentation] Get BootProgress state and expect boot state mismatch.
1024 [Arguments] ${boot_state}=None
1025
1026 # Description of argument(s):
1027 # boot_state Value of the BootProgress state to match against.
1028
1029 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1030
1031 Should Not Be Equal ${boot_progress} ${boot_state}
1032
Peter D Phan49739b22021-09-29 14:30:08 -05001033
Sridevi Ramesh13d84bf2022-10-31 09:14:52 -05001034Is Boot Progress At Required State
1035 [Documentation] Get BootProgress state and expect boot state to match.
1036 [Arguments] ${boot_state}=None
1037
1038 # Description of argument(s):
1039 # boot_state Value of the BootProgress state to match.
1040
1041 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1042
1043 Should Be Equal ${boot_progress} ${boot_state}
1044
1045
1046Is Boot Progress At Any State
1047 [Documentation] Get BootProgress state and expect boot state to match
1048 ... with any of the states mentioned in the list.
1049 [Arguments] ${boot_states}=@{BOOT_PROGRESS_STATES}
1050
1051 # Description of argument(s):
1052 # boot_states List of the BootProgress states to match.
1053
1054 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1055 Should Contain Any ${boot_progress} @{boot_states}
1056
1057
Sagar Anand0e262662023-01-24 11:36:01 -06001058Is Host At State
1059 [Documentation] Get Host state and check if it matches
1060 ... user input expected state.
1061 [Arguments] ${expected_host_state}
1062
1063 # Description of argument(s):
1064 # expected_host_state Expected Host State to check.(e.g. Quiesced).
1065
1066 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1067
1068 Should Be Equal ${host_state} ${expected_host_state}
1069
1070
Peter D Phan49739b22021-09-29 14:30:08 -05001071Set Watchdog Interval Using Busctl
1072 [Documentation] Set Watchdog time interval.
1073 [Arguments] ${milliseconds}=1000
1074
1075 # Description of argument(s):
George Keishing4b729492021-11-10 12:51:10 -06001076 # milliseconds Time interval for watchdog timer
Peter D Phan49739b22021-09-29 14:30:08 -05001077
George Keishingc0701102021-09-30 12:12:04 -05001078 ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog
1079 ... /xyz/openbmc_project/watchdog/host0
1080 ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds}
Peter D Phan49739b22021-09-29 14:30:08 -05001081 BMC Execute Command ${cmd}
1082
George Keishingf5fec0d2021-10-08 12:38:45 -05001083
1084Stop PLDM Service And Wait
1085 [Documentation] Stop PLDM service and wait for Host to initiate reset.
1086
1087 BMC Execute Command systemctl stop pldmd.service
1088
George Keishingca76e372022-03-16 12:45:26 -05001089
1090Get BIOS Attribute
1091 [Documentation] Get the BIOS attribute for /redfish/v1/Systems/system/Bios.
1092
1093 # Python module: get_member_list(resource_path)
1094 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1095 ${bios_attr_dict}= Redfish.Get Attribute ${systems[0]}/Bios Attributes
1096
George Keishing409df052024-01-17 22:36:14 +05301097 RETURN ${bios_attr_dict}
nagarjunb22cfb2c412022-03-15 15:49:27 +05301098
George Keishing8f610e72022-03-28 10:43:08 -05001099
1100Set BIOS Attribute
1101 [Documentation] PATCH the BIOS attribute for /redfish/v1/Systems/system/Bios.
1102 [Arguments] ${attribute_name} ${attribute_value}
1103
1104 # Description of argument(s):
1105 # attribute_name Any valid BIOS attribute.
1106 # attribute_value Valid allowed attribute values.
1107
1108 # Python module: get_member_list(resource_path)
1109 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1110 Redfish.Patch ${systems[0]}/Bios/Settings body={"Attributes":{"${attribute_name}":"${attribute_value}"}}
1111
1112
nagarjunb22cfb2c412022-03-15 15:49:27 +05301113Is BMC Operational
1114 [Documentation] Check if BMC is enabled.
ganesanb13fb3cf2023-05-12 00:42:18 +00001115 [Teardown] Redfish.Logout
nagarjunb22cfb2c412022-03-15 15:49:27 +05301116
ganesanb13fb3cf2023-05-12 00:42:18 +00001117 Wait Until Keyword Succeeds 5 min 5 sec Ping Host ${OPENBMC_HOST}
1118 # In some of bmc stack, network services will gets loaded before redfish/ipmi services gets loaded.
1119 # Hence, 3mins sleep time is added to allow other service gets loaded.
1120 Sleep 180s
1121 Redfish.login
1122 ${bmc_status}= Redfish Get BMC State
nagarjunb22cfb2c412022-03-15 15:49:27 +05301123 Should Be Equal ${bmc_status} Enabled
George Keishing83c737b2022-05-17 12:12:04 -05001124
1125
1126PLDM Set BIOS Attribute
1127 [Documentation] Set the BIOS attribute via pldmtool and verify the attribute is set.
1128 ... Defaulted for fw_boot_side for boot test usage caller.
1129 [Arguments] ${attribute_name}=fw_boot_side ${attribute_value}=Temp
1130
1131 # Description of argument(s):
1132 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1133 # attribute_value Valid BIOS attribute value for fw_boot_side.
1134
1135 # PLDM response output example:
1136 # {
1137 # "Response": "SUCCESS"
1138 # }
1139
1140 ${resp}= pldmtool bios SetBIOSAttributeCurrentValue -a ${attribute_name} -d ${attribute_value}
1141 Should Be Equal As Strings ${resp["Response"]} SUCCESS
1142
1143 # PLDM GET output example:
1144 # {
1145 # "CurrentValue": "Temp"
1146 # }
1147
1148 ${pldm_output}= PLDM Get BIOS Attribute ${attribute_name}
1149 Should Be Equal As Strings ${pldm_output["CurrentValue"]} ${attribute_value}
1150 ... msg=Expecting ${attribute_value} but got ${pldm_output["CurrentValue"]}
1151
1152
1153PLDM Get BIOS Attribute
1154 [Documentation] Get the BIOS attribute via pldmtool for a given attribute and return value.
1155 [Arguments] ${attribute_name}
1156
1157 # Description of argument(s):
1158 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1159
1160 ${pldm_output}= pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${attribute_name}
George Keishing409df052024-01-17 22:36:14 +05301161 RETURN ${pldm_output}
nagarjunb2200108dc2022-07-12 21:50:45 +05301162
1163
1164Verify Host Power State
1165 [Documentation] Get the Host Power state and compare it with the expected state.
1166 [Arguments] ${expected_power_state}
1167
1168 # Description of argument(s):
1169 # expected_power_state State of Host e.g. Off or On.
1170
1171 ${power_state} ${health_status}= Redfish Get Host State
1172 Should Be Equal ${power_state} ${expected_power_state}
1173
1174
1175Verify Host Is Up
1176 [Documentation] Verify Host is Up.
1177
1178 Wait Until Keyword Succeeds 3 min 30 sec Verify Host Power State On
1179 # Python module: os_execute(cmd)
1180 Wait Until Keyword Succeeds 10 min 30 sec OS Execute Command uptime