blob: 5eb78024a8f1210b38be801ccd07301bc45950b5 [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
George Keishing9a288602021-12-10 04:50:25 -060011Resource ../lib/ipmi_client.robot
Michael Walsh391ba9b2017-08-24 11:36:24 -050012Library String
George Keishing30c12ff2016-09-02 10:25:29 -050013Library DateTime
14Library Process
Chris Austenb29d2e82016-06-07 12:25:35 -050015Library OperatingSystem
Michael Walsha6723f22016-11-22 11:12:01 -060016Library gen_print.py
Steven Sombaraaaab222018-12-19 13:16:23 -060017Library gen_misc.py
Michael Walsha6723f22016-11-22 11:12:01 -060018Library gen_robot_print.py
Michael Walsh5f3f4142017-05-22 17:09:47 -050019Library gen_cmd.py
Sunil Macd110a2017-05-23 04:14:32 -050020Library gen_robot_keyword.py
Michael Walshe53e47a2017-06-30 17:03:24 -050021Library bmc_ssh_utils.py
Michael Walshfdc5ced2017-08-17 13:15:15 -050022Library utils.py
Charles Paul Hofer35816152017-10-02 11:55:11 -050023Library var_funcs.py
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050024Library SCPLibrary WITH NAME scp
George Keishing61364e52019-10-01 12:01:19 -050025Library gen_robot_valid.py
George Keishing83c737b2022-05-17 12:12:04 -050026Library pldm_utils.py
Chris Austenb29d2e82016-06-07 12:25:35 -050027
Steven Sombarf60cbcf2018-12-07 08:12:18 -060028
Chris Austenb29d2e82016-06-07 12:25:35 -050029*** Variables ***
Steven Sombar0acb3412018-01-24 09:38:42 -060030
Steven Sombar0acb3412018-01-24 09:38:42 -060031${SYSTEM_SHUTDOWN_TIME} ${5}
32
Michael Walsha6723f22016-11-22 11:12:01 -060033# Assign default value to QUIET for programs which may not define it.
34${QUIET} ${0}
Steven Sombar0acb3412018-01-24 09:38:42 -060035
Sridevi Ramesh1699d372016-12-06 00:20:22 -060036${HOST_SETTING} ${SETTINGS_URI}host0
Steven Sombar0acb3412018-01-24 09:38:42 -060037
Steven Sombar0acb3412018-01-24 09:38:42 -060038${boot_prog_method} ${EMPTY}
Michael Walshfdc5ced2017-08-17 13:15:15 -050039${power_policy_setup} ${0}
40${bmc_power_policy_method} ${EMPTY}
Michael Walshfdc5ced2017-08-17 13:15:15 -050041
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050042
Chris Austenb29d2e82016-06-07 12:25:35 -050043*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060044
Steven Sombar0acb3412018-01-24 09:38:42 -060045
George Keishing5e870cd2016-08-24 10:05:47 -050046Verify Ping and REST Authentication
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050047 [Documentation] Verify ping and rest authentication.
Michael Walsha6723f22016-11-22 11:12:01 -060048 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050049 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -050050 Run Keyword If '${l_ping}' == '${False}'
51 ... 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 Keishingc4d3dc02016-09-19 03:45:55 -050055 Run Keyword If '${l_rest}' == '${False}'
56 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -050057
58 # Just to make sure the SSH is working for SCP
59 Open Connection And Log In
60 ${system} ${stderr}= Execute Command hostname return_stderr=True
61 Should Be Empty ${stderr}
62
Steven Sombar0acb3412018-01-24 09:38:42 -060063
George Keishing90b555a2021-05-20 11:54:16 -050064Verify Ping SSH And Redfish Authentication
65 [Documentation] Verify ping, SSH and redfish authentication.
66
67 ${l_ping}= Run Keyword And Return Status Ping Host ${OPENBMC_HOST}
68 Run Keyword If '${l_ping}' == '${False}' Fail msg=Ping Failed
69
70 ${l_rest}= Run Keyword And Return Status Redfish.Login
71 Run Keyword If '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
72
73 # Just to make sure the SSH is working.
74 Open Connection And Log In
75 ${system} ${stderr}= Execute Command hostname return_stderr=True
76 Should Be Empty ${stderr}
77
78
George Keishingc4d3dc02016-09-19 03:45:55 -050079Check If BMC is Up
80 [Documentation] Wait for Host to be online. Checks every X seconds
81 ... interval for Y minutes and fails if timed out.
82 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -060083 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -050084 ... ${interval}=10 sec
85
Steven Sombar0acb3412018-01-24 09:38:42 -060086 # Description of argument(s):
87 # max_timeout Maximum time to wait.
88 # This should be expressed in Robot Framework's time format
89 # (e.g. "10 minutes").
George Keishing16b3c7b2021-01-28 09:23:37 -060090 # interval Interval to wait between status checks.
Steven Sombar0acb3412018-01-24 09:38:42 -060091 # This should be expressed in Robot Framework's time format
92 # (e.g. "5 seconds").
93
George Keishingc4d3dc02016-09-19 03:45:55 -050094 Wait Until Keyword Succeeds
95 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
96
George Keishingb3700812016-08-31 03:03:30 -050097
George Keishing06ae4aa2016-08-30 01:41:28 -050098Flush REST Sessions
99 [Documentation] Removes all the active session objects
100 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500101
Steven Sombar0acb3412018-01-24 09:38:42 -0600102
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600103Trigger Host Watchdog Error
George Keishing37cfa6b2017-06-15 10:25:55 -0500104 [Documentation] Inject host watchdog timeout error via REST.
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600105 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Steven Sombar0acb3412018-01-24 09:38:42 -0600106
Michael Walshb5839d02017-04-12 16:11:20 -0500107 # Description of argument(s):
108 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
109 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600110 # sleep_time Time delay for host watchdog error to get injected.
111 # Default is 5 seconds.
112
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500113 ${data}= Create Dictionary
114 ... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
115 ${status} ${result}= Run Keyword And Ignore Error
116 ... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction
117 Run Keyword If '${status}' == 'PASS'
118 ... Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
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}
Sridevi Rameshea36b412017-03-09 04:08:02 -0600144 [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 Sombaraaf72c42017-09-05 12:02:00 -0500216Read Turbo Setting Via REST
217 [Documentation] Return turbo setting via REST.
Steven Sombarea79a492018-04-18 11:14:57 -0500218 # Returns 1 if TurboAllowed, 0 if not.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500219
Steven Sombarea79a492018-04-18 11:14:57 -0500220 ${turbo_setting}= Read Attribute
221 ... ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
222 [Return] ${turbo_setting}
223
Steven Sombaraaf72c42017-09-05 12:02:00 -0500224
Steven Sombaraaf72c42017-09-05 12:02:00 -0500225Set Turbo Setting Via REST
226 [Documentation] Set turbo setting via REST.
Steven Sombar80bc8592018-04-24 11:44:53 -0500227 [Arguments] ${setting} ${verify}=${False}
Steven Sombar0acb3412018-01-24 09:38:42 -0600228
Steven Sombaraaf72c42017-09-05 12:02:00 -0500229 # Description of argument(s):
Steven Sombar80bc8592018-04-24 11:44:53 -0500230 # setting State to set TurboAllowed, 1=allowed, 0=not allowed.
231 # verify If True, read the TurboAllowed setting to confirm.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500232
Steven Sombarea79a492018-04-18 11:14:57 -0500233 ${data}= Create Dictionary data=${${setting}}
Steven Sombar80bc8592018-04-24 11:44:53 -0500234 Write Attribute ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
235 ... verify=${verify} data=${data}
George Keishingef74a8c2017-10-20 10:23:52 -0500236
Steven Sombar0acb3412018-01-24 09:38:42 -0600237
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600238Set REST Logging Policy
239 [Documentation] Enable or disable REST logging setting.
240 [Arguments] ${policy_setting}=${True}
George Keishingef74a8c2017-10-20 10:23:52 -0500241
242 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600243 # policy_setting The policy setting value which can be either
244 # True or False.
George Keishingef74a8c2017-10-20 10:23:52 -0500245
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600246 ${log_dict}= Create Dictionary data=${policy_setting}
George Keishingdf3e65f2018-12-18 13:06:56 -0600247 Write Attribute ${BMC_LOGGING_URI}rest_api_logs Enabled
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600248 ... data=${log_dict} verify=${1} expected_value=${policy_setting}
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -0500249
Steven Sombar0acb3412018-01-24 09:38:42 -0600250
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600251Old Get Boot Progress
252 [Documentation] Get the boot progress the old way (via org location).
253 [Arguments] ${quiet}=${QUIET}
George Keishing034902d2017-11-10 13:15:38 -0600254
255 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600256 # quiet Indicates whether this keyword should run without any output to
257 # the console.
258
259 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
260 ... value quiet=${quiet}
261
262 [Return] ${state}
263
264
265Set Boot Progress Method
266 [Documentation] Set the boot_prog_method to either 'Old' or 'New'.
267
268 # The boot progress data has moved from an 'org' location to an 'xyz'
269 # location. This keyword will determine whether the new method of getting
270 # the boot progress is valid and will set the global boot_prog_method
271 # variable accordingly. If boot_prog_method is already set (either by a
272 # prior call to this function or via a -v parm), this keyword will simply
273 # return.
274
275 # Note: There are interim builds that contain boot_progress in both the
276 # old and the new location values. It is nearly impossible for this
277 # keyword to determine whether the old boot_progress or the new one is
278 # active. When using such builds where the old boot_progress is active,
279 # the only recourse users will have is that they may specify
280 # -v boot_prog_method:Old to force old behavior on such builds.
281
282 Run Keyword If '${boot_prog_method}' != '${EMPTY}' Return From Keyword
283
284 ${new_status} ${new_value}= Run Keyword And Ignore Error
285 ... New Get Boot Progress
286 # If the new style read fails, the method must necessarily be "Old".
287 Run Keyword If '${new_status}' == 'PASS'
288 ... Run Keywords
289 ... Set Global Variable ${boot_prog_method} New AND
290 ... Rqpvars boot_prog_method AND
291 ... Return From Keyword
292
293 # Default method is "Old".
294 Set Global Variable ${boot_prog_method} Old
295 Rqpvars boot_prog_method
296
297
298Initiate Power On
299 [Documentation] Initiates the power on and waits until the Is Power On
300 ... keyword returns that the power state has switched to on.
301 [Arguments] ${wait}=${1}
302
303 # Description of argument(s):
304 # wait Indicates whether to wait for a powered on state after issuing
305 # the power on command.
306
307 @{arglist}= Create List
308 ${args}= Create Dictionary data=@{arglist}
309 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
310 ... data=${args}
311 should be equal as strings ${resp.status_code} ${HTTP_OK}
312
313 # Does caller want to wait for power on status?
314 Run Keyword If '${wait}' == '${0}' Return From Keyword
315 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
316
317
318Initiate Power Off
319 [Documentation] Initiates the power off and waits until the Is Power Off
320 ... keyword returns that the power state has switched to off.
321
322 @{arglist}= Create List
323 ${args}= Create Dictionary data=@{arglist}
324 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
325 ... data=${args}
326 should be equal as strings ${resp.status_code} ${HTTP_OK}
327 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
328
329
330Get Boot Progress
331 [Documentation] Get the boot progress and return it.
332 [Arguments] ${quiet}=${QUIET}
333
334 # Description of argument(s):
335 # quiet Indicates whether this keyword should run without any output to
336 # the console.
337
338 Set Boot Progress Method
339 ${state}= Run Keyword If '${boot_prog_method}' == 'New'
340 ... New Get Boot Progress quiet=${quiet}
341 ... ELSE
342 ... Old Get Boot Progress quiet=${quiet}
343
344 [Return] ${state}
345
346
347New Get Boot Progress
348 [Documentation] Get the boot progress the new way (via xyz location).
349 [Arguments] ${quiet}=${QUIET}
350
351 # Description of argument(s):
352 # quiet Indicates whether this keyword should run without any output to
353 # the console.
354
355 ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet}
356
357 [Return] ${state.rsplit('.', 1)[1]}
358
359
360New Get Power Policy
361 [Documentation] Returns the BMC power policy (new method).
362 ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy
363
364 [Return] ${currentPolicy}
365
366
367Old Get Power Policy
368 [Documentation] Returns the BMC power policy (old method).
369 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
370
371 [Return] ${currentPolicy}
372
373
George Keishinga54e06f2020-06-12 10:42:41 -0500374Redfish Get Power Restore Policy
375 [Documentation] Returns the BMC power restore policy.
376
377 ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/system PowerRestorePolicy
378 [Return] ${power_restore_policy}
379
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600380Get Auto Reboot
381 [Documentation] Returns auto reboot setting.
382 ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
383
384 [Return] ${setting}
385
386
George Keishingc8a6dd22020-06-12 12:01:33 -0500387Redfish Get Auto Reboot
388 [Documentation] Returns auto reboot setting.
389
George Keishinga8cb28d2020-06-15 03:10:29 -0500390 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/system Boot
George Keishinga8cb28d2020-06-15 03:10:29 -0500391 [Return] ${resp["AutomaticRetryConfig"]}
George Keishingc8a6dd22020-06-12 12:01:33 -0500392
393
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600394Trigger Warm Reset
395 [Documentation] Initiate a warm reset.
396
397 log to console "Triggering warm reset"
398 ${data}= create dictionary data=@{EMPTY}
399 ${resp}= openbmc post request
400 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
401 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
402 ${session_active}= Check If warmReset is Initiated
403 Run Keyword If '${session_active}' == '${True}'
404 ... Fail msg=warm reset didn't occur
405
406 Sleep ${SYSTEM_SHUTDOWN_TIME}min
407 Check If BMC Is Up
408
409
410Get Power State
411 [Documentation] Returns the power state as an integer. Either 0 or 1.
412 [Arguments] ${quiet}=${QUIET}
413
414 # Description of argument(s):
415 # quiet Indicates whether this keyword should run without any output to
416 # the console.
417
418 @{arglist}= Create List
419 ${args}= Create Dictionary data=@{arglist}
420
421 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
422 ... data=${args} quiet=${quiet}
423 Should be equal as strings ${resp.status_code} ${HTTP_OK}
424 ${content}= to json ${resp.content}
425
426 [Return] ${content["data"]}
427
428
429Clear BMC Gard Record
430 [Documentation] Clear gard records from the system.
431
432 @{arglist}= Create List
433 ${args}= Create Dictionary data=@{arglist}
434 ${resp}= Call Method
435 ... ${OPENPOWER_CONTROL}gard Reset data=${args}
436 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
437
438
439Flash PNOR
440 [Documentation] Calls flash bios update method to flash PNOR image
441 [Arguments] ${pnor_image}
442
443 # Description of argument(s):
444 # pnor_image The filename and path of the PNOR image
445 # (e.g. "/home/image/zaius.pnor").
446
447 @{arglist}= Create List ${pnor_image}
448 ${args}= Create Dictionary data=@{arglist}
449 ${resp}= Call Method /org/openbmc/control/flash/bios/ update
450 ... data=${args}
451 should be equal as strings ${resp.status_code} ${HTTP_OK}
452 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
453
454
455Get Flash BIOS Status
456 [Documentation] Returns the status of the flash BIOS API as a string. For
457 ... example 'Flashing', 'Flash Done', etc
458 ${data}= Read Properties /org/openbmc/control/flash/bios
459 [Return] ${data['status']}
460
461
462Is PNOR Flashing
463 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
464 ... flashing has started.
465 ${status}= Get Flash BIOS Status
466 Should Contain ${status} Flashing
467
468
469Is PNOR Flash Done
470 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
471 ... PNOR flashing has completed.
472 ${status}= Get Flash BIOS Status
473 should be equal as strings ${status} Flash Done
474
475
476Create OS Console File Path
477 [Documentation] Create OS console file path name and return it.
478 [Arguments] ${log_file_path}=${EMPTY}
479
480 # Description of arguments:
481 # file_path The caller's candidate value. If this value is ${EMPTY}, this
482 # keyword will compose a file path name. Otherwise, this
483 # keyword will use the caller's file_path value. In either
484 # case, the value will be returned.
485
486 ${status}= Run Keyword And Return Status Variable Should Exist
487 ... ${TEST_NAME}
488
489 ${default_file_path}= Set Variable If ${status} == ${TRUE}
George Keishing9161b102021-12-10 02:26:30 -0600490 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt
491 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_os_console.txt
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600492
493 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
494 ... ${default_file_path} ${log_file_path}
495
496 [Return] ${log_file_path}
497
498
499Get Endpoint Paths
500 [Documentation] Returns all url paths ending with given endpoint
501 ... Example:
502 ... Given the following endpoint: cpu
503 ... This keyword will return: list of all urls ending with
504 ... cpu -
505 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
506 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
507 [Arguments] ${path} ${endpoint}
508
509 # Description of arguments:
510 # path URL path for enumeration.
511 # endpoint Endpoint string (url path ending).
512
Steven Sombaraaaab222018-12-19 13:16:23 -0600513 # Make sure path ends with slash.
514 ${path}= Add Trailing Slash ${path}
515
516 ${resp}= Read Properties ${path}enumerate timeout=30
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600517 Log Dictionary ${resp}
518
519 ${list}= Get Dictionary Keys ${resp}
520 # For a given string, look for prefix and suffix for matching expression.
521 # Start of string followed by zero or more of any character followed by
522 # any digit or lower case character.
George Keishing585afa32020-07-09 04:55:15 -0500523 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[_0-9a-z]*$ case_insensitive=${True}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600524
525 [Return] ${resp}
526
527
528Set BMC Power Policy
529 [Documentation] Set the given BMC power policy.
530 [Arguments] ${policy}
531
532 # Note that this function will translate the old style "RESTORE_LAST_STATE"
533 # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy.
534 # Policy.Restore" for you.
535
536 # Description of argument(s):
537 # policy Power restore policy (e.g "RESTORE_LAST_STATE",
538 # ${RESTORE_LAST_STATE}).
539
540 # Set the bmc_power_policy_method to either 'Old' or 'New'.
541 Set Power Policy Method
542 # This translation helps bridge between old and new method for calling.
543 ${policy}= Translate Power Policy Value ${policy}
544 # Run the appropriate keyword.
545 Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy}
546 ${currentPolicy}= Get System Power Policy
547 Should Be Equal ${currentPolicy} ${policy}
548
549
550Delete Error Logs
551 [Documentation] Delete error logs.
Michael Sheposcc490b42020-08-26 12:53:01 -0500552 [Arguments] ${quiet}=${0}
553 # Description of argument(s):
554 # quiet If enabled, turns off logging to console.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600555
556 # Check if error logs entries exist, if not return.
Steven Sombara8800da2018-12-18 16:19:05 -0600557 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600558 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
559
560 # Get the list of error logs entries and delete them all.
561 ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY}
David Shaw79247e42020-06-18 17:16:02 -0500562 FOR ${entry} IN @{elog_entries}
Michael Sheposcc490b42020-08-26 12:53:01 -0500563 Delete Error Log Entry ${entry} quiet=${quiet}
David Shaw79247e42020-06-18 17:16:02 -0500564 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600565
566
567Delete All Error Logs
568 [Documentation] Delete all error log entries using "DeleteAll" interface.
569
570 ${data}= Create Dictionary data=@{EMPTY}
571 ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
572 ... data=${data}
573 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
574
575
576Get Elog URL List
577 [Documentation] Return error log entry list of URLs.
578
579 ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/
580 Sort List ${url_list}
581 [Return] ${url_list}
582
583
584Get BMC Flash Chip Boot Side
585 [Documentation] Return the BMC flash chip boot side.
George Keishing034902d2017-11-10 13:15:38 -0600586
587 # Example:
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600588 # 0 - indicates chip select is current side.
589 # 32 - indicates chip select is alternate side.
George Keishing034902d2017-11-10 13:15:38 -0600590
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600591 ${boot_side} ${stderr} ${rc}= BMC Execute Command
592 ... cat /sys/class/watchdog/watchdog1/bootstatus
593
594 [Return] ${boot_side}
595
596
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600597Watchdog Object Should Exist
598 [Documentation] Check that watchdog object exists.
599
600 ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0
601 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
602 ... msg=Expected watchdog object does not exist.
Sweta Potthurif39022d2018-02-06 03:40:07 -0600603
604
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600605Get System LED State
606 [Documentation] Return the state of given system LED.
607 [Arguments] ${led_name}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600608
609 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600610 # led_name System LED name (e.g. heartbeat, identify, beep).
Sweta Potthurif39022d2018-02-06 03:40:07 -0600611
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600612 ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
613 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb9f407b2018-02-20 00:07:46 -0600614
615
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600616Verify LED State
617 [Documentation] Checks if LED is in given state.
618 [Arguments] ${led_name} ${led_state}
619 # Description of argument(s):
620 # led_name System LED name (e.g. heartbeat, identify, beep).
621 # led_state LED state to be verified (e.g. On, Off).
George Keishingb9f407b2018-02-20 00:07:46 -0600622
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600623 ${state}= Get System LED State ${led_name}
624 Should Be Equal ${state} ${led_state}
George Keishingb9f407b2018-02-20 00:07:46 -0600625
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600626
627Get LED State XYZ
628 [Documentation] Returns state of given LED.
629 [Arguments] ${led_name}
630
631 # Description of argument(s):
632 # led_name Name of LED.
633
634 ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted
635 # Returns the state of the LED, either On or Off.
636 [Return] ${state}
George Keishingb9f407b2018-02-20 00:07:46 -0600637
George Keishing78ce8dc2018-03-30 11:49:06 -0500638
639Verify Identify LED State
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500640 [Documentation] Verify that the identify state of the LED group matches caller's expectations.
George Keishing78ce8dc2018-03-30 11:49:06 -0500641 [Arguments] ${expected_state}
642
643 # Description of argument(s):
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500644 # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted).
George Keishing78ce8dc2018-03-30 11:49:06 -0500645
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500646 ${led_state}= Get LED State XYZ enclosure_identify
647 Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state.
Sweta Potthuri39255032018-03-28 10:12:14 -0500648
649Verify The Attribute
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500650 [Documentation] Verify the given attribute.
Sweta Potthuri39255032018-03-28 10:12:14 -0500651 [Arguments] ${uri} ${attribute_name} ${attribute_value}
652
653 # Description of argument(s):
654 # uri URI path
655 # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable").
656 # attribute_name Name of attribute to be verified (e.g. "TPMEnable").
657 # attribute_value The expected value of attribute (e.g. "1", "0", etc.)
658
659 ${output}= Read Attribute ${uri} ${attribute_name}
660 Should Be Equal ${attribute_value} ${output}
661 ... msg=Attribute "${attribute_name} does not have the expected value.
George Keishingcf0d7772018-05-04 08:22:50 -0500662
663
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600664New Set Power Policy
665 [Documentation] Set the given BMC power policy (new method).
666 [Arguments] ${policy}
George Keishingb4adfc72018-10-26 09:39:32 -0500667
668 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600669 # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}).
George Keishingc5fef582018-07-18 08:41:28 -0500670
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600671 ${valueDict}= Create Dictionary data=${policy}
672 Write Attribute
673 ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict}
George Keishing216e5842018-08-31 14:58:15 -0500674
675
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600676Old Set Power Policy
677 [Documentation] Set the given BMC power policy (old method).
678 [Arguments] ${policy}
George Keishing3c004dc2018-10-10 07:16:47 -0500679
680 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600681 # policy Power restore policy (e.g. "ALWAYS_POWER_OFF").
682
683 ${valueDict}= create dictionary data=${policy}
684 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
George Keishing3c004dc2018-10-10 07:16:47 -0500685
686
George Keishinga54e06f2020-06-12 10:42:41 -0500687Redfish Set Power Restore Policy
688 [Documentation] Set the BMC power restore policy.
689 [Arguments] ${power_restore_policy}
690
691 # Description of argument(s):
692 # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
693
694 Redfish.Patch /redfish/v1/Systems/system body={"PowerRestorePolicy": "${power_restore_policy}"}
695 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
696
697
George Keishing9a288602021-12-10 04:50:25 -0600698IPMI Set Power Restore Policy
699 [Documentation] Set the BMC power restore policy using IPMI.
700 [Arguments] ${power_restore_policy}=always-off
701
702 # Description of argument(s):
703 # power_restore_policy Power restore policies
704 # always-on : turn on when power is restored
705 # previous : return to previous state when power is restored
706 # always-off : stay off after power is restored
707
708 ${resp}= Run IPMI Standard Command chassis policy ${power_restore_policy}
709 # Example: Set chassis power restore policy to always-off
710 Should Contain ${resp} ${power_restore_policy}
711
712
George Keishinga5cedb32020-07-17 15:50:34 -0500713Set Auto Reboot Setting
714 [Documentation] Set the given auto reboot setting (REST or Redfish).
715 [Arguments] ${value}
716
717 # Description of argument(s):
718 # value The reboot setting, 1 for enabling and 0 for disabling.
719
720 # This is to cater to boot call points and plugin script which will always
721 # send using value 0 or 1. This dictionary maps to redfish string values.
722 ${rest_redfish_dict}= Create Dictionary
723 ... 1=RetryAttempts
724 ... 0=Disabled
725
George Keishinge1879642020-12-09 13:20:15 -0600726 Run Keyword If ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
George Keishinga5cedb32020-07-17 15:50:34 -0500727 ... Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
George Keishinge1879642020-12-09 13:20:15 -0600728 ... ELSE
729 ... Set Auto Reboot ${value}
George Keishinga5cedb32020-07-17 15:50:34 -0500730
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600731Set Auto Reboot
732 [Documentation] Set the given auto reboot setting.
733 [Arguments] ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500734
735 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600736 # setting The reboot setting, 1 for enabling and 0 for disabling.
George Keishing3c004dc2018-10-10 07:16:47 -0500737
Sridevi Ramesh68d72ff2019-02-04 09:24:46 -0600738 ${valueDict}= Convert To Integer ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600739 ${data}= Create Dictionary data=${valueDict}
740 Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data}
741 ${current_setting}= Get Auto Reboot
742 Should Be Equal As Integers ${current_setting} ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500743
George Keishingc25c55d2018-10-30 02:23:44 -0500744
George Keishingc8a6dd22020-06-12 12:01:33 -0500745Redfish Set Auto Reboot
746 [Documentation] Set the given auto reboot setting.
747 [Arguments] ${setting}
748
749 # Description of argument(s):
750 # setting The reboot setting, "RetryAttempts" and "Disabled".
751
George Keishinga8cb28d2020-06-15 03:10:29 -0500752 Redfish.Patch /redfish/v1/Systems/system body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
753 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
George Keishinga8cb28d2020-06-15 03:10:29 -0500754
George Keishingc8a6dd22020-06-12 12:01:33 -0500755 ${current_setting}= Redfish Get Auto Reboot
756 Should Be Equal As Strings ${current_setting} ${setting}
757
758
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600759Set Control Boot Mode
760 [Documentation] Set given boot mode on the boot object path attribute.
761 [Arguments] ${boot_path} ${boot_mode}
George Keishingc25c55d2018-10-30 02:23:44 -0500762
763 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600764 # boot_path Boot object path.
765 # Example:
766 # /xyz/openbmc_project/control/host0/boot
767 # /xyz/openbmc_project/control/host0/boot/one_time
768 # boot_mode Boot mode which need to be set.
769 # Example:
770 # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
George Keishingc25c55d2018-10-30 02:23:44 -0500771
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600772 ${valueDict}= Create Dictionary data=${boot_mode}
773 Write Attribute ${boot_path} BootMode data=${valueDict}
George Keishingc25c55d2018-10-30 02:23:44 -0500774
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600775
776Is Power On
777 [Documentation] Verify that the BMC chassis state is on.
778 ${state}= Get Power State
779 Should be equal ${state} ${1}
780
781
782Is Power Off
783 [Documentation] Verify that the BMC chassis state is off.
784 ${state}= Get Power State
785 Should be equal ${state} ${0}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500786
787
788CLI Get BMC DateTime
789 [Documentation] Returns BMC date time from date command.
790
791 ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1
792 [Return] ${bmc_time_via_date}
George Keishing61364e52019-10-01 12:01:19 -0500793
794
795Update Root Password
796 [Documentation] Update system "root" user password.
797 [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD}
798
799 # Description of argument(s):
800 # openbmc_password The root password for the open BMC system.
801
802 @{password}= Create List ${openbmc_password}
803 ${data}= Create Dictionary data=@{password}
804
805 ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
806 ${resp}= Post Request openbmc ${BMC_USER_URI}root/action/SetPassword
807 ... data=${data} headers=${headers}
808 Valid Value resp.status_code [${HTTP_OK}]
Sushil Singh6624ce52020-01-22 00:53:41 -0600809
810
811Get Post Boot Action
812 [Documentation] Get post boot action.
813
George Keishing879f0842020-02-05 11:00:47 -0600814 # Post code update action dictionary.
Sushil Singh6624ce52020-01-22 00:53:41 -0600815 #
816 # {
817 # BMC image: {
818 # OnReset: Redfish OBMC Reboot (off),
819 # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
820 # },
821 # Host image: {
George Keishinge523fc02020-03-23 12:28:01 -0500822 # OnReset: RF SYS GracefulRestart,
Sushil Singh6624ce52020-01-22 00:53:41 -0600823 # Immediate: Wait State os_running_match_state 10 mins
824 # }
825 # }
826
827 ${code_base_dir_path}= Get Code Base Dir Path
828 ${post_code_update_actions}= Evaluate
829 ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
830 Rprint Vars post_code_update_actions
831
832 [Return] ${post_code_update_actions}
833
George Keishing1eeff9c2020-06-16 04:03:34 -0500834
835Redfish Set Boot Default
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300836 [Documentation] Set and Verify Boot source override
837 [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI
George Keishing1eeff9c2020-06-16 04:03:34 -0500838
839 # Description of argument(s):
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300840 # override_enabled Boot source override enable type.
George Keishing1eeff9c2020-06-16 04:03:34 -0500841 # ('Once', 'Continuous', 'Disabled').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300842 # override_target Boot source override target.
George Keishing1eeff9c2020-06-16 04:03:34 -0500843 # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300844 # override_mode Boot source override mode (relevant only for x86 arch).
845 # ('Legacy', 'UEFI').
George Keishing1eeff9c2020-06-16 04:03:34 -0500846
847 ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled}
848 ... BootSourceOverrideTarget=${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300849
850 Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
851 ... Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
852
George Keishing1eeff9c2020-06-16 04:03:34 -0500853 ${payload}= Create Dictionary Boot=${data}
854
855 Redfish.Patch /redfish/v1/Systems/system body=&{payload}
856 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
857
858 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/system Boot
859 Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled}
860 Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300861 Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
862 ... Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
George Keishinge1879642020-12-09 13:20:15 -0600863
864
865# Redfish state keywords.
866
867Redfish Get BMC State
868 [Documentation] Return BMC health state.
869
870 # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady
871
872 # Example:
873 # "Status": {
874 # "Health": "OK",
875 # "HealthRollup": "OK",
876 # "State": "Enabled"
877 # },
878
879 ${status}= Redfish.Get Attribute /redfish/v1/Managers/bmc Status
880 [Return] ${status["State"]}
881
882
883Redfish Get Host State
884 [Documentation] Return host power and health state.
885
886 # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status
887
888 # Example:
889 # "PowerState": "Off",
890 # "Status": {
891 # "Health": "OK",
892 # "HealthRollup": "OK",
893 # "State": "StandbyOffline"
894 # },
895
George Keishingb51d1502021-03-25 03:30:33 -0500896 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}
George Keishinge1879642020-12-09 13:20:15 -0600897 [Return] ${chassis["PowerState"]} ${chassis["Status"]["State"]}
898
899
900Redfish Get Boot Progress
901 [Documentation] Return boot progress state.
902
903 # Example: /redfish/v1/Systems/system/
904 # "BootProgress": {
905 # "LastState": "OSRunning"
906 # },
907
908 ${boot_progress}= Redfish.Get Properties /redfish/v1/Systems/system/
George Keishingb51d1502021-03-25 03:30:33 -0500909
910 Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86"
911 ... NA ${boot_progress["Status"]["State"]}
912
George Keishinge1879642020-12-09 13:20:15 -0600913 [Return] ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]}
914
915
916Redfish Get States
917 [Documentation] Return all the BMC and host states in dictionary.
George Keishing366033f2021-04-01 13:49:06 -0500918 [Timeout] 120 Seconds
George Keishinge1879642020-12-09 13:20:15 -0600919
920 # Refer: openbmc/docs/designs/boot-progress.md
921
George Keishing205f95f2021-03-10 02:25:53 -0600922 Redfish.Login
George Keishinge1879642020-12-09 13:20:15 -0600923
924 ${bmc_state}= Redfish Get BMC State
925 ${chassis_state} ${chassis_status}= Redfish Get Host State
926 ${boot_progress} ${host_state}= Redfish Get Boot Progress
927
928 ${states}= Create Dictionary
929 ... bmc=${bmc_state}
930 ... chassis=${chassis_state}
931 ... host=${host_state}
932 ... boot_progress=${boot_progress}
933
George Keishing64293c52021-03-24 08:21:23 -0500934 # Disable loggoing state to prevent huge log.html record when boot
935 # test is run in loops.
936 #Log ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600937
George Keishinge1879642020-12-09 13:20:15 -0600938 [Return] ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600939
940
941Is BMC Standby
942 [Documentation] Check if BMC is ready and host at standby.
943
944 ${standby_states}= Create Dictionary
945 ... bmc=Enabled
946 ... chassis=Off
947 ... host=Disabled
948 ... boot_progress=None
949
950 Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States
951
Sushil Singhb910d892021-11-17 05:34:29 -0600952 Wait Until Keyword Succeeds 2 min 10 sec Match State ${standby_states}
George Keishing95cf8652021-02-08 11:32:33 -0600953
954
955Match State
956 [Documentation] Check if the expected and current states are matched.
957 [Arguments] ${match_state}
958
959 # Description of argument(s):
960 # match_state Expected states in dictionary.
961
962 ${current_state}= Redfish Get States
963 Dictionaries Should Be Equal ${match_state} ${current_state}
Peter D Phan49739b22021-09-29 14:30:08 -0500964
965
966Redfish Initiate Auto Reboot
967 [Documentation] Initiate an auto reboot.
968 [Arguments] ${interval}=2000
969
970 # Description of argument(s):
971 # interval Value in milliseconds to set Watchdog interval
972
973 # Set auto reboot policy
974 Redfish Set Auto Reboot RetryAttempts
975
George Keishingc0701102021-09-30 12:12:04 -0500976 Redfish Power Operation On
George Keishinga4e13522022-04-13 11:14:53 -0500977
978 Wait Until Keyword Succeeds 2 min 5 sec Is Boot Progress Changed
George Keishingc0701102021-09-30 12:12:04 -0500979
Peter D Phan49739b22021-09-29 14:30:08 -0500980 # Set watchdog timer
981 Set Watchdog Interval Using Busctl ${interval}
982
983
George Keishinga4e13522022-04-13 11:14:53 -0500984Is Boot Progress Changed
985 [Documentation] Get BootProgress state and expect boot state mismatch.
986 [Arguments] ${boot_state}=None
987
988 # Description of argument(s):
989 # boot_state Value of the BootProgress state to match against.
990
991 ${boot_progress} ${host_state}= Redfish Get Boot Progress
992
993 Should Not Be Equal ${boot_progress} ${boot_state}
994
Peter D Phan49739b22021-09-29 14:30:08 -0500995
996Set Watchdog Interval Using Busctl
997 [Documentation] Set Watchdog time interval.
998 [Arguments] ${milliseconds}=1000
999
1000 # Description of argument(s):
George Keishing4b729492021-11-10 12:51:10 -06001001 # milliseconds Time interval for watchdog timer
Peter D Phan49739b22021-09-29 14:30:08 -05001002
George Keishingc0701102021-09-30 12:12:04 -05001003 ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog
1004 ... /xyz/openbmc_project/watchdog/host0
1005 ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds}
Peter D Phan49739b22021-09-29 14:30:08 -05001006 BMC Execute Command ${cmd}
1007
George Keishingf5fec0d2021-10-08 12:38:45 -05001008
1009Stop PLDM Service And Wait
1010 [Documentation] Stop PLDM service and wait for Host to initiate reset.
1011
1012 BMC Execute Command systemctl stop pldmd.service
1013
George Keishingca76e372022-03-16 12:45:26 -05001014
1015Get BIOS Attribute
1016 [Documentation] Get the BIOS attribute for /redfish/v1/Systems/system/Bios.
1017
1018 # Python module: get_member_list(resource_path)
1019 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1020 ${bios_attr_dict}= Redfish.Get Attribute ${systems[0]}/Bios Attributes
1021
1022 [Return] ${bios_attr_dict}
nagarjunb22cfb2c412022-03-15 15:49:27 +05301023
George Keishing8f610e72022-03-28 10:43:08 -05001024
1025Set BIOS Attribute
1026 [Documentation] PATCH the BIOS attribute for /redfish/v1/Systems/system/Bios.
1027 [Arguments] ${attribute_name} ${attribute_value}
1028
1029 # Description of argument(s):
1030 # attribute_name Any valid BIOS attribute.
1031 # attribute_value Valid allowed attribute values.
1032
1033 # Python module: get_member_list(resource_path)
1034 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1035 Redfish.Patch ${systems[0]}/Bios/Settings body={"Attributes":{"${attribute_name}":"${attribute_value}"}}
1036
1037
nagarjunb22cfb2c412022-03-15 15:49:27 +05301038Is BMC Operational
1039 [Documentation] Check if BMC is enabled.
1040
1041 ${bmc_status} = Redfish Get BMC State
1042 Should Be Equal ${bmc_status} Enabled
George Keishing83c737b2022-05-17 12:12:04 -05001043
1044
1045PLDM Set BIOS Attribute
1046 [Documentation] Set the BIOS attribute via pldmtool and verify the attribute is set.
1047 ... Defaulted for fw_boot_side for boot test usage caller.
1048 [Arguments] ${attribute_name}=fw_boot_side ${attribute_value}=Temp
1049
1050 # Description of argument(s):
1051 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1052 # attribute_value Valid BIOS attribute value for fw_boot_side.
1053
1054 # PLDM response output example:
1055 # {
1056 # "Response": "SUCCESS"
1057 # }
1058
1059 ${resp}= pldmtool bios SetBIOSAttributeCurrentValue -a ${attribute_name} -d ${attribute_value}
1060 Should Be Equal As Strings ${resp["Response"]} SUCCESS
1061
1062 # PLDM GET output example:
1063 # {
1064 # "CurrentValue": "Temp"
1065 # }
1066
1067 ${pldm_output}= PLDM Get BIOS Attribute ${attribute_name}
1068 Should Be Equal As Strings ${pldm_output["CurrentValue"]} ${attribute_value}
1069 ... msg=Expecting ${attribute_value} but got ${pldm_output["CurrentValue"]}
1070
1071
1072PLDM Get BIOS Attribute
1073 [Documentation] Get the BIOS attribute via pldmtool for a given attribute and return value.
1074 [Arguments] ${attribute_name}
1075
1076 # Description of argument(s):
1077 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1078
1079 ${pldm_output}= pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${attribute_name}
1080 [Return] ${pldm_output}