blob: 844d1416880c35bb52376b3ff7f36ca3450993b8 [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
Raghavendra Prabhu3128a732025-08-07 06:04:24 -0500170 ${cmd_buf}= Set Variable If '${os_username}' == 'root' reboot
171 ... echo ${os_password} | sudo -S reboot
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600172
173 ${output} ${stderr} ${rc}= OS Execute Command
174 ... ${cmd_buf} fork=${1}
175
176
177Initiate OS Host Power Off
178 [Documentation] Initiate an OS reboot.
179 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
180 ... ${os_password}=${OS_PASSWORD} ${hard}=${0}
181
182 # Description of argument(s):
183 # os_host The DNS name or IP of the OS.
184 # os_username The username to be used to sign in to the OS.
185 # os_password The password to be used to sign in to the OS.
186 # hard Indicates whether to do a hard vs. soft power off.
187
Raghavendra Prabhu3128a732025-08-07 06:04:24 -0500188 ${time_string}= Set Variable If ${hard} ${SPACE}now
189 ... ${EMPTY}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600190
Raghavendra Prabhu3128a732025-08-07 06:04:24 -0500191 ${cmd_buf}= Set Variable If '${os_username}' == 'root' shutdown${time_string}
192 ... echo ${os_password} | sudo -S shutdown${time_string}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600193
194 ${output} ${stderr} ${rc}= OS Execute Command
195 ... ${cmd_buf} fork=${1}
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500196
George Keishing3987a1e2017-09-20 09:13:02 -0500197
Steven Sombar5f3af442018-02-14 08:30:15 -0600198Set System LED State
199 [Documentation] Set given system LED via REST.
200 [Arguments] ${led_name} ${led_state}
201 # Description of argument(s):
202 # led_name System LED name (e.g. heartbeat, identify, beep).
203 # led_state LED state to be set (e.g. On, Off).
204
205 ${args}= Create Dictionary
206 ... data=xyz.openbmc_project.Led.Physical.Action.${led_state}
207 Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args}
208
209 Verify LED State ${led_name} ${led_state}
210
211
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600212Old Get Boot Progress
213 [Documentation] Get the boot progress the old way (via org location).
214 [Arguments] ${quiet}=${QUIET}
George Keishing034902d2017-11-10 13:15:38 -0600215
216 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600217 # quiet Indicates whether this keyword should run without any output to
218 # the console.
219
220 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
221 ... value quiet=${quiet}
222
George Keishing409df052024-01-17 22:36:14 +0530223 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600224
225
226Set Boot Progress Method
227 [Documentation] Set the boot_prog_method to either 'Old' or 'New'.
228
229 # The boot progress data has moved from an 'org' location to an 'xyz'
230 # location. This keyword will determine whether the new method of getting
231 # the boot progress is valid and will set the global boot_prog_method
232 # variable accordingly. If boot_prog_method is already set (either by a
233 # prior call to this function or via a -v parm), this keyword will simply
234 # return.
235
236 # Note: There are interim builds that contain boot_progress in both the
237 # old and the new location values. It is nearly impossible for this
238 # keyword to determine whether the old boot_progress or the new one is
239 # active. When using such builds where the old boot_progress is active,
240 # the only recourse users will have is that they may specify
241 # -v boot_prog_method:Old to force old behavior on such builds.
242
George Keishing0628c4f2025-06-24 23:58:47 +0530243 IF '${boot_prog_method}' != '${EMPTY}' Return From Keyword
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600244
245 ${new_status} ${new_value}= Run Keyword And Ignore Error
246 ... New Get Boot Progress
247 # If the new style read fails, the method must necessarily be "Old".
George Keishing0628c4f2025-06-24 23:58:47 +0530248 IF '${new_status}' == 'PASS'
249 Set Global Variable ${boot_prog_method} New
250 Rqpvars boot_prog_method
251 Return From Keyword
252 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600253
254 # Default method is "Old".
255 Set Global Variable ${boot_prog_method} Old
256 Rqpvars boot_prog_method
257
258
259Initiate Power On
260 [Documentation] Initiates the power on and waits until the Is Power On
261 ... keyword returns that the power state has switched to on.
262 [Arguments] ${wait}=${1}
263
264 # Description of argument(s):
265 # wait Indicates whether to wait for a powered on state after issuing
266 # the power on command.
267
268 @{arglist}= Create List
269 ${args}= Create Dictionary data=@{arglist}
270 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
271 ... data=${args}
272 should be equal as strings ${resp.status_code} ${HTTP_OK}
273
274 # Does caller want to wait for power on status?
George Keishing0628c4f2025-06-24 23:58:47 +0530275 IF '${wait}' == '${0}' Return From Keyword
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600276 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
277
278
279Initiate Power Off
280 [Documentation] Initiates the power off and waits until the Is Power Off
281 ... keyword returns that the power state has switched to off.
282
283 @{arglist}= Create List
284 ${args}= Create Dictionary data=@{arglist}
285 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
286 ... data=${args}
287 should be equal as strings ${resp.status_code} ${HTTP_OK}
288 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
289
290
291Get Boot Progress
292 [Documentation] Get the boot progress and return it.
293 [Arguments] ${quiet}=${QUIET}
294
295 # Description of argument(s):
296 # quiet Indicates whether this keyword should run without any output to
297 # the console.
298
299 Set Boot Progress Method
Raghavendra Prabhu3128a732025-08-07 06:04:24 -0500300 IF '${boot_prog_method}' == 'New'
301 ${state}= New Get Boot Progress quiet=${quiet}
302 ELSE
303 ${state}= Old Get Boot Progress quiet=${quiet}
304 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600305
George Keishing409df052024-01-17 22:36:14 +0530306 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600307
308
309New Get Boot Progress
310 [Documentation] Get the boot progress the new way (via xyz location).
311 [Arguments] ${quiet}=${QUIET}
312
313 # Description of argument(s):
314 # quiet Indicates whether this keyword should run without any output to
315 # the console.
316
317 ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet}
318
George Keishing409df052024-01-17 22:36:14 +0530319 RETURN ${state.rsplit('.', 1)[1]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600320
321
322New Get Power Policy
323 [Documentation] Returns the BMC power policy (new method).
324 ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy
325
George Keishing409df052024-01-17 22:36:14 +0530326 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600327
328
329Old Get Power Policy
330 [Documentation] Returns the BMC power policy (old method).
331 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
332
George Keishing409df052024-01-17 22:36:14 +0530333 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600334
335
George Keishinga54e06f2020-06-12 10:42:41 -0500336Redfish Get Power Restore Policy
337 [Documentation] Returns the BMC power restore policy.
338
Yi Huc32434a2024-01-11 17:33:10 -0800339 ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} PowerRestorePolicy
George Keishing409df052024-01-17 22:36:14 +0530340 RETURN ${power_restore_policy}
341
George Keishinga54e06f2020-06-12 10:42:41 -0500342
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600343Get Auto Reboot
344 [Documentation] Returns auto reboot setting.
345 ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
346
George Keishing409df052024-01-17 22:36:14 +0530347 RETURN ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600348
349
George Keishingc8a6dd22020-06-12 12:01:33 -0500350Redfish Get Auto Reboot
351 [Documentation] Returns auto reboot setting.
352
George Keishing43909f32024-08-20 22:08:02 +0530353 ${resp}= Wait Until Keyword Succeeds 1 min 20 sec
354 ... Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing409df052024-01-17 22:36:14 +0530355 RETURN ${resp["AutomaticRetryConfig"]}
George Keishingc8a6dd22020-06-12 12:01:33 -0500356
357
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600358Trigger Warm Reset
359 [Documentation] Initiate a warm reset.
360
361 log to console "Triggering warm reset"
362 ${data}= create dictionary data=@{EMPTY}
George Keishingfbd67002022-08-01 11:24:03 -0500363 ${resp}= Openbmc Post Request
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600364 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
365 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
366 ${session_active}= Check If warmReset is Initiated
George Keishing0628c4f2025-06-24 23:58:47 +0530367 IF '${session_active}' == '${True}' Fail msg=warm reset didn't occur
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600368
369 Sleep ${SYSTEM_SHUTDOWN_TIME}min
370 Check If BMC Is Up
371
372
373Get Power State
374 [Documentation] Returns the power state as an integer. Either 0 or 1.
375 [Arguments] ${quiet}=${QUIET}
376
377 # Description of argument(s):
378 # quiet Indicates whether this keyword should run without any output to
379 # the console.
380
381 @{arglist}= Create List
382 ${args}= Create Dictionary data=@{arglist}
383
384 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
385 ... data=${args} quiet=${quiet}
386 Should be equal as strings ${resp.status_code} ${HTTP_OK}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600387
George Keishing409df052024-01-17 22:36:14 +0530388 RETURN ${resp.json()["data"]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600389
390
391Clear BMC Gard Record
392 [Documentation] Clear gard records from the system.
393
394 @{arglist}= Create List
395 ${args}= Create Dictionary data=@{arglist}
396 ${resp}= Call Method
397 ... ${OPENPOWER_CONTROL}gard Reset data=${args}
398 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
399
400
401Flash PNOR
402 [Documentation] Calls flash bios update method to flash PNOR image
403 [Arguments] ${pnor_image}
404
405 # Description of argument(s):
406 # pnor_image The filename and path of the PNOR image
407 # (e.g. "/home/image/zaius.pnor").
408
409 @{arglist}= Create List ${pnor_image}
410 ${args}= Create Dictionary data=@{arglist}
411 ${resp}= Call Method /org/openbmc/control/flash/bios/ update
412 ... data=${args}
413 should be equal as strings ${resp.status_code} ${HTTP_OK}
414 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
415
416
417Get Flash BIOS Status
418 [Documentation] Returns the status of the flash BIOS API as a string. For
419 ... example 'Flashing', 'Flash Done', etc
420 ${data}= Read Properties /org/openbmc/control/flash/bios
George Keishing409df052024-01-17 22:36:14 +0530421 RETURN ${data['status']}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600422
423
424Is PNOR Flashing
425 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
426 ... flashing has started.
427 ${status}= Get Flash BIOS Status
428 Should Contain ${status} Flashing
429
430
431Is PNOR Flash Done
432 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
433 ... PNOR flashing has completed.
434 ${status}= Get Flash BIOS Status
435 should be equal as strings ${status} Flash Done
436
437
438Create OS Console File Path
439 [Documentation] Create OS console file path name and return it.
440 [Arguments] ${log_file_path}=${EMPTY}
441
442 # Description of arguments:
443 # file_path The caller's candidate value. If this value is ${EMPTY}, this
444 # keyword will compose a file path name. Otherwise, this
445 # keyword will use the caller's file_path value. In either
446 # case, the value will be returned.
447
448 ${status}= Run Keyword And Return Status Variable Should Exist
449 ... ${TEST_NAME}
450
451 ${default_file_path}= Set Variable If ${status} == ${TRUE}
George Keishing9161b102021-12-10 02:26:30 -0600452 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt
453 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_os_console.txt
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600454
455 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
456 ... ${default_file_path} ${log_file_path}
457
George Keishing409df052024-01-17 22:36:14 +0530458 RETURN ${log_file_path}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600459
460
461Get Endpoint Paths
462 [Documentation] Returns all url paths ending with given endpoint
463 ... Example:
464 ... Given the following endpoint: cpu
465 ... This keyword will return: list of all urls ending with
466 ... cpu -
467 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
468 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
469 [Arguments] ${path} ${endpoint}
470
471 # Description of arguments:
472 # path URL path for enumeration.
473 # endpoint Endpoint string (url path ending).
474
Steven Sombaraaaab222018-12-19 13:16:23 -0600475 # Make sure path ends with slash.
476 ${path}= Add Trailing Slash ${path}
477
478 ${resp}= Read Properties ${path}enumerate timeout=30
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600479 Log Dictionary ${resp}
480
481 ${list}= Get Dictionary Keys ${resp}
482 # For a given string, look for prefix and suffix for matching expression.
483 # Start of string followed by zero or more of any character followed by
484 # any digit or lower case character.
George Keishing585afa32020-07-09 04:55:15 -0500485 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[_0-9a-z]*$ case_insensitive=${True}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600486
George Keishing409df052024-01-17 22:36:14 +0530487 RETURN ${resp}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600488
489
490Set BMC Power Policy
491 [Documentation] Set the given BMC power policy.
492 [Arguments] ${policy}
493
494 # Note that this function will translate the old style "RESTORE_LAST_STATE"
495 # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy.
496 # Policy.Restore" for you.
497
498 # Description of argument(s):
499 # policy Power restore policy (e.g "RESTORE_LAST_STATE",
500 # ${RESTORE_LAST_STATE}).
501
502 # Set the bmc_power_policy_method to either 'Old' or 'New'.
503 Set Power Policy Method
504 # This translation helps bridge between old and new method for calling.
505 ${policy}= Translate Power Policy Value ${policy}
506 # Run the appropriate keyword.
507 Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy}
508 ${currentPolicy}= Get System Power Policy
509 Should Be Equal ${currentPolicy} ${policy}
510
511
512Delete Error Logs
513 [Documentation] Delete error logs.
Michael Sheposcc490b42020-08-26 12:53:01 -0500514 [Arguments] ${quiet}=${0}
515 # Description of argument(s):
516 # quiet If enabled, turns off logging to console.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600517
518 # Check if error logs entries exist, if not return.
Steven Sombara8800da2018-12-18 16:19:05 -0600519 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600520 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
521
522 # Get the list of error logs entries and delete them all.
523 ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY}
David Shaw79247e42020-06-18 17:16:02 -0500524 FOR ${entry} IN @{elog_entries}
Michael Sheposcc490b42020-08-26 12:53:01 -0500525 Delete Error Log Entry ${entry} quiet=${quiet}
David Shaw79247e42020-06-18 17:16:02 -0500526 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600527
528
529Delete All Error Logs
530 [Documentation] Delete all error log entries using "DeleteAll" interface.
531
George Keishingfbd67002022-08-01 11:24:03 -0500532 ${args}= Set Variable {"data": []}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600533 ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
George Keishingfbd67002022-08-01 11:24:03 -0500534 ... data=${args}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600535 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
536
537
538Get Elog URL List
539 [Documentation] Return error log entry list of URLs.
540
541 ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/
542 Sort List ${url_list}
George Keishing409df052024-01-17 22:36:14 +0530543 RETURN ${url_list}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600544
545
546Get BMC Flash Chip Boot Side
547 [Documentation] Return the BMC flash chip boot side.
George Keishing034902d2017-11-10 13:15:38 -0600548
549 # Example:
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600550 # 0 - indicates chip select is current side.
551 # 32 - indicates chip select is alternate side.
George Keishing034902d2017-11-10 13:15:38 -0600552
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600553 ${boot_side} ${stderr} ${rc}= BMC Execute Command
554 ... cat /sys/class/watchdog/watchdog1/bootstatus
555
George Keishing409df052024-01-17 22:36:14 +0530556 RETURN ${boot_side}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600557
558
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600559Watchdog Object Should Exist
560 [Documentation] Check that watchdog object exists.
561
562 ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0
563 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
564 ... msg=Expected watchdog object does not exist.
Sweta Potthurif39022d2018-02-06 03:40:07 -0600565
566
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600567Get System LED State
568 [Documentation] Return the state of given system LED.
569 [Arguments] ${led_name}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600570
571 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600572 # led_name System LED name (e.g. heartbeat, identify, beep).
Sweta Potthurif39022d2018-02-06 03:40:07 -0600573
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600574 ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
George Keishing409df052024-01-17 22:36:14 +0530575 RETURN ${state.rsplit('.', 1)[1]}
George Keishingb9f407b2018-02-20 00:07:46 -0600576
577
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600578Verify LED State
579 [Documentation] Checks if LED is in given state.
580 [Arguments] ${led_name} ${led_state}
581 # Description of argument(s):
582 # led_name System LED name (e.g. heartbeat, identify, beep).
583 # led_state LED state to be verified (e.g. On, Off).
George Keishingb9f407b2018-02-20 00:07:46 -0600584
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600585 ${state}= Get System LED State ${led_name}
586 Should Be Equal ${state} ${led_state}
George Keishingb9f407b2018-02-20 00:07:46 -0600587
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600588
589Get LED State XYZ
590 [Documentation] Returns state of given LED.
591 [Arguments] ${led_name}
592
593 # Description of argument(s):
594 # led_name Name of LED.
595
596 ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted
597 # Returns the state of the LED, either On or Off.
George Keishing409df052024-01-17 22:36:14 +0530598 RETURN ${state}
George Keishingb9f407b2018-02-20 00:07:46 -0600599
George Keishing78ce8dc2018-03-30 11:49:06 -0500600
601Verify Identify LED State
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500602 [Documentation] Verify that the identify state of the LED group matches caller's expectations.
George Keishing78ce8dc2018-03-30 11:49:06 -0500603 [Arguments] ${expected_state}
604
605 # Description of argument(s):
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500606 # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted).
George Keishing78ce8dc2018-03-30 11:49:06 -0500607
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500608 ${led_state}= Get LED State XYZ enclosure_identify
609 Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state.
Sweta Potthuri39255032018-03-28 10:12:14 -0500610
611Verify The Attribute
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500612 [Documentation] Verify the given attribute.
Sweta Potthuri39255032018-03-28 10:12:14 -0500613 [Arguments] ${uri} ${attribute_name} ${attribute_value}
614
615 # Description of argument(s):
616 # uri URI path
617 # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable").
618 # attribute_name Name of attribute to be verified (e.g. "TPMEnable").
619 # attribute_value The expected value of attribute (e.g. "1", "0", etc.)
620
621 ${output}= Read Attribute ${uri} ${attribute_name}
622 Should Be Equal ${attribute_value} ${output}
623 ... msg=Attribute "${attribute_name} does not have the expected value.
George Keishingcf0d7772018-05-04 08:22:50 -0500624
625
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600626New Set Power Policy
627 [Documentation] Set the given BMC power policy (new method).
628 [Arguments] ${policy}
George Keishingb4adfc72018-10-26 09:39:32 -0500629
630 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600631 # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}).
George Keishingc5fef582018-07-18 08:41:28 -0500632
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600633 ${valueDict}= Create Dictionary data=${policy}
634 Write Attribute
635 ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict}
George Keishing216e5842018-08-31 14:58:15 -0500636
637
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600638Old Set Power Policy
639 [Documentation] Set the given BMC power policy (old method).
640 [Arguments] ${policy}
George Keishing3c004dc2018-10-10 07:16:47 -0500641
642 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600643 # policy Power restore policy (e.g. "ALWAYS_POWER_OFF").
644
645 ${valueDict}= create dictionary data=${policy}
646 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
George Keishing3c004dc2018-10-10 07:16:47 -0500647
648
George Keishinga54e06f2020-06-12 10:42:41 -0500649Redfish Set Power Restore Policy
650 [Documentation] Set the BMC power restore policy.
651 [Arguments] ${power_restore_policy}
652
653 # Description of argument(s):
654 # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
655
Yi Huc32434a2024-01-11 17:33:10 -0800656 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"PowerRestorePolicy": "${power_restore_policy}"}
George Keishinga54e06f2020-06-12 10:42:41 -0500657 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
658
659
George Keishing9a288602021-12-10 04:50:25 -0600660IPMI Set Power Restore Policy
661 [Documentation] Set the BMC power restore policy using IPMI.
662 [Arguments] ${power_restore_policy}=always-off
663
664 # Description of argument(s):
665 # power_restore_policy Power restore policies
666 # always-on : turn on when power is restored
667 # previous : return to previous state when power is restored
668 # always-off : stay off after power is restored
669
670 ${resp}= Run IPMI Standard Command chassis policy ${power_restore_policy}
671 # Example: Set chassis power restore policy to always-off
672 Should Contain ${resp} ${power_restore_policy}
673
674
George Keishinga5cedb32020-07-17 15:50:34 -0500675Set Auto Reboot Setting
676 [Documentation] Set the given auto reboot setting (REST or Redfish).
677 [Arguments] ${value}
678
679 # Description of argument(s):
680 # value The reboot setting, 1 for enabling and 0 for disabling.
681
682 # This is to cater to boot call points and plugin script which will always
683 # send using value 0 or 1. This dictionary maps to redfish string values.
684 ${rest_redfish_dict}= Create Dictionary
685 ... 1=RetryAttempts
686 ... 0=Disabled
687
George Keishing0628c4f2025-06-24 23:58:47 +0530688 IF ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
689 Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
690 ELSE
691 Set Auto Reboot ${value}
692 END
George Keishinga5cedb32020-07-17 15:50:34 -0500693
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600694Set Auto Reboot
695 [Documentation] Set the given auto reboot setting.
696 [Arguments] ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500697
698 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600699 # setting The reboot setting, 1 for enabling and 0 for disabling.
George Keishing3c004dc2018-10-10 07:16:47 -0500700
Sridevi Ramesh68d72ff2019-02-04 09:24:46 -0600701 ${valueDict}= Convert To Integer ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600702 ${data}= Create Dictionary data=${valueDict}
703 Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data}
704 ${current_setting}= Get Auto Reboot
705 Should Be Equal As Integers ${current_setting} ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500706
George Keishingc25c55d2018-10-30 02:23:44 -0500707
George Keishingc8a6dd22020-06-12 12:01:33 -0500708Redfish Set Auto Reboot
709 [Documentation] Set the given auto reboot setting.
710 [Arguments] ${setting}
711
712 # Description of argument(s):
713 # setting The reboot setting, "RetryAttempts" and "Disabled".
714
Yi Huc32434a2024-01-11 17:33:10 -0800715 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
George Keishinga8cb28d2020-06-15 03:10:29 -0500716 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
George Keishinga8cb28d2020-06-15 03:10:29 -0500717
George Keishingc8a6dd22020-06-12 12:01:33 -0500718 ${current_setting}= Redfish Get Auto Reboot
719 Should Be Equal As Strings ${current_setting} ${setting}
720
721
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600722Set Control Boot Mode
723 [Documentation] Set given boot mode on the boot object path attribute.
724 [Arguments] ${boot_path} ${boot_mode}
George Keishingc25c55d2018-10-30 02:23:44 -0500725
726 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600727 # boot_path Boot object path.
728 # Example:
729 # /xyz/openbmc_project/control/host0/boot
730 # /xyz/openbmc_project/control/host0/boot/one_time
731 # boot_mode Boot mode which need to be set.
732 # Example:
733 # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
George Keishingc25c55d2018-10-30 02:23:44 -0500734
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600735 ${valueDict}= Create Dictionary data=${boot_mode}
736 Write Attribute ${boot_path} BootMode data=${valueDict}
George Keishingc25c55d2018-10-30 02:23:44 -0500737
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600738
739Is Power On
740 [Documentation] Verify that the BMC chassis state is on.
741 ${state}= Get Power State
742 Should be equal ${state} ${1}
743
744
745Is Power Off
746 [Documentation] Verify that the BMC chassis state is off.
747 ${state}= Get Power State
748 Should be equal ${state} ${0}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500749
750
751CLI Get BMC DateTime
752 [Documentation] Returns BMC date time from date command.
753
rramyasr-ined0c14a2025-03-03 03:35:04 -0600754 ${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 +0530755 RETURN ${bmc_time_via_date}
George Keishing61364e52019-10-01 12:01:19 -0500756
757
758Update Root Password
759 [Documentation] Update system "root" user password.
760 [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD}
761
762 # Description of argument(s):
763 # openbmc_password The root password for the open BMC system.
764
765 @{password}= Create List ${openbmc_password}
766 ${data}= Create Dictionary data=@{password}
767
768 ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
George Keishingfbd67002022-08-01 11:24:03 -0500769 ${resp}= POST On Session openbmc ${BMC_USER_URI}root/action/SetPassword
George Keishing61364e52019-10-01 12:01:19 -0500770 ... data=${data} headers=${headers}
771 Valid Value resp.status_code [${HTTP_OK}]
Sushil Singh6624ce52020-01-22 00:53:41 -0600772
773
774Get Post Boot Action
775 [Documentation] Get post boot action.
776
George Keishing879f0842020-02-05 11:00:47 -0600777 # Post code update action dictionary.
Sushil Singh6624ce52020-01-22 00:53:41 -0600778 #
779 # {
780 # BMC image: {
781 # OnReset: Redfish OBMC Reboot (off),
782 # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
783 # },
784 # Host image: {
George Keishinge523fc02020-03-23 12:28:01 -0500785 # OnReset: RF SYS GracefulRestart,
Sushil Singh6624ce52020-01-22 00:53:41 -0600786 # Immediate: Wait State os_running_match_state 10 mins
787 # }
788 # }
789
790 ${code_base_dir_path}= Get Code Base Dir Path
791 ${post_code_update_actions}= Evaluate
792 ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
793 Rprint Vars post_code_update_actions
794
George Keishing409df052024-01-17 22:36:14 +0530795 RETURN ${post_code_update_actions}
Sushil Singh6624ce52020-01-22 00:53:41 -0600796
George Keishing1eeff9c2020-06-16 04:03:34 -0500797
Sushil Singh1560e652022-08-03 13:25:01 -0500798Get Task State From File
799 [Documentation] Get task states from pre-define data/task_state.json file.
800
801 # Example: Task state JSON format.
802 #
803 # {
804 # "TaskRunning": {
805 # "TaskState": "Running",
806 # "TaskStatus": "OK"
807 # },
808 # "TaskCompleted": {
809 # "TaskState": "Completed",
810 # "TaskStatus": "OK"
811 # },
812 # "TaskException": {
813 # "TaskState": "Exception",
814 # "TaskStatus": "Warning"
815 # }
816 # }
817
818 # Python module: get_code_base_dir_path()
819 ${code_base_dir_path}= Get Code Base Dir Path
820 ${task_state}= Evaluate
821 ... json.load(open('${code_base_dir_path}data/task_state.json')) modules=json
822 Rprint Vars task_state
823
George Keishing409df052024-01-17 22:36:14 +0530824 RETURN ${task_state}
Sushil Singh1560e652022-08-03 13:25:01 -0500825
826
George Keishing1eeff9c2020-06-16 04:03:34 -0500827Redfish Set Boot Default
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300828 [Documentation] Set and Verify Boot source override
829 [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI
George Keishing1eeff9c2020-06-16 04:03:34 -0500830
831 # Description of argument(s):
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300832 # override_enabled Boot source override enable type.
George Keishing1eeff9c2020-06-16 04:03:34 -0500833 # ('Once', 'Continuous', 'Disabled').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300834 # override_target Boot source override target.
George Keishing1eeff9c2020-06-16 04:03:34 -0500835 # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300836 # override_mode Boot source override mode (relevant only for x86 arch).
837 # ('Legacy', 'UEFI').
George Keishing1eeff9c2020-06-16 04:03:34 -0500838
839 ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled}
840 ... BootSourceOverrideTarget=${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300841
George Keishing0628c4f2025-06-24 23:58:47 +0530842 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
843 Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
844 END
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300845
George Keishing1eeff9c2020-06-16 04:03:34 -0500846 ${payload}= Create Dictionary Boot=${data}
847
Yi Huc32434a2024-01-11 17:33:10 -0800848 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body=&{payload}
George Keishing1eeff9c2020-06-16 04:03:34 -0500849 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
850
Yi Huc32434a2024-01-11 17:33:10 -0800851 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing1eeff9c2020-06-16 04:03:34 -0500852 Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled}
853 Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target}
George Keishing0628c4f2025-06-24 23:58:47 +0530854 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
855 Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
856 END
George Keishinge1879642020-12-09 13:20:15 -0600857
858
859# Redfish state keywords.
860
861Redfish Get BMC State
862 [Documentation] Return BMC health state.
863
864 # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady
865
866 # Example:
867 # "Status": {
868 # "Health": "OK",
869 # "HealthRollup": "OK",
870 # "State": "Enabled"
871 # },
872
George Keishing43909f32024-08-20 22:08:02 +0530873 ${status}= Wait Until Keyword Succeeds 1 min 20 sec
874 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
George Keishing409df052024-01-17 22:36:14 +0530875 RETURN ${status["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600876
877
Sushil Singh472177b2023-08-28 05:28:30 -0500878Redfish Verify BMC State
879 [Documentation] Verify BMC state is enabled.
880 [Arguments] ${match_state}=Enabled
881
882 # Description of argument(s):
883 # match_state Expected match state (e.g. Enabled, Starting, Error)
884
George Keishing43909f32024-08-20 22:08:02 +0530885 ${Status}= Wait Until Keyword Succeeds 1 min 20 sec
886 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
Sushil Singh472177b2023-08-28 05:28:30 -0500887
888 Should Be Equal As Strings ${match_state} ${Status['State']}
889
890
George Keishinge1879642020-12-09 13:20:15 -0600891Redfish Get Host State
892 [Documentation] Return host power and health state.
893
894 # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status
895
896 # Example:
897 # "PowerState": "Off",
898 # "Status": {
899 # "Health": "OK",
900 # "HealthRollup": "OK",
901 # "State": "StandbyOffline"
902 # },
903
George Keishing43909f32024-08-20 22:08:02 +0530904 ${chassis}= Wait Until Keyword Succeeds 1 min 20 sec
905 ... Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}
George Keishing409df052024-01-17 22:36:14 +0530906 RETURN ${chassis["PowerState"]} ${chassis["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600907
908
909Redfish Get Boot Progress
910 [Documentation] Return boot progress state.
911
912 # Example: /redfish/v1/Systems/system/
913 # "BootProgress": {
914 # "LastState": "OSRunning"
915 # },
916
George Keishing43909f32024-08-20 22:08:02 +0530917 ${boot_progress}= Wait Until Keyword Succeeds 1 min 20 sec
918 ... Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/
George Keishingb51d1502021-03-25 03:30:33 -0500919
920 Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86"
921 ... NA ${boot_progress["Status"]["State"]}
922
George Keishing409df052024-01-17 22:36:14 +0530923 RETURN ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600924
925
926Redfish Get States
927 [Documentation] Return all the BMC and host states in dictionary.
Sushil Singhfd0f91b2023-11-10 07:35:11 -0600928 [Timeout] ${REDFISH_SYS_STATE_WAIT_TIMEOUT}
George Keishinge1879642020-12-09 13:20:15 -0600929
930 # Refer: openbmc/docs/designs/boot-progress.md
931
George Keishing205f95f2021-03-10 02:25:53 -0600932 Redfish.Login
George Keishinge1879642020-12-09 13:20:15 -0600933
934 ${bmc_state}= Redfish Get BMC State
935 ${chassis_state} ${chassis_status}= Redfish Get Host State
936 ${boot_progress} ${host_state}= Redfish Get Boot Progress
937
938 ${states}= Create Dictionary
939 ... bmc=${bmc_state}
940 ... chassis=${chassis_state}
941 ... host=${host_state}
942 ... boot_progress=${boot_progress}
943
George Keishing64293c52021-03-24 08:21:23 -0500944 # Disable loggoing state to prevent huge log.html record when boot
945 # test is run in loops.
946 #Log ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600947
George Keishing409df052024-01-17 22:36:14 +0530948 RETURN ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600949
950
Sushil Singh80029902023-03-06 01:33:00 -0600951Is BMC Not Quiesced
952 [Documentation] Verify BMC state is not quiesced.
953
954 ${bmc_state}= Redfish Get States
955
956 Log To Console BMC State : ${bmc_state}
957
958 Should Not Be Equal As Strings Quiesced ${bmc_state['bmc']}
959
960
George Keishing95cf8652021-02-08 11:32:33 -0600961Is BMC Standby
962 [Documentation] Check if BMC is ready and host at standby.
963
964 ${standby_states}= Create Dictionary
965 ... bmc=Enabled
966 ... chassis=Off
967 ... host=Disabled
968 ... boot_progress=None
969
George Keishing0628c4f2025-06-24 23:58:47 +0530970 IF '${PLATFORM_ARCH_TYPE}' == 'x86'
971 Set To Dictionary ${standby_states} boot_progress=NA
972 END
aravinth0510de1863d2022-06-27 17:26:14 +0000973
George Keishing95cf8652021-02-08 11:32:33 -0600974 Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States
975
Rahul Maheshwari258d5922022-11-27 01:04:39 -0600976 Wait Until Keyword Succeeds 5 min 10 sec Match State ${standby_states}
George Keishing95cf8652021-02-08 11:32:33 -0600977
978
979Match State
980 [Documentation] Check if the expected and current states are matched.
981 [Arguments] ${match_state}
982
983 # Description of argument(s):
984 # match_state Expected states in dictionary.
985
986 ${current_state}= Redfish Get States
987 Dictionaries Should Be Equal ${match_state} ${current_state}
Peter D Phan49739b22021-09-29 14:30:08 -0500988
989
praphullasuresh95589b32023-08-24 08:59:28 -0500990Wait For Host Boot Progress To Reach Required State
991 [Documentation] Wait till host boot progress reaches required state.
praphullasuresheacfac92023-08-25 06:51:01 -0500992 [Arguments] ${expected_boot_state}=OSRunning
praphullasuresh95589b32023-08-24 08:59:28 -0500993
994 # Description of argument(s):
995 # expected_boot_state Expected boot state. E.g. OSRunning, SystemInitComplete etc.
996
997 Wait Until Keyword Succeeds ${power_on_timeout} 20 sec
998 ... Is Boot Progress At Required State ${expected_boot_state}
999
1000
Peter D Phan49739b22021-09-29 14:30:08 -05001001Redfish Initiate Auto Reboot
1002 [Documentation] Initiate an auto reboot.
1003 [Arguments] ${interval}=2000
1004
1005 # Description of argument(s):
1006 # interval Value in milliseconds to set Watchdog interval
1007
1008 # Set auto reboot policy
1009 Redfish Set Auto Reboot RetryAttempts
1010
George Keishingc0701102021-09-30 12:12:04 -05001011 Redfish Power Operation On
George Keishinga4e13522022-04-13 11:14:53 -05001012
1013 Wait Until Keyword Succeeds 2 min 5 sec Is Boot Progress Changed
George Keishingc0701102021-09-30 12:12:04 -05001014
Peter D Phan49739b22021-09-29 14:30:08 -05001015 # Set watchdog timer
1016 Set Watchdog Interval Using Busctl ${interval}
1017
1018
George Keishinga4e13522022-04-13 11:14:53 -05001019Is Boot Progress Changed
1020 [Documentation] Get BootProgress state and expect boot state mismatch.
1021 [Arguments] ${boot_state}=None
1022
1023 # Description of argument(s):
1024 # boot_state Value of the BootProgress state to match against.
1025
1026 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1027
1028 Should Not Be Equal ${boot_progress} ${boot_state}
1029
Peter D Phan49739b22021-09-29 14:30:08 -05001030
Sridevi Ramesh13d84bf2022-10-31 09:14:52 -05001031Is Boot Progress At Required State
1032 [Documentation] Get BootProgress state and expect boot state to match.
1033 [Arguments] ${boot_state}=None
1034
1035 # Description of argument(s):
1036 # boot_state Value of the BootProgress state to match.
1037
1038 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1039
1040 Should Be Equal ${boot_progress} ${boot_state}
1041
1042
1043Is Boot Progress At Any State
1044 [Documentation] Get BootProgress state and expect boot state to match
1045 ... with any of the states mentioned in the list.
1046 [Arguments] ${boot_states}=@{BOOT_PROGRESS_STATES}
1047
1048 # Description of argument(s):
1049 # boot_states List of the BootProgress states to match.
1050
1051 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1052 Should Contain Any ${boot_progress} @{boot_states}
1053
1054
Sagar Anand0e262662023-01-24 11:36:01 -06001055Is Host At State
1056 [Documentation] Get Host state and check if it matches
1057 ... user input expected state.
1058 [Arguments] ${expected_host_state}
1059
1060 # Description of argument(s):
1061 # expected_host_state Expected Host State to check.(e.g. Quiesced).
1062
1063 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1064
1065 Should Be Equal ${host_state} ${expected_host_state}
1066
1067
Peter D Phan49739b22021-09-29 14:30:08 -05001068Set Watchdog Interval Using Busctl
1069 [Documentation] Set Watchdog time interval.
1070 [Arguments] ${milliseconds}=1000
1071
1072 # Description of argument(s):
George Keishing4b729492021-11-10 12:51:10 -06001073 # milliseconds Time interval for watchdog timer
Peter D Phan49739b22021-09-29 14:30:08 -05001074
George Keishingc0701102021-09-30 12:12:04 -05001075 ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog
1076 ... /xyz/openbmc_project/watchdog/host0
1077 ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds}
Peter D Phan49739b22021-09-29 14:30:08 -05001078 BMC Execute Command ${cmd}
1079
George Keishingf5fec0d2021-10-08 12:38:45 -05001080
1081Stop PLDM Service And Wait
1082 [Documentation] Stop PLDM service and wait for Host to initiate reset.
1083
1084 BMC Execute Command systemctl stop pldmd.service
1085
George Keishingca76e372022-03-16 12:45:26 -05001086
1087Get BIOS Attribute
1088 [Documentation] Get the BIOS attribute for /redfish/v1/Systems/system/Bios.
1089
1090 # Python module: get_member_list(resource_path)
1091 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1092 ${bios_attr_dict}= Redfish.Get Attribute ${systems[0]}/Bios Attributes
1093
George Keishing409df052024-01-17 22:36:14 +05301094 RETURN ${bios_attr_dict}
nagarjunb22cfb2c412022-03-15 15:49:27 +05301095
George Keishing8f610e72022-03-28 10:43:08 -05001096
1097Set BIOS Attribute
1098 [Documentation] PATCH the BIOS attribute for /redfish/v1/Systems/system/Bios.
1099 [Arguments] ${attribute_name} ${attribute_value}
1100
1101 # Description of argument(s):
1102 # attribute_name Any valid BIOS attribute.
1103 # attribute_value Valid allowed attribute values.
1104
1105 # Python module: get_member_list(resource_path)
1106 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1107 Redfish.Patch ${systems[0]}/Bios/Settings body={"Attributes":{"${attribute_name}":"${attribute_value}"}}
1108
1109
nagarjunb22cfb2c412022-03-15 15:49:27 +05301110Is BMC Operational
1111 [Documentation] Check if BMC is enabled.
ganesanb13fb3cf2023-05-12 00:42:18 +00001112 [Teardown] Redfish.Logout
nagarjunb22cfb2c412022-03-15 15:49:27 +05301113
ganesanb13fb3cf2023-05-12 00:42:18 +00001114 Wait Until Keyword Succeeds 5 min 5 sec Ping Host ${OPENBMC_HOST}
1115 # In some of bmc stack, network services will gets loaded before redfish/ipmi services gets loaded.
1116 # Hence, 3mins sleep time is added to allow other service gets loaded.
1117 Sleep 180s
1118 Redfish.login
1119 ${bmc_status}= Redfish Get BMC State
nagarjunb22cfb2c412022-03-15 15:49:27 +05301120 Should Be Equal ${bmc_status} Enabled
George Keishing83c737b2022-05-17 12:12:04 -05001121
1122
1123PLDM Set BIOS Attribute
1124 [Documentation] Set the BIOS attribute via pldmtool and verify the attribute is set.
1125 ... Defaulted for fw_boot_side for boot test usage caller.
1126 [Arguments] ${attribute_name}=fw_boot_side ${attribute_value}=Temp
1127
1128 # Description of argument(s):
1129 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1130 # attribute_value Valid BIOS attribute value for fw_boot_side.
1131
1132 # PLDM response output example:
1133 # {
1134 # "Response": "SUCCESS"
1135 # }
1136
1137 ${resp}= pldmtool bios SetBIOSAttributeCurrentValue -a ${attribute_name} -d ${attribute_value}
1138 Should Be Equal As Strings ${resp["Response"]} SUCCESS
1139
1140 # PLDM GET output example:
1141 # {
1142 # "CurrentValue": "Temp"
1143 # }
1144
1145 ${pldm_output}= PLDM Get BIOS Attribute ${attribute_name}
1146 Should Be Equal As Strings ${pldm_output["CurrentValue"]} ${attribute_value}
1147 ... msg=Expecting ${attribute_value} but got ${pldm_output["CurrentValue"]}
1148
1149
1150PLDM Get BIOS Attribute
1151 [Documentation] Get the BIOS attribute via pldmtool for a given attribute and return value.
1152 [Arguments] ${attribute_name}
1153
1154 # Description of argument(s):
1155 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1156
1157 ${pldm_output}= pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${attribute_name}
George Keishing409df052024-01-17 22:36:14 +05301158 RETURN ${pldm_output}
nagarjunb2200108dc2022-07-12 21:50:45 +05301159
1160
1161Verify Host Power State
1162 [Documentation] Get the Host Power state and compare it with the expected state.
1163 [Arguments] ${expected_power_state}
1164
1165 # Description of argument(s):
1166 # expected_power_state State of Host e.g. Off or On.
1167
1168 ${power_state} ${health_status}= Redfish Get Host State
1169 Should Be Equal ${power_state} ${expected_power_state}
1170
1171
1172Verify Host Is Up
1173 [Documentation] Verify Host is Up.
1174
1175 Wait Until Keyword Succeeds 3 min 30 sec Verify Host Power State On
1176 # Python module: os_execute(cmd)
1177 Wait Until Keyword Succeeds 10 min 30 sec OS Execute Command uptime