blob: 084d40087cd8d004ded6a2428db74b6f9ea9ae59 [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
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050023Library SCPLibrary WITH NAME 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 Keishingc4d3dc02016-09-19 03:45:55 -050051 Run Keyword If '${l_ping}' == '${False}'
52 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -050053
Michael Walsha6723f22016-11-22 11:12:01 -060054 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050055 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -050056 Run Keyword If '${l_rest}' == '${False}'
57 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -050058
59 # Just to make sure the SSH is working for SCP
60 Open Connection And Log In
61 ${system} ${stderr}= Execute Command hostname return_stderr=True
62 Should Be Empty ${stderr}
63
Steven Sombar0acb3412018-01-24 09:38:42 -060064
George Keishing90b555a2021-05-20 11:54:16 -050065Verify Ping SSH And Redfish Authentication
66 [Documentation] Verify ping, SSH and redfish authentication.
67
68 ${l_ping}= Run Keyword And Return Status Ping Host ${OPENBMC_HOST}
69 Run Keyword If '${l_ping}' == '${False}' Fail msg=Ping Failed
70
71 ${l_rest}= Run Keyword And Return Status Redfish.Login
72 Run Keyword If '${l_rest}' == '${False}' Fail msg=REST Authentication Failed
73
74 # Just to make sure the SSH is working.
75 Open Connection And Log In
76 ${system} ${stderr}= Execute Command hostname return_stderr=True
77 Should Be Empty ${stderr}
78
79
George Keishingc4d3dc02016-09-19 03:45:55 -050080Check If BMC is Up
81 [Documentation] Wait for Host to be online. Checks every X seconds
82 ... interval for Y minutes and fails if timed out.
83 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -060084 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -050085 ... ${interval}=10 sec
86
Steven Sombar0acb3412018-01-24 09:38:42 -060087 # Description of argument(s):
88 # max_timeout Maximum time to wait.
89 # This should be expressed in Robot Framework's time format
90 # (e.g. "10 minutes").
George Keishing16b3c7b2021-01-28 09:23:37 -060091 # interval Interval to wait between status checks.
Steven Sombar0acb3412018-01-24 09:38:42 -060092 # This should be expressed in Robot Framework's time format
93 # (e.g. "5 seconds").
94
George Keishingc4d3dc02016-09-19 03:45:55 -050095 Wait Until Keyword Succeeds
96 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
97
George Keishingb3700812016-08-31 03:03:30 -050098
George Keishing06ae4aa2016-08-30 01:41:28 -050099Flush REST Sessions
100 [Documentation] Removes all the active session objects
101 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500102
Steven Sombar0acb3412018-01-24 09:38:42 -0600103
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600104Trigger Host Watchdog Error
George Keishing37cfa6b2017-06-15 10:25:55 -0500105 [Documentation] Inject host watchdog timeout error via REST.
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600106 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Steven Sombar0acb3412018-01-24 09:38:42 -0600107
Michael Walshb5839d02017-04-12 16:11:20 -0500108 # Description of argument(s):
109 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
110 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600111 # sleep_time Time delay for host watchdog error to get injected.
112 # Default is 5 seconds.
113
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500114 ${data}= Create Dictionary
115 ... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
116 ${status} ${result}= Run Keyword And Ignore Error
117 ... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction
118 Run Keyword If '${status}' == 'PASS'
119 ... Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
George Keishing37cfa6b2017-06-15 10:25:55 -0500120
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600121 ${int_milliseconds}= Convert To Integer ${milliseconds}
122 ${data}= Create Dictionary data=${int_milliseconds}
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500123 Write Attribute ${HOST_WATCHDOG_URI} Interval data=${data}
124
125 ${data}= Create Dictionary data=${True}
126 Write Attribute ${HOST_WATCHDOG_URI} Enabled data=${data}
George Keishing37cfa6b2017-06-15 10:25:55 -0500127
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600128 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500129
Steven Sombar0acb3412018-01-24 09:38:42 -0600130
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500131Login To OS Host
Steven Sombar0acb3412018-01-24 09:38:42 -0600132 [Documentation] Login to OS Host and return the Login response code.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500133 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
134 ... ${os_password}=${OS_PASSWORD}
Steven Sombar0acb3412018-01-24 09:38:42 -0600135
Gunnar Mills28e403b2017-10-25 16:16:38 -0500136 # Description of arguments:
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500137 # ${os_host} IP address of the OS Host.
138 # ${os_username} OS Host Login user name.
139 # ${os_password} OS Host Login passwrd.
140
George Keishing1856d332021-11-15 08:38:53 -0600141 Redfish Power On stack_mode=skip quiet=1
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500142
George Keishing3f223b82017-06-28 03:50:35 -0500143 SSHLibrary.Open Connection ${os_host}
George Keishinge0030882019-02-21 03:48:27 -0600144 ${resp}= SSHLibrary.Login ${os_username} ${os_password}
George Keishing409df052024-01-17 22:36:14 +0530145 RETURN ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500146
Steven Sombar0acb3412018-01-24 09:38:42 -0600147
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600148Initiate Auto Reboot
149 [Documentation] Initiate an auto reboot.
150 [Arguments] ${milliseconds}=5000
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500151
152 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600153 # milliseconds The number of milliseconds for the watchdog timer.
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500154
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600155 # Set the auto reboot policy.
156 Set Auto Reboot ${1}
157 # Set the watchdog timer.
158 Trigger Host Watchdog Error ${milliseconds}
159
160
161Initiate OS Host Reboot
162 [Documentation] Initiate an OS reboot.
163 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
164 ... ${os_password}=${OS_PASSWORD}
165
166 # Description of argument(s):
167 # os_host The host name or IP address of the OS.
168 # os_username The username to be used to sign in to the OS.
169 # os_password The password to be used to sign in to the OS.
170
171 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
172 ... Set Variable reboot
173 ... ELSE
174 ... Set Variable echo ${os_password} | sudo -S reboot
175
176 ${output} ${stderr} ${rc}= OS Execute Command
177 ... ${cmd_buf} fork=${1}
178
179
180Initiate OS Host Power Off
181 [Documentation] Initiate an OS reboot.
182 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
183 ... ${os_password}=${OS_PASSWORD} ${hard}=${0}
184
185 # Description of argument(s):
186 # os_host The DNS name or IP of the OS.
187 # os_username The username to be used to sign in to the OS.
188 # os_password The password to be used to sign in to the OS.
189 # hard Indicates whether to do a hard vs. soft power off.
190
191 ${time_string}= Run Keyword If ${hard} Set Variable ${SPACE}now
192 ... ELSE Set Variable ${EMPTY}
193
194 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
195 ... Set Variable shutdown${time_string}
196 ... ELSE
197 ... Set Variable echo ${os_password} | sudo -S shutdown${time_string}
198
199 ${output} ${stderr} ${rc}= OS Execute Command
200 ... ${cmd_buf} fork=${1}
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500201
George Keishing3987a1e2017-09-20 09:13:02 -0500202
Steven Sombar5f3af442018-02-14 08:30:15 -0600203Set System LED State
204 [Documentation] Set given system LED via REST.
205 [Arguments] ${led_name} ${led_state}
206 # Description of argument(s):
207 # led_name System LED name (e.g. heartbeat, identify, beep).
208 # led_state LED state to be set (e.g. On, Off).
209
210 ${args}= Create Dictionary
211 ... data=xyz.openbmc_project.Led.Physical.Action.${led_state}
212 Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args}
213
214 Verify LED State ${led_name} ${led_state}
215
216
Steven Sombaraaf72c42017-09-05 12:02:00 -0500217Read Turbo Setting Via REST
218 [Documentation] Return turbo setting via REST.
Steven Sombarea79a492018-04-18 11:14:57 -0500219 # Returns 1 if TurboAllowed, 0 if not.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500220
Steven Sombarea79a492018-04-18 11:14:57 -0500221 ${turbo_setting}= Read Attribute
222 ... ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
George Keishing409df052024-01-17 22:36:14 +0530223 RETURN ${turbo_setting}
Steven Sombarea79a492018-04-18 11:14:57 -0500224
Steven Sombaraaf72c42017-09-05 12:02:00 -0500225
Steven Sombaraaf72c42017-09-05 12:02:00 -0500226Set Turbo Setting Via REST
227 [Documentation] Set turbo setting via REST.
Steven Sombar80bc8592018-04-24 11:44:53 -0500228 [Arguments] ${setting} ${verify}=${False}
Steven Sombar0acb3412018-01-24 09:38:42 -0600229
Steven Sombaraaf72c42017-09-05 12:02:00 -0500230 # Description of argument(s):
Steven Sombar80bc8592018-04-24 11:44:53 -0500231 # setting State to set TurboAllowed, 1=allowed, 0=not allowed.
232 # verify If True, read the TurboAllowed setting to confirm.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500233
Steven Sombarea79a492018-04-18 11:14:57 -0500234 ${data}= Create Dictionary data=${${setting}}
Steven Sombar80bc8592018-04-24 11:44:53 -0500235 Write Attribute ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
236 ... verify=${verify} data=${data}
George Keishingef74a8c2017-10-20 10:23:52 -0500237
Steven Sombar0acb3412018-01-24 09:38:42 -0600238
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600239Set REST Logging Policy
240 [Documentation] Enable or disable REST logging setting.
241 [Arguments] ${policy_setting}=${True}
George Keishingef74a8c2017-10-20 10:23:52 -0500242
243 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600244 # policy_setting The policy setting value which can be either
245 # True or False.
George Keishingef74a8c2017-10-20 10:23:52 -0500246
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600247 ${log_dict}= Create Dictionary data=${policy_setting}
George Keishingdf3e65f2018-12-18 13:06:56 -0600248 Write Attribute ${BMC_LOGGING_URI}rest_api_logs Enabled
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600249 ... data=${log_dict} verify=${1} expected_value=${policy_setting}
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -0500250
Steven Sombar0acb3412018-01-24 09:38:42 -0600251
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600252Old Get Boot Progress
253 [Documentation] Get the boot progress the old way (via org location).
254 [Arguments] ${quiet}=${QUIET}
George Keishing034902d2017-11-10 13:15:38 -0600255
256 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600257 # quiet Indicates whether this keyword should run without any output to
258 # the console.
259
260 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
261 ... value quiet=${quiet}
262
George Keishing409df052024-01-17 22:36:14 +0530263 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600264
265
266Set Boot Progress Method
267 [Documentation] Set the boot_prog_method to either 'Old' or 'New'.
268
269 # The boot progress data has moved from an 'org' location to an 'xyz'
270 # location. This keyword will determine whether the new method of getting
271 # the boot progress is valid and will set the global boot_prog_method
272 # variable accordingly. If boot_prog_method is already set (either by a
273 # prior call to this function or via a -v parm), this keyword will simply
274 # return.
275
276 # Note: There are interim builds that contain boot_progress in both the
277 # old and the new location values. It is nearly impossible for this
278 # keyword to determine whether the old boot_progress or the new one is
279 # active. When using such builds where the old boot_progress is active,
280 # the only recourse users will have is that they may specify
281 # -v boot_prog_method:Old to force old behavior on such builds.
282
283 Run Keyword If '${boot_prog_method}' != '${EMPTY}' Return From Keyword
284
285 ${new_status} ${new_value}= Run Keyword And Ignore Error
286 ... New Get Boot Progress
287 # If the new style read fails, the method must necessarily be "Old".
288 Run Keyword If '${new_status}' == 'PASS'
289 ... Run Keywords
290 ... Set Global Variable ${boot_prog_method} New AND
291 ... Rqpvars boot_prog_method AND
292 ... Return From Keyword
293
294 # Default method is "Old".
295 Set Global Variable ${boot_prog_method} Old
296 Rqpvars boot_prog_method
297
298
299Initiate Power On
300 [Documentation] Initiates the power on and waits until the Is Power On
301 ... keyword returns that the power state has switched to on.
302 [Arguments] ${wait}=${1}
303
304 # Description of argument(s):
305 # wait Indicates whether to wait for a powered on state after issuing
306 # the power on command.
307
308 @{arglist}= Create List
309 ${args}= Create Dictionary data=@{arglist}
310 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
311 ... data=${args}
312 should be equal as strings ${resp.status_code} ${HTTP_OK}
313
314 # Does caller want to wait for power on status?
315 Run Keyword If '${wait}' == '${0}' Return From Keyword
316 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
317
318
319Initiate Power Off
320 [Documentation] Initiates the power off and waits until the Is Power Off
321 ... keyword returns that the power state has switched to off.
322
323 @{arglist}= Create List
324 ${args}= Create Dictionary data=@{arglist}
325 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
326 ... data=${args}
327 should be equal as strings ${resp.status_code} ${HTTP_OK}
328 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
329
330
331Get Boot Progress
332 [Documentation] Get the boot progress and return it.
333 [Arguments] ${quiet}=${QUIET}
334
335 # Description of argument(s):
336 # quiet Indicates whether this keyword should run without any output to
337 # the console.
338
339 Set Boot Progress Method
340 ${state}= Run Keyword If '${boot_prog_method}' == 'New'
341 ... New Get Boot Progress quiet=${quiet}
342 ... ELSE
343 ... Old Get Boot Progress quiet=${quiet}
344
George Keishing409df052024-01-17 22:36:14 +0530345 RETURN ${state}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600346
347
348New Get Boot Progress
349 [Documentation] Get the boot progress the new way (via xyz location).
350 [Arguments] ${quiet}=${QUIET}
351
352 # Description of argument(s):
353 # quiet Indicates whether this keyword should run without any output to
354 # the console.
355
356 ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet}
357
George Keishing409df052024-01-17 22:36:14 +0530358 RETURN ${state.rsplit('.', 1)[1]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600359
360
361New Get Power Policy
362 [Documentation] Returns the BMC power policy (new method).
363 ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy
364
George Keishing409df052024-01-17 22:36:14 +0530365 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600366
367
368Old Get Power Policy
369 [Documentation] Returns the BMC power policy (old method).
370 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
371
George Keishing409df052024-01-17 22:36:14 +0530372 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600373
374
George Keishinga54e06f2020-06-12 10:42:41 -0500375Redfish Get Power Restore Policy
376 [Documentation] Returns the BMC power restore policy.
377
Yi Huc32434a2024-01-11 17:33:10 -0800378 ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} PowerRestorePolicy
George Keishing409df052024-01-17 22:36:14 +0530379 RETURN ${power_restore_policy}
380
George Keishinga54e06f2020-06-12 10:42:41 -0500381
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600382Get Auto Reboot
383 [Documentation] Returns auto reboot setting.
384 ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
385
George Keishing409df052024-01-17 22:36:14 +0530386 RETURN ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600387
388
George Keishingc8a6dd22020-06-12 12:01:33 -0500389Redfish Get Auto Reboot
390 [Documentation] Returns auto reboot setting.
391
George Keishing43909f32024-08-20 22:08:02 +0530392 ${resp}= Wait Until Keyword Succeeds 1 min 20 sec
393 ... Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing409df052024-01-17 22:36:14 +0530394 RETURN ${resp["AutomaticRetryConfig"]}
George Keishingc8a6dd22020-06-12 12:01:33 -0500395
396
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600397Trigger Warm Reset
398 [Documentation] Initiate a warm reset.
399
400 log to console "Triggering warm reset"
401 ${data}= create dictionary data=@{EMPTY}
George Keishingfbd67002022-08-01 11:24:03 -0500402 ${resp}= Openbmc Post Request
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600403 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
404 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
405 ${session_active}= Check If warmReset is Initiated
406 Run Keyword If '${session_active}' == '${True}'
407 ... Fail msg=warm reset didn't occur
408
409 Sleep ${SYSTEM_SHUTDOWN_TIME}min
410 Check If BMC Is Up
411
412
413Get Power State
414 [Documentation] Returns the power state as an integer. Either 0 or 1.
415 [Arguments] ${quiet}=${QUIET}
416
417 # Description of argument(s):
418 # quiet Indicates whether this keyword should run without any output to
419 # the console.
420
421 @{arglist}= Create List
422 ${args}= Create Dictionary data=@{arglist}
423
424 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
425 ... data=${args} quiet=${quiet}
426 Should be equal as strings ${resp.status_code} ${HTTP_OK}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600427
George Keishing409df052024-01-17 22:36:14 +0530428 RETURN ${resp.json()["data"]}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600429
430
431Clear BMC Gard Record
432 [Documentation] Clear gard records from the system.
433
434 @{arglist}= Create List
435 ${args}= Create Dictionary data=@{arglist}
436 ${resp}= Call Method
437 ... ${OPENPOWER_CONTROL}gard Reset data=${args}
438 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
439
440
441Flash PNOR
442 [Documentation] Calls flash bios update method to flash PNOR image
443 [Arguments] ${pnor_image}
444
445 # Description of argument(s):
446 # pnor_image The filename and path of the PNOR image
447 # (e.g. "/home/image/zaius.pnor").
448
449 @{arglist}= Create List ${pnor_image}
450 ${args}= Create Dictionary data=@{arglist}
451 ${resp}= Call Method /org/openbmc/control/flash/bios/ update
452 ... data=${args}
453 should be equal as strings ${resp.status_code} ${HTTP_OK}
454 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
455
456
457Get Flash BIOS Status
458 [Documentation] Returns the status of the flash BIOS API as a string. For
459 ... example 'Flashing', 'Flash Done', etc
460 ${data}= Read Properties /org/openbmc/control/flash/bios
George Keishing409df052024-01-17 22:36:14 +0530461 RETURN ${data['status']}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600462
463
464Is PNOR Flashing
465 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
466 ... flashing has started.
467 ${status}= Get Flash BIOS Status
468 Should Contain ${status} Flashing
469
470
471Is PNOR Flash Done
472 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
473 ... PNOR flashing has completed.
474 ${status}= Get Flash BIOS Status
475 should be equal as strings ${status} Flash Done
476
477
478Create OS Console File Path
479 [Documentation] Create OS console file path name and return it.
480 [Arguments] ${log_file_path}=${EMPTY}
481
482 # Description of arguments:
483 # file_path The caller's candidate value. If this value is ${EMPTY}, this
484 # keyword will compose a file path name. Otherwise, this
485 # keyword will use the caller's file_path value. In either
486 # case, the value will be returned.
487
488 ${status}= Run Keyword And Return Status Variable Should Exist
489 ... ${TEST_NAME}
490
491 ${default_file_path}= Set Variable If ${status} == ${TRUE}
George Keishing9161b102021-12-10 02:26:30 -0600492 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt
493 ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_os_console.txt
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600494
495 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
496 ... ${default_file_path} ${log_file_path}
497
George Keishing409df052024-01-17 22:36:14 +0530498 RETURN ${log_file_path}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600499
500
501Get Endpoint Paths
502 [Documentation] Returns all url paths ending with given endpoint
503 ... Example:
504 ... Given the following endpoint: cpu
505 ... This keyword will return: list of all urls ending with
506 ... cpu -
507 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
508 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
509 [Arguments] ${path} ${endpoint}
510
511 # Description of arguments:
512 # path URL path for enumeration.
513 # endpoint Endpoint string (url path ending).
514
Steven Sombaraaaab222018-12-19 13:16:23 -0600515 # Make sure path ends with slash.
516 ${path}= Add Trailing Slash ${path}
517
518 ${resp}= Read Properties ${path}enumerate timeout=30
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600519 Log Dictionary ${resp}
520
521 ${list}= Get Dictionary Keys ${resp}
522 # For a given string, look for prefix and suffix for matching expression.
523 # Start of string followed by zero or more of any character followed by
524 # any digit or lower case character.
George Keishing585afa32020-07-09 04:55:15 -0500525 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[_0-9a-z]*$ case_insensitive=${True}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600526
George Keishing409df052024-01-17 22:36:14 +0530527 RETURN ${resp}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600528
529
530Set BMC Power Policy
531 [Documentation] Set the given BMC power policy.
532 [Arguments] ${policy}
533
534 # Note that this function will translate the old style "RESTORE_LAST_STATE"
535 # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy.
536 # Policy.Restore" for you.
537
538 # Description of argument(s):
539 # policy Power restore policy (e.g "RESTORE_LAST_STATE",
540 # ${RESTORE_LAST_STATE}).
541
542 # Set the bmc_power_policy_method to either 'Old' or 'New'.
543 Set Power Policy Method
544 # This translation helps bridge between old and new method for calling.
545 ${policy}= Translate Power Policy Value ${policy}
546 # Run the appropriate keyword.
547 Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy}
548 ${currentPolicy}= Get System Power Policy
549 Should Be Equal ${currentPolicy} ${policy}
550
551
552Delete Error Logs
553 [Documentation] Delete error logs.
Michael Sheposcc490b42020-08-26 12:53:01 -0500554 [Arguments] ${quiet}=${0}
555 # Description of argument(s):
556 # quiet If enabled, turns off logging to console.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600557
558 # Check if error logs entries exist, if not return.
Steven Sombara8800da2018-12-18 16:19:05 -0600559 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600560 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
561
562 # Get the list of error logs entries and delete them all.
563 ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY}
David Shaw79247e42020-06-18 17:16:02 -0500564 FOR ${entry} IN @{elog_entries}
Michael Sheposcc490b42020-08-26 12:53:01 -0500565 Delete Error Log Entry ${entry} quiet=${quiet}
David Shaw79247e42020-06-18 17:16:02 -0500566 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600567
568
569Delete All Error Logs
570 [Documentation] Delete all error log entries using "DeleteAll" interface.
571
George Keishingfbd67002022-08-01 11:24:03 -0500572 ${args}= Set Variable {"data": []}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600573 ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
George Keishingfbd67002022-08-01 11:24:03 -0500574 ... data=${args}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600575 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
576
577
578Get Elog URL List
579 [Documentation] Return error log entry list of URLs.
580
581 ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/
582 Sort List ${url_list}
George Keishing409df052024-01-17 22:36:14 +0530583 RETURN ${url_list}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600584
585
586Get BMC Flash Chip Boot Side
587 [Documentation] Return the BMC flash chip boot side.
George Keishing034902d2017-11-10 13:15:38 -0600588
589 # Example:
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600590 # 0 - indicates chip select is current side.
591 # 32 - indicates chip select is alternate side.
George Keishing034902d2017-11-10 13:15:38 -0600592
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600593 ${boot_side} ${stderr} ${rc}= BMC Execute Command
594 ... cat /sys/class/watchdog/watchdog1/bootstatus
595
George Keishing409df052024-01-17 22:36:14 +0530596 RETURN ${boot_side}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600597
598
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600599Watchdog Object Should Exist
600 [Documentation] Check that watchdog object exists.
601
602 ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0
603 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
604 ... msg=Expected watchdog object does not exist.
Sweta Potthurif39022d2018-02-06 03:40:07 -0600605
606
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600607Get System LED State
608 [Documentation] Return the state of given system LED.
609 [Arguments] ${led_name}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600610
611 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600612 # led_name System LED name (e.g. heartbeat, identify, beep).
Sweta Potthurif39022d2018-02-06 03:40:07 -0600613
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600614 ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
George Keishing409df052024-01-17 22:36:14 +0530615 RETURN ${state.rsplit('.', 1)[1]}
George Keishingb9f407b2018-02-20 00:07:46 -0600616
617
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600618Verify LED State
619 [Documentation] Checks if LED is in given state.
620 [Arguments] ${led_name} ${led_state}
621 # Description of argument(s):
622 # led_name System LED name (e.g. heartbeat, identify, beep).
623 # led_state LED state to be verified (e.g. On, Off).
George Keishingb9f407b2018-02-20 00:07:46 -0600624
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600625 ${state}= Get System LED State ${led_name}
626 Should Be Equal ${state} ${led_state}
George Keishingb9f407b2018-02-20 00:07:46 -0600627
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600628
629Get LED State XYZ
630 [Documentation] Returns state of given LED.
631 [Arguments] ${led_name}
632
633 # Description of argument(s):
634 # led_name Name of LED.
635
636 ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted
637 # Returns the state of the LED, either On or Off.
George Keishing409df052024-01-17 22:36:14 +0530638 RETURN ${state}
George Keishingb9f407b2018-02-20 00:07:46 -0600639
George Keishing78ce8dc2018-03-30 11:49:06 -0500640
641Verify Identify LED State
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500642 [Documentation] Verify that the identify state of the LED group matches caller's expectations.
George Keishing78ce8dc2018-03-30 11:49:06 -0500643 [Arguments] ${expected_state}
644
645 # Description of argument(s):
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500646 # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted).
George Keishing78ce8dc2018-03-30 11:49:06 -0500647
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500648 ${led_state}= Get LED State XYZ enclosure_identify
649 Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state.
Sweta Potthuri39255032018-03-28 10:12:14 -0500650
651Verify The Attribute
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500652 [Documentation] Verify the given attribute.
Sweta Potthuri39255032018-03-28 10:12:14 -0500653 [Arguments] ${uri} ${attribute_name} ${attribute_value}
654
655 # Description of argument(s):
656 # uri URI path
657 # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable").
658 # attribute_name Name of attribute to be verified (e.g. "TPMEnable").
659 # attribute_value The expected value of attribute (e.g. "1", "0", etc.)
660
661 ${output}= Read Attribute ${uri} ${attribute_name}
662 Should Be Equal ${attribute_value} ${output}
663 ... msg=Attribute "${attribute_name} does not have the expected value.
George Keishingcf0d7772018-05-04 08:22:50 -0500664
665
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600666New Set Power Policy
667 [Documentation] Set the given BMC power policy (new method).
668 [Arguments] ${policy}
George Keishingb4adfc72018-10-26 09:39:32 -0500669
670 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600671 # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}).
George Keishingc5fef582018-07-18 08:41:28 -0500672
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600673 ${valueDict}= Create Dictionary data=${policy}
674 Write Attribute
675 ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict}
George Keishing216e5842018-08-31 14:58:15 -0500676
677
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600678Old Set Power Policy
679 [Documentation] Set the given BMC power policy (old method).
680 [Arguments] ${policy}
George Keishing3c004dc2018-10-10 07:16:47 -0500681
682 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600683 # policy Power restore policy (e.g. "ALWAYS_POWER_OFF").
684
685 ${valueDict}= create dictionary data=${policy}
686 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
George Keishing3c004dc2018-10-10 07:16:47 -0500687
688
George Keishinga54e06f2020-06-12 10:42:41 -0500689Redfish Set Power Restore Policy
690 [Documentation] Set the BMC power restore policy.
691 [Arguments] ${power_restore_policy}
692
693 # Description of argument(s):
694 # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
695
Yi Huc32434a2024-01-11 17:33:10 -0800696 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"PowerRestorePolicy": "${power_restore_policy}"}
George Keishinga54e06f2020-06-12 10:42:41 -0500697 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
698
699
George Keishing9a288602021-12-10 04:50:25 -0600700IPMI Set Power Restore Policy
701 [Documentation] Set the BMC power restore policy using IPMI.
702 [Arguments] ${power_restore_policy}=always-off
703
704 # Description of argument(s):
705 # power_restore_policy Power restore policies
706 # always-on : turn on when power is restored
707 # previous : return to previous state when power is restored
708 # always-off : stay off after power is restored
709
710 ${resp}= Run IPMI Standard Command chassis policy ${power_restore_policy}
711 # Example: Set chassis power restore policy to always-off
712 Should Contain ${resp} ${power_restore_policy}
713
714
George Keishinga5cedb32020-07-17 15:50:34 -0500715Set Auto Reboot Setting
716 [Documentation] Set the given auto reboot setting (REST or Redfish).
717 [Arguments] ${value}
718
719 # Description of argument(s):
720 # value The reboot setting, 1 for enabling and 0 for disabling.
721
722 # This is to cater to boot call points and plugin script which will always
723 # send using value 0 or 1. This dictionary maps to redfish string values.
724 ${rest_redfish_dict}= Create Dictionary
725 ... 1=RetryAttempts
726 ... 0=Disabled
727
George Keishinge1879642020-12-09 13:20:15 -0600728 Run Keyword If ${REDFISH_SUPPORT_TRANS_STATE} == ${1}
George Keishinga5cedb32020-07-17 15:50:34 -0500729 ... Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]}
George Keishinge1879642020-12-09 13:20:15 -0600730 ... ELSE
731 ... Set Auto Reboot ${value}
George Keishinga5cedb32020-07-17 15:50:34 -0500732
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600733Set Auto Reboot
734 [Documentation] Set the given auto reboot setting.
735 [Arguments] ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500736
737 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600738 # setting The reboot setting, 1 for enabling and 0 for disabling.
George Keishing3c004dc2018-10-10 07:16:47 -0500739
Sridevi Ramesh68d72ff2019-02-04 09:24:46 -0600740 ${valueDict}= Convert To Integer ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600741 ${data}= Create Dictionary data=${valueDict}
742 Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data}
743 ${current_setting}= Get Auto Reboot
744 Should Be Equal As Integers ${current_setting} ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500745
George Keishingc25c55d2018-10-30 02:23:44 -0500746
George Keishingc8a6dd22020-06-12 12:01:33 -0500747Redfish Set Auto Reboot
748 [Documentation] Set the given auto reboot setting.
749 [Arguments] ${setting}
750
751 # Description of argument(s):
752 # setting The reboot setting, "RetryAttempts" and "Disabled".
753
Yi Huc32434a2024-01-11 17:33:10 -0800754 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
George Keishinga8cb28d2020-06-15 03:10:29 -0500755 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
George Keishinga8cb28d2020-06-15 03:10:29 -0500756
George Keishingc8a6dd22020-06-12 12:01:33 -0500757 ${current_setting}= Redfish Get Auto Reboot
758 Should Be Equal As Strings ${current_setting} ${setting}
759
760
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600761Set Control Boot Mode
762 [Documentation] Set given boot mode on the boot object path attribute.
763 [Arguments] ${boot_path} ${boot_mode}
George Keishingc25c55d2018-10-30 02:23:44 -0500764
765 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600766 # boot_path Boot object path.
767 # Example:
768 # /xyz/openbmc_project/control/host0/boot
769 # /xyz/openbmc_project/control/host0/boot/one_time
770 # boot_mode Boot mode which need to be set.
771 # Example:
772 # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
George Keishingc25c55d2018-10-30 02:23:44 -0500773
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600774 ${valueDict}= Create Dictionary data=${boot_mode}
775 Write Attribute ${boot_path} BootMode data=${valueDict}
George Keishingc25c55d2018-10-30 02:23:44 -0500776
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600777
778Is Power On
779 [Documentation] Verify that the BMC chassis state is on.
780 ${state}= Get Power State
781 Should be equal ${state} ${1}
782
783
784Is Power Off
785 [Documentation] Verify that the BMC chassis state is off.
786 ${state}= Get Power State
787 Should be equal ${state} ${0}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500788
789
790CLI Get BMC DateTime
791 [Documentation] Returns BMC date time from date command.
792
793 ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1
George Keishing409df052024-01-17 22:36:14 +0530794 RETURN ${bmc_time_via_date}
George Keishing61364e52019-10-01 12:01:19 -0500795
796
797Update Root Password
798 [Documentation] Update system "root" user password.
799 [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD}
800
801 # Description of argument(s):
802 # openbmc_password The root password for the open BMC system.
803
804 @{password}= Create List ${openbmc_password}
805 ${data}= Create Dictionary data=@{password}
806
807 ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
George Keishingfbd67002022-08-01 11:24:03 -0500808 ${resp}= POST On Session openbmc ${BMC_USER_URI}root/action/SetPassword
George Keishing61364e52019-10-01 12:01:19 -0500809 ... data=${data} headers=${headers}
810 Valid Value resp.status_code [${HTTP_OK}]
Sushil Singh6624ce52020-01-22 00:53:41 -0600811
812
813Get Post Boot Action
814 [Documentation] Get post boot action.
815
George Keishing879f0842020-02-05 11:00:47 -0600816 # Post code update action dictionary.
Sushil Singh6624ce52020-01-22 00:53:41 -0600817 #
818 # {
819 # BMC image: {
820 # OnReset: Redfish OBMC Reboot (off),
821 # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
822 # },
823 # Host image: {
George Keishinge523fc02020-03-23 12:28:01 -0500824 # OnReset: RF SYS GracefulRestart,
Sushil Singh6624ce52020-01-22 00:53:41 -0600825 # Immediate: Wait State os_running_match_state 10 mins
826 # }
827 # }
828
829 ${code_base_dir_path}= Get Code Base Dir Path
830 ${post_code_update_actions}= Evaluate
831 ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
832 Rprint Vars post_code_update_actions
833
George Keishing409df052024-01-17 22:36:14 +0530834 RETURN ${post_code_update_actions}
Sushil Singh6624ce52020-01-22 00:53:41 -0600835
George Keishing1eeff9c2020-06-16 04:03:34 -0500836
Sushil Singh1560e652022-08-03 13:25:01 -0500837Get Task State From File
838 [Documentation] Get task states from pre-define data/task_state.json file.
839
840 # Example: Task state JSON format.
841 #
842 # {
843 # "TaskRunning": {
844 # "TaskState": "Running",
845 # "TaskStatus": "OK"
846 # },
847 # "TaskCompleted": {
848 # "TaskState": "Completed",
849 # "TaskStatus": "OK"
850 # },
851 # "TaskException": {
852 # "TaskState": "Exception",
853 # "TaskStatus": "Warning"
854 # }
855 # }
856
857 # Python module: get_code_base_dir_path()
858 ${code_base_dir_path}= Get Code Base Dir Path
859 ${task_state}= Evaluate
860 ... json.load(open('${code_base_dir_path}data/task_state.json')) modules=json
861 Rprint Vars task_state
862
George Keishing409df052024-01-17 22:36:14 +0530863 RETURN ${task_state}
Sushil Singh1560e652022-08-03 13:25:01 -0500864
865
George Keishing1eeff9c2020-06-16 04:03:34 -0500866Redfish Set Boot Default
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300867 [Documentation] Set and Verify Boot source override
868 [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI
George Keishing1eeff9c2020-06-16 04:03:34 -0500869
870 # Description of argument(s):
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300871 # override_enabled Boot source override enable type.
George Keishing1eeff9c2020-06-16 04:03:34 -0500872 # ('Once', 'Continuous', 'Disabled').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300873 # override_target Boot source override target.
George Keishing1eeff9c2020-06-16 04:03:34 -0500874 # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300875 # override_mode Boot source override mode (relevant only for x86 arch).
876 # ('Legacy', 'UEFI').
George Keishing1eeff9c2020-06-16 04:03:34 -0500877
878 ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled}
879 ... BootSourceOverrideTarget=${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300880
881 Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
882 ... Set To Dictionary ${data} BootSourceOverrideMode ${override_mode}
883
George Keishing1eeff9c2020-06-16 04:03:34 -0500884 ${payload}= Create Dictionary Boot=${data}
885
Yi Huc32434a2024-01-11 17:33:10 -0800886 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body=&{payload}
George Keishing1eeff9c2020-06-16 04:03:34 -0500887 ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
888
Yi Huc32434a2024-01-11 17:33:10 -0800889 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot
George Keishing1eeff9c2020-06-16 04:03:34 -0500890 Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled}
891 Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target}
Konstantin Aladyshev0043fc52021-04-15 12:07:29 +0300892 Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
893 ... Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode}
George Keishinge1879642020-12-09 13:20:15 -0600894
895
896# Redfish state keywords.
897
898Redfish Get BMC State
899 [Documentation] Return BMC health state.
900
901 # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady
902
903 # Example:
904 # "Status": {
905 # "Health": "OK",
906 # "HealthRollup": "OK",
907 # "State": "Enabled"
908 # },
909
George Keishing43909f32024-08-20 22:08:02 +0530910 ${status}= Wait Until Keyword Succeeds 1 min 20 sec
911 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
George Keishing409df052024-01-17 22:36:14 +0530912 RETURN ${status["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600913
914
Sushil Singh472177b2023-08-28 05:28:30 -0500915Redfish Verify BMC State
916 [Documentation] Verify BMC state is enabled.
917 [Arguments] ${match_state}=Enabled
918
919 # Description of argument(s):
920 # match_state Expected match state (e.g. Enabled, Starting, Error)
921
George Keishing43909f32024-08-20 22:08:02 +0530922 ${Status}= Wait Until Keyword Succeeds 1 min 20 sec
923 ... Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status
Sushil Singh472177b2023-08-28 05:28:30 -0500924
925 Should Be Equal As Strings ${match_state} ${Status['State']}
926
927
George Keishinge1879642020-12-09 13:20:15 -0600928Redfish Get Host State
929 [Documentation] Return host power and health state.
930
931 # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status
932
933 # Example:
934 # "PowerState": "Off",
935 # "Status": {
936 # "Health": "OK",
937 # "HealthRollup": "OK",
938 # "State": "StandbyOffline"
939 # },
940
George Keishing43909f32024-08-20 22:08:02 +0530941 ${chassis}= Wait Until Keyword Succeeds 1 min 20 sec
942 ... Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}
George Keishing409df052024-01-17 22:36:14 +0530943 RETURN ${chassis["PowerState"]} ${chassis["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600944
945
946Redfish Get Boot Progress
947 [Documentation] Return boot progress state.
948
949 # Example: /redfish/v1/Systems/system/
950 # "BootProgress": {
951 # "LastState": "OSRunning"
952 # },
953
George Keishing43909f32024-08-20 22:08:02 +0530954 ${boot_progress}= Wait Until Keyword Succeeds 1 min 20 sec
955 ... Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/
George Keishingb51d1502021-03-25 03:30:33 -0500956
957 Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86"
958 ... NA ${boot_progress["Status"]["State"]}
959
George Keishing409df052024-01-17 22:36:14 +0530960 RETURN ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]}
George Keishinge1879642020-12-09 13:20:15 -0600961
962
963Redfish Get States
964 [Documentation] Return all the BMC and host states in dictionary.
Sushil Singhfd0f91b2023-11-10 07:35:11 -0600965 [Timeout] ${REDFISH_SYS_STATE_WAIT_TIMEOUT}
George Keishinge1879642020-12-09 13:20:15 -0600966
967 # Refer: openbmc/docs/designs/boot-progress.md
968
George Keishing205f95f2021-03-10 02:25:53 -0600969 Redfish.Login
George Keishinge1879642020-12-09 13:20:15 -0600970
971 ${bmc_state}= Redfish Get BMC State
972 ${chassis_state} ${chassis_status}= Redfish Get Host State
973 ${boot_progress} ${host_state}= Redfish Get Boot Progress
974
975 ${states}= Create Dictionary
976 ... bmc=${bmc_state}
977 ... chassis=${chassis_state}
978 ... host=${host_state}
979 ... boot_progress=${boot_progress}
980
George Keishing64293c52021-03-24 08:21:23 -0500981 # Disable loggoing state to prevent huge log.html record when boot
982 # test is run in loops.
983 #Log ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600984
George Keishing409df052024-01-17 22:36:14 +0530985 RETURN ${states}
George Keishing95cf8652021-02-08 11:32:33 -0600986
987
Sushil Singh80029902023-03-06 01:33:00 -0600988Is BMC Not Quiesced
989 [Documentation] Verify BMC state is not quiesced.
990
991 ${bmc_state}= Redfish Get States
992
993 Log To Console BMC State : ${bmc_state}
994
995 Should Not Be Equal As Strings Quiesced ${bmc_state['bmc']}
996
997
George Keishing95cf8652021-02-08 11:32:33 -0600998Is BMC Standby
999 [Documentation] Check if BMC is ready and host at standby.
1000
1001 ${standby_states}= Create Dictionary
1002 ... bmc=Enabled
1003 ... chassis=Off
1004 ... host=Disabled
1005 ... boot_progress=None
1006
aravinth0510de1863d2022-06-27 17:26:14 +00001007 Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86'
1008 ... Set To Dictionary ${standby_states} boot_progress=NA
1009
George Keishing95cf8652021-02-08 11:32:33 -06001010 Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States
1011
Rahul Maheshwari258d5922022-11-27 01:04:39 -06001012 Wait Until Keyword Succeeds 5 min 10 sec Match State ${standby_states}
George Keishing95cf8652021-02-08 11:32:33 -06001013
1014
1015Match State
1016 [Documentation] Check if the expected and current states are matched.
1017 [Arguments] ${match_state}
1018
1019 # Description of argument(s):
1020 # match_state Expected states in dictionary.
1021
1022 ${current_state}= Redfish Get States
1023 Dictionaries Should Be Equal ${match_state} ${current_state}
Peter D Phan49739b22021-09-29 14:30:08 -05001024
1025
praphullasuresh95589b32023-08-24 08:59:28 -05001026Wait For Host Boot Progress To Reach Required State
1027 [Documentation] Wait till host boot progress reaches required state.
praphullasuresheacfac92023-08-25 06:51:01 -05001028 [Arguments] ${expected_boot_state}=OSRunning
praphullasuresh95589b32023-08-24 08:59:28 -05001029
1030 # Description of argument(s):
1031 # expected_boot_state Expected boot state. E.g. OSRunning, SystemInitComplete etc.
1032
1033 Wait Until Keyword Succeeds ${power_on_timeout} 20 sec
1034 ... Is Boot Progress At Required State ${expected_boot_state}
1035
1036
Peter D Phan49739b22021-09-29 14:30:08 -05001037Redfish Initiate Auto Reboot
1038 [Documentation] Initiate an auto reboot.
1039 [Arguments] ${interval}=2000
1040
1041 # Description of argument(s):
1042 # interval Value in milliseconds to set Watchdog interval
1043
1044 # Set auto reboot policy
1045 Redfish Set Auto Reboot RetryAttempts
1046
George Keishingc0701102021-09-30 12:12:04 -05001047 Redfish Power Operation On
George Keishinga4e13522022-04-13 11:14:53 -05001048
1049 Wait Until Keyword Succeeds 2 min 5 sec Is Boot Progress Changed
George Keishingc0701102021-09-30 12:12:04 -05001050
Peter D Phan49739b22021-09-29 14:30:08 -05001051 # Set watchdog timer
1052 Set Watchdog Interval Using Busctl ${interval}
1053
1054
George Keishinga4e13522022-04-13 11:14:53 -05001055Is Boot Progress Changed
1056 [Documentation] Get BootProgress state and expect boot state mismatch.
1057 [Arguments] ${boot_state}=None
1058
1059 # Description of argument(s):
1060 # boot_state Value of the BootProgress state to match against.
1061
1062 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1063
1064 Should Not Be Equal ${boot_progress} ${boot_state}
1065
Peter D Phan49739b22021-09-29 14:30:08 -05001066
Sridevi Ramesh13d84bf2022-10-31 09:14:52 -05001067Is Boot Progress At Required State
1068 [Documentation] Get BootProgress state and expect boot state to match.
1069 [Arguments] ${boot_state}=None
1070
1071 # Description of argument(s):
1072 # boot_state Value of the BootProgress state to match.
1073
1074 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1075
1076 Should Be Equal ${boot_progress} ${boot_state}
1077
1078
1079Is Boot Progress At Any State
1080 [Documentation] Get BootProgress state and expect boot state to match
1081 ... with any of the states mentioned in the list.
1082 [Arguments] ${boot_states}=@{BOOT_PROGRESS_STATES}
1083
1084 # Description of argument(s):
1085 # boot_states List of the BootProgress states to match.
1086
1087 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1088 Should Contain Any ${boot_progress} @{boot_states}
1089
1090
Sagar Anand0e262662023-01-24 11:36:01 -06001091Is Host At State
1092 [Documentation] Get Host state and check if it matches
1093 ... user input expected state.
1094 [Arguments] ${expected_host_state}
1095
1096 # Description of argument(s):
1097 # expected_host_state Expected Host State to check.(e.g. Quiesced).
1098
1099 ${boot_progress} ${host_state}= Redfish Get Boot Progress
1100
1101 Should Be Equal ${host_state} ${expected_host_state}
1102
1103
Peter D Phan49739b22021-09-29 14:30:08 -05001104Set Watchdog Interval Using Busctl
1105 [Documentation] Set Watchdog time interval.
1106 [Arguments] ${milliseconds}=1000
1107
1108 # Description of argument(s):
George Keishing4b729492021-11-10 12:51:10 -06001109 # milliseconds Time interval for watchdog timer
Peter D Phan49739b22021-09-29 14:30:08 -05001110
George Keishingc0701102021-09-30 12:12:04 -05001111 ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog
1112 ... /xyz/openbmc_project/watchdog/host0
1113 ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds}
Peter D Phan49739b22021-09-29 14:30:08 -05001114 BMC Execute Command ${cmd}
1115
George Keishingf5fec0d2021-10-08 12:38:45 -05001116
1117Stop PLDM Service And Wait
1118 [Documentation] Stop PLDM service and wait for Host to initiate reset.
1119
1120 BMC Execute Command systemctl stop pldmd.service
1121
George Keishingca76e372022-03-16 12:45:26 -05001122
1123Get BIOS Attribute
1124 [Documentation] Get the BIOS attribute for /redfish/v1/Systems/system/Bios.
1125
1126 # Python module: get_member_list(resource_path)
1127 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1128 ${bios_attr_dict}= Redfish.Get Attribute ${systems[0]}/Bios Attributes
1129
George Keishing409df052024-01-17 22:36:14 +05301130 RETURN ${bios_attr_dict}
nagarjunb22cfb2c412022-03-15 15:49:27 +05301131
George Keishing8f610e72022-03-28 10:43:08 -05001132
1133Set BIOS Attribute
1134 [Documentation] PATCH the BIOS attribute for /redfish/v1/Systems/system/Bios.
1135 [Arguments] ${attribute_name} ${attribute_value}
1136
1137 # Description of argument(s):
1138 # attribute_name Any valid BIOS attribute.
1139 # attribute_value Valid allowed attribute values.
1140
1141 # Python module: get_member_list(resource_path)
1142 ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems
1143 Redfish.Patch ${systems[0]}/Bios/Settings body={"Attributes":{"${attribute_name}":"${attribute_value}"}}
1144
1145
nagarjunb22cfb2c412022-03-15 15:49:27 +05301146Is BMC Operational
1147 [Documentation] Check if BMC is enabled.
ganesanb13fb3cf2023-05-12 00:42:18 +00001148 [Teardown] Redfish.Logout
nagarjunb22cfb2c412022-03-15 15:49:27 +05301149
ganesanb13fb3cf2023-05-12 00:42:18 +00001150 Wait Until Keyword Succeeds 5 min 5 sec Ping Host ${OPENBMC_HOST}
1151 # In some of bmc stack, network services will gets loaded before redfish/ipmi services gets loaded.
1152 # Hence, 3mins sleep time is added to allow other service gets loaded.
1153 Sleep 180s
1154 Redfish.login
1155 ${bmc_status}= Redfish Get BMC State
nagarjunb22cfb2c412022-03-15 15:49:27 +05301156 Should Be Equal ${bmc_status} Enabled
George Keishing83c737b2022-05-17 12:12:04 -05001157
1158
1159PLDM Set BIOS Attribute
1160 [Documentation] Set the BIOS attribute via pldmtool and verify the attribute is set.
1161 ... Defaulted for fw_boot_side for boot test usage caller.
1162 [Arguments] ${attribute_name}=fw_boot_side ${attribute_value}=Temp
1163
1164 # Description of argument(s):
1165 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1166 # attribute_value Valid BIOS attribute value for fw_boot_side.
1167
1168 # PLDM response output example:
1169 # {
1170 # "Response": "SUCCESS"
1171 # }
1172
1173 ${resp}= pldmtool bios SetBIOSAttributeCurrentValue -a ${attribute_name} -d ${attribute_value}
1174 Should Be Equal As Strings ${resp["Response"]} SUCCESS
1175
1176 # PLDM GET output example:
1177 # {
1178 # "CurrentValue": "Temp"
1179 # }
1180
1181 ${pldm_output}= PLDM Get BIOS Attribute ${attribute_name}
1182 Should Be Equal As Strings ${pldm_output["CurrentValue"]} ${attribute_value}
1183 ... msg=Expecting ${attribute_value} but got ${pldm_output["CurrentValue"]}
1184
1185
1186PLDM Get BIOS Attribute
1187 [Documentation] Get the BIOS attribute via pldmtool for a given attribute and return value.
1188 [Arguments] ${attribute_name}
1189
1190 # Description of argument(s):
1191 # attribute_name Valid BIOS attribute name e.g ("fw_boot_side")
1192
1193 ${pldm_output}= pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${attribute_name}
George Keishing409df052024-01-17 22:36:14 +05301194 RETURN ${pldm_output}
nagarjunb2200108dc2022-07-12 21:50:45 +05301195
1196
1197Verify Host Power State
1198 [Documentation] Get the Host Power state and compare it with the expected state.
1199 [Arguments] ${expected_power_state}
1200
1201 # Description of argument(s):
1202 # expected_power_state State of Host e.g. Off or On.
1203
1204 ${power_state} ${health_status}= Redfish Get Host State
1205 Should Be Equal ${power_state} ${expected_power_state}
1206
1207
1208Verify Host Is Up
1209 [Documentation] Verify Host is Up.
1210
1211 Wait Until Keyword Succeeds 3 min 30 sec Verify Host Power State On
1212 # Python module: os_execute(cmd)
1213 Wait Until Keyword Succeeds 10 min 30 sec OS Execute Command uptime