blob: 9f6c9483096273cfae4cf8565fe11a4d49c82217 [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
Michael Walsh391ba9b2017-08-24 11:36:24 -050010Library String
George Keishing30c12ff2016-09-02 10:25:29 -050011Library DateTime
12Library Process
Chris Austenb29d2e82016-06-07 12:25:35 -050013Library OperatingSystem
Michael Walsha6723f22016-11-22 11:12:01 -060014Library gen_print.py
Steven Sombaraaaab222018-12-19 13:16:23 -060015Library gen_misc.py
Michael Walsha6723f22016-11-22 11:12:01 -060016Library gen_robot_print.py
Michael Walsh5f3f4142017-05-22 17:09:47 -050017Library gen_cmd.py
Sunil Macd110a2017-05-23 04:14:32 -050018Library gen_robot_keyword.py
Michael Walshe53e47a2017-06-30 17:03:24 -050019Library bmc_ssh_utils.py
Michael Walshfdc5ced2017-08-17 13:15:15 -050020Library utils.py
Charles Paul Hofer35816152017-10-02 11:55:11 -050021Library var_funcs.py
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050022Library SCPLibrary WITH NAME scp
George Keishing61364e52019-10-01 12:01:19 -050023Library gen_robot_valid.py
Chris Austenb29d2e82016-06-07 12:25:35 -050024
Steven Sombarf60cbcf2018-12-07 08:12:18 -060025
Chris Austenb29d2e82016-06-07 12:25:35 -050026*** Variables ***
Steven Sombar0acb3412018-01-24 09:38:42 -060027
Steven Sombar0acb3412018-01-24 09:38:42 -060028${SYSTEM_SHUTDOWN_TIME} ${5}
29
Michael Walsha6723f22016-11-22 11:12:01 -060030# Assign default value to QUIET for programs which may not define it.
31${QUIET} ${0}
Steven Sombar0acb3412018-01-24 09:38:42 -060032
Sridevi Ramesh1699d372016-12-06 00:20:22 -060033${HOST_SETTING} ${SETTINGS_URI}host0
Steven Sombar0acb3412018-01-24 09:38:42 -060034
Steven Sombar0acb3412018-01-24 09:38:42 -060035${boot_prog_method} ${EMPTY}
Michael Walshfdc5ced2017-08-17 13:15:15 -050036${power_policy_setup} ${0}
37${bmc_power_policy_method} ${EMPTY}
Michael Walshfdc5ced2017-08-17 13:15:15 -050038
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -050039
Chris Austenb29d2e82016-06-07 12:25:35 -050040*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060041
Steven Sombar0acb3412018-01-24 09:38:42 -060042
George Keishing5e870cd2016-08-24 10:05:47 -050043Verify Ping and REST Authentication
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050044 [Documentation] Verify ping and rest authentication.
Michael Walsha6723f22016-11-22 11:12:01 -060045 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050046 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -050047 Run Keyword If '${l_ping}' == '${False}'
48 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -050049
Michael Walsha6723f22016-11-22 11:12:01 -060050 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -050051 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -050052 Run Keyword If '${l_rest}' == '${False}'
53 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -050054
55 # Just to make sure the SSH is working for SCP
56 Open Connection And Log In
57 ${system} ${stderr}= Execute Command hostname return_stderr=True
58 Should Be Empty ${stderr}
59
Steven Sombar0acb3412018-01-24 09:38:42 -060060
George Keishingc4d3dc02016-09-19 03:45:55 -050061Check If BMC is Up
62 [Documentation] Wait for Host to be online. Checks every X seconds
63 ... interval for Y minutes and fails if timed out.
64 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -060065 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -050066 ... ${interval}=10 sec
67
Steven Sombar0acb3412018-01-24 09:38:42 -060068 # Description of argument(s):
69 # max_timeout Maximum time to wait.
70 # This should be expressed in Robot Framework's time format
71 # (e.g. "10 minutes").
72 # interfal Interval to wait between status checks.
73 # This should be expressed in Robot Framework's time format
74 # (e.g. "5 seconds").
75
George Keishingc4d3dc02016-09-19 03:45:55 -050076 Wait Until Keyword Succeeds
77 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
78
George Keishingb3700812016-08-31 03:03:30 -050079
George Keishing06ae4aa2016-08-30 01:41:28 -050080Flush REST Sessions
81 [Documentation] Removes all the active session objects
82 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -050083
Steven Sombar0acb3412018-01-24 09:38:42 -060084
Rahul Maheshwarie95622c2017-02-24 10:04:29 -060085Trigger Host Watchdog Error
George Keishing37cfa6b2017-06-15 10:25:55 -050086 [Documentation] Inject host watchdog timeout error via REST.
Rahul Maheshwarie95622c2017-02-24 10:04:29 -060087 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Steven Sombar0acb3412018-01-24 09:38:42 -060088
Michael Walshb5839d02017-04-12 16:11:20 -050089 # Description of argument(s):
90 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
91 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -060092 # sleep_time Time delay for host watchdog error to get injected.
93 # Default is 5 seconds.
94
Michael Walsh4ffd1a12018-03-14 10:35:44 -050095 ${data}= Create Dictionary
96 ... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle
97 ${status} ${result}= Run Keyword And Ignore Error
98 ... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction
99 Run Keyword If '${status}' == 'PASS'
100 ... Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data}
George Keishing37cfa6b2017-06-15 10:25:55 -0500101
Sridevi Ramesheadeef02019-01-17 08:56:18 -0600102 ${int_milliseconds}= Convert To Integer ${milliseconds}
103 ${data}= Create Dictionary data=${int_milliseconds}
Michael Walsh4ffd1a12018-03-14 10:35:44 -0500104 Write Attribute ${HOST_WATCHDOG_URI} Interval data=${data}
105
106 ${data}= Create Dictionary data=${True}
107 Write Attribute ${HOST_WATCHDOG_URI} Enabled data=${data}
George Keishing37cfa6b2017-06-15 10:25:55 -0500108
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600109 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500110
Steven Sombar0acb3412018-01-24 09:38:42 -0600111
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500112Login To OS Host
Steven Sombar0acb3412018-01-24 09:38:42 -0600113 [Documentation] Login to OS Host and return the Login response code.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500114 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
115 ... ${os_password}=${OS_PASSWORD}
Steven Sombar0acb3412018-01-24 09:38:42 -0600116
Gunnar Mills28e403b2017-10-25 16:16:38 -0500117 # Description of arguments:
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500118 # ${os_host} IP address of the OS Host.
119 # ${os_username} OS Host Login user name.
120 # ${os_password} OS Host Login passwrd.
121
Rahul Maheshwarid1f45f22018-10-26 05:16:39 -0500122 REST Power On stack_mode=skip quiet=1
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500123
George Keishing3f223b82017-06-28 03:50:35 -0500124 SSHLibrary.Open Connection ${os_host}
George Keishinge0030882019-02-21 03:48:27 -0600125 ${resp}= SSHLibrary.Login ${os_username} ${os_password}
Sridevi Rameshea36b412017-03-09 04:08:02 -0600126 [Return] ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500127
Steven Sombar0acb3412018-01-24 09:38:42 -0600128
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600129Initiate Auto Reboot
130 [Documentation] Initiate an auto reboot.
131 [Arguments] ${milliseconds}=5000
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500132
133 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600134 # milliseconds The number of milliseconds for the watchdog timer.
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500135
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600136 # Set the auto reboot policy.
137 Set Auto Reboot ${1}
138 # Set the watchdog timer.
139 Trigger Host Watchdog Error ${milliseconds}
140
141
142Initiate OS Host Reboot
143 [Documentation] Initiate an OS reboot.
144 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
145 ... ${os_password}=${OS_PASSWORD}
146
147 # Description of argument(s):
148 # os_host The host name or IP address of the OS.
149 # os_username The username to be used to sign in to the OS.
150 # os_password The password to be used to sign in to the OS.
151
152 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
153 ... Set Variable reboot
154 ... ELSE
155 ... Set Variable echo ${os_password} | sudo -S reboot
156
157 ${output} ${stderr} ${rc}= OS Execute Command
158 ... ${cmd_buf} fork=${1}
159
160
161Initiate OS Host Power Off
162 [Documentation] Initiate an OS reboot.
163 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
164 ... ${os_password}=${OS_PASSWORD} ${hard}=${0}
165
166 # Description of argument(s):
167 # os_host The DNS name or IP 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 # hard Indicates whether to do a hard vs. soft power off.
171
172 ${time_string}= Run Keyword If ${hard} Set Variable ${SPACE}now
173 ... ELSE Set Variable ${EMPTY}
174
175 ${cmd_buf}= Run Keyword If '${os_username}' == 'root'
176 ... Set Variable shutdown${time_string}
177 ... ELSE
178 ... Set Variable echo ${os_password} | sudo -S shutdown${time_string}
179
180 ${output} ${stderr} ${rc}= OS Execute Command
181 ... ${cmd_buf} fork=${1}
Sweta Potthurie5a9fc72017-05-03 07:02:46 -0500182
George Keishing3987a1e2017-09-20 09:13:02 -0500183
Steven Sombar5f3af442018-02-14 08:30:15 -0600184Set System LED State
185 [Documentation] Set given system LED via REST.
186 [Arguments] ${led_name} ${led_state}
187 # Description of argument(s):
188 # led_name System LED name (e.g. heartbeat, identify, beep).
189 # led_state LED state to be set (e.g. On, Off).
190
191 ${args}= Create Dictionary
192 ... data=xyz.openbmc_project.Led.Physical.Action.${led_state}
193 Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args}
194
195 Verify LED State ${led_name} ${led_state}
196
197
Steven Sombaraaf72c42017-09-05 12:02:00 -0500198Read Turbo Setting Via REST
199 [Documentation] Return turbo setting via REST.
Steven Sombarea79a492018-04-18 11:14:57 -0500200 # Returns 1 if TurboAllowed, 0 if not.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500201
Steven Sombarea79a492018-04-18 11:14:57 -0500202 ${turbo_setting}= Read Attribute
203 ... ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
204 [Return] ${turbo_setting}
205
Steven Sombaraaf72c42017-09-05 12:02:00 -0500206
Steven Sombaraaf72c42017-09-05 12:02:00 -0500207Set Turbo Setting Via REST
208 [Documentation] Set turbo setting via REST.
Steven Sombar80bc8592018-04-24 11:44:53 -0500209 [Arguments] ${setting} ${verify}=${False}
Steven Sombar0acb3412018-01-24 09:38:42 -0600210
Steven Sombaraaf72c42017-09-05 12:02:00 -0500211 # Description of argument(s):
Steven Sombar80bc8592018-04-24 11:44:53 -0500212 # setting State to set TurboAllowed, 1=allowed, 0=not allowed.
213 # verify If True, read the TurboAllowed setting to confirm.
Steven Sombaraaf72c42017-09-05 12:02:00 -0500214
Steven Sombarea79a492018-04-18 11:14:57 -0500215 ${data}= Create Dictionary data=${${setting}}
Steven Sombar80bc8592018-04-24 11:44:53 -0500216 Write Attribute ${CONTROL_HOST_URI}turbo_allowed TurboAllowed
217 ... verify=${verify} data=${data}
George Keishingef74a8c2017-10-20 10:23:52 -0500218
Steven Sombar0acb3412018-01-24 09:38:42 -0600219
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600220Set REST Logging Policy
221 [Documentation] Enable or disable REST logging setting.
222 [Arguments] ${policy_setting}=${True}
George Keishingef74a8c2017-10-20 10:23:52 -0500223
224 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600225 # policy_setting The policy setting value which can be either
226 # True or False.
George Keishingef74a8c2017-10-20 10:23:52 -0500227
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600228 ${log_dict}= Create Dictionary data=${policy_setting}
George Keishingdf3e65f2018-12-18 13:06:56 -0600229 Write Attribute ${BMC_LOGGING_URI}rest_api_logs Enabled
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600230 ... data=${log_dict} verify=${1} expected_value=${policy_setting}
Sridevi Ramesh0d88ab32017-09-21 11:07:28 -0500231
Steven Sombar0acb3412018-01-24 09:38:42 -0600232
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600233Old Get Boot Progress
234 [Documentation] Get the boot progress the old way (via org location).
235 [Arguments] ${quiet}=${QUIET}
George Keishing034902d2017-11-10 13:15:38 -0600236
237 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600238 # quiet Indicates whether this keyword should run without any output to
239 # the console.
240
241 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
242 ... value quiet=${quiet}
243
244 [Return] ${state}
245
246
247Set Boot Progress Method
248 [Documentation] Set the boot_prog_method to either 'Old' or 'New'.
249
250 # The boot progress data has moved from an 'org' location to an 'xyz'
251 # location. This keyword will determine whether the new method of getting
252 # the boot progress is valid and will set the global boot_prog_method
253 # variable accordingly. If boot_prog_method is already set (either by a
254 # prior call to this function or via a -v parm), this keyword will simply
255 # return.
256
257 # Note: There are interim builds that contain boot_progress in both the
258 # old and the new location values. It is nearly impossible for this
259 # keyword to determine whether the old boot_progress or the new one is
260 # active. When using such builds where the old boot_progress is active,
261 # the only recourse users will have is that they may specify
262 # -v boot_prog_method:Old to force old behavior on such builds.
263
264 Run Keyword If '${boot_prog_method}' != '${EMPTY}' Return From Keyword
265
266 ${new_status} ${new_value}= Run Keyword And Ignore Error
267 ... New Get Boot Progress
268 # If the new style read fails, the method must necessarily be "Old".
269 Run Keyword If '${new_status}' == 'PASS'
270 ... Run Keywords
271 ... Set Global Variable ${boot_prog_method} New AND
272 ... Rqpvars boot_prog_method AND
273 ... Return From Keyword
274
275 # Default method is "Old".
276 Set Global Variable ${boot_prog_method} Old
277 Rqpvars boot_prog_method
278
279
280Initiate Power On
281 [Documentation] Initiates the power on and waits until the Is Power On
282 ... keyword returns that the power state has switched to on.
283 [Arguments] ${wait}=${1}
284
285 # Description of argument(s):
286 # wait Indicates whether to wait for a powered on state after issuing
287 # the power on command.
288
289 @{arglist}= Create List
290 ${args}= Create Dictionary data=@{arglist}
291 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
292 ... data=${args}
293 should be equal as strings ${resp.status_code} ${HTTP_OK}
294
295 # Does caller want to wait for power on status?
296 Run Keyword If '${wait}' == '${0}' Return From Keyword
297 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
298
299
300Initiate Power Off
301 [Documentation] Initiates the power off and waits until the Is Power Off
302 ... keyword returns that the power state has switched to off.
303
304 @{arglist}= Create List
305 ${args}= Create Dictionary data=@{arglist}
306 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
307 ... data=${args}
308 should be equal as strings ${resp.status_code} ${HTTP_OK}
309 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
310
311
312Get Boot Progress
313 [Documentation] Get the boot progress and return it.
314 [Arguments] ${quiet}=${QUIET}
315
316 # Description of argument(s):
317 # quiet Indicates whether this keyword should run without any output to
318 # the console.
319
320 Set Boot Progress Method
321 ${state}= Run Keyword If '${boot_prog_method}' == 'New'
322 ... New Get Boot Progress quiet=${quiet}
323 ... ELSE
324 ... Old Get Boot Progress quiet=${quiet}
325
326 [Return] ${state}
327
328
329New Get Boot Progress
330 [Documentation] Get the boot progress the new way (via xyz location).
331 [Arguments] ${quiet}=${QUIET}
332
333 # Description of argument(s):
334 # quiet Indicates whether this keyword should run without any output to
335 # the console.
336
337 ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet}
338
339 [Return] ${state.rsplit('.', 1)[1]}
340
341
342New Get Power Policy
343 [Documentation] Returns the BMC power policy (new method).
344 ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy
345
346 [Return] ${currentPolicy}
347
348
349Old Get Power Policy
350 [Documentation] Returns the BMC power policy (old method).
351 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
352
353 [Return] ${currentPolicy}
354
355
356Get Auto Reboot
357 [Documentation] Returns auto reboot setting.
358 ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
359
360 [Return] ${setting}
361
362
George Keishingc8a6dd22020-06-12 12:01:33 -0500363Redfish Get Auto Reboot
364 [Documentation] Returns auto reboot setting.
365
366 Redfish.Login
George Keishinga8cb28d2020-06-15 03:10:29 -0500367 ${resp}= Redfish.Get Attribute /redfish/v1/Systems/system Boot
George Keishingc8a6dd22020-06-12 12:01:33 -0500368 Redfish.Logout
George Keishinga8cb28d2020-06-15 03:10:29 -0500369 [Return] ${resp["AutomaticRetryConfig"]}
George Keishingc8a6dd22020-06-12 12:01:33 -0500370
371
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600372Trigger Warm Reset
373 [Documentation] Initiate a warm reset.
374
375 log to console "Triggering warm reset"
376 ${data}= create dictionary data=@{EMPTY}
377 ${resp}= openbmc post request
378 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
379 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
380 ${session_active}= Check If warmReset is Initiated
381 Run Keyword If '${session_active}' == '${True}'
382 ... Fail msg=warm reset didn't occur
383
384 Sleep ${SYSTEM_SHUTDOWN_TIME}min
385 Check If BMC Is Up
386
387
388Get Power State
389 [Documentation] Returns the power state as an integer. Either 0 or 1.
390 [Arguments] ${quiet}=${QUIET}
391
392 # Description of argument(s):
393 # quiet Indicates whether this keyword should run without any output to
394 # the console.
395
396 @{arglist}= Create List
397 ${args}= Create Dictionary data=@{arglist}
398
399 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
400 ... data=${args} quiet=${quiet}
401 Should be equal as strings ${resp.status_code} ${HTTP_OK}
402 ${content}= to json ${resp.content}
403
404 [Return] ${content["data"]}
405
406
407Clear BMC Gard Record
408 [Documentation] Clear gard records from the system.
409
410 @{arglist}= Create List
411 ${args}= Create Dictionary data=@{arglist}
412 ${resp}= Call Method
413 ... ${OPENPOWER_CONTROL}gard Reset data=${args}
414 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
415
416
417Flash PNOR
418 [Documentation] Calls flash bios update method to flash PNOR image
419 [Arguments] ${pnor_image}
420
421 # Description of argument(s):
422 # pnor_image The filename and path of the PNOR image
423 # (e.g. "/home/image/zaius.pnor").
424
425 @{arglist}= Create List ${pnor_image}
426 ${args}= Create Dictionary data=@{arglist}
427 ${resp}= Call Method /org/openbmc/control/flash/bios/ update
428 ... data=${args}
429 should be equal as strings ${resp.status_code} ${HTTP_OK}
430 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
431
432
433Get Flash BIOS Status
434 [Documentation] Returns the status of the flash BIOS API as a string. For
435 ... example 'Flashing', 'Flash Done', etc
436 ${data}= Read Properties /org/openbmc/control/flash/bios
437 [Return] ${data['status']}
438
439
440Is PNOR Flashing
441 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
442 ... flashing has started.
443 ${status}= Get Flash BIOS Status
444 Should Contain ${status} Flashing
445
446
447Is PNOR Flash Done
448 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
449 ... PNOR flashing has completed.
450 ${status}= Get Flash BIOS Status
451 should be equal as strings ${status} Flash Done
452
453
454Create OS Console File Path
455 [Documentation] Create OS console file path name and return it.
456 [Arguments] ${log_file_path}=${EMPTY}
457
458 # Description of arguments:
459 # file_path The caller's candidate value. If this value is ${EMPTY}, this
460 # keyword will compose a file path name. Otherwise, this
461 # keyword will use the caller's file_path value. In either
462 # case, the value will be returned.
463
464 ${status}= Run Keyword And Return Status Variable Should Exist
465 ... ${TEST_NAME}
466
467 ${default_file_path}= Set Variable If ${status} == ${TRUE}
468 ... /tmp/${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt
469 ... /tmp/${OPENBMC_HOST}_os_console.txt
470
471 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
472 ... ${default_file_path} ${log_file_path}
473
474 [Return] ${log_file_path}
475
476
477Get Endpoint Paths
478 [Documentation] Returns all url paths ending with given endpoint
479 ... Example:
480 ... Given the following endpoint: cpu
481 ... This keyword will return: list of all urls ending with
482 ... cpu -
483 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
484 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
485 [Arguments] ${path} ${endpoint}
486
487 # Description of arguments:
488 # path URL path for enumeration.
489 # endpoint Endpoint string (url path ending).
490
Steven Sombaraaaab222018-12-19 13:16:23 -0600491 # Make sure path ends with slash.
492 ${path}= Add Trailing Slash ${path}
493
494 ${resp}= Read Properties ${path}enumerate timeout=30
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600495 Log Dictionary ${resp}
496
497 ${list}= Get Dictionary Keys ${resp}
498 # For a given string, look for prefix and suffix for matching expression.
499 # Start of string followed by zero or more of any character followed by
500 # any digit or lower case character.
501 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[0-9a-z]*$
502
503 [Return] ${resp}
504
505
506Set BMC Power Policy
507 [Documentation] Set the given BMC power policy.
508 [Arguments] ${policy}
509
510 # Note that this function will translate the old style "RESTORE_LAST_STATE"
511 # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy.
512 # Policy.Restore" for you.
513
514 # Description of argument(s):
515 # policy Power restore policy (e.g "RESTORE_LAST_STATE",
516 # ${RESTORE_LAST_STATE}).
517
518 # Set the bmc_power_policy_method to either 'Old' or 'New'.
519 Set Power Policy Method
520 # This translation helps bridge between old and new method for calling.
521 ${policy}= Translate Power Policy Value ${policy}
522 # Run the appropriate keyword.
523 Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy}
524 ${currentPolicy}= Get System Power Policy
525 Should Be Equal ${currentPolicy} ${policy}
526
527
528Delete Error Logs
529 [Documentation] Delete error logs.
530
531 # Check if error logs entries exist, if not return.
Steven Sombara8800da2018-12-18 16:19:05 -0600532 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600533 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
534
535 # Get the list of error logs entries and delete them all.
536 ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY}
537 :FOR ${entry} IN @{elog_entries}
538 \ Delete Error Log Entry ${entry}
539
540
541Delete All Error Logs
542 [Documentation] Delete all error log entries using "DeleteAll" interface.
543
544 ${data}= Create Dictionary data=@{EMPTY}
545 ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
546 ... data=${data}
547 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
548
549
550Get Elog URL List
551 [Documentation] Return error log entry list of URLs.
552
553 ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/
554 Sort List ${url_list}
555 [Return] ${url_list}
556
557
558Get BMC Flash Chip Boot Side
559 [Documentation] Return the BMC flash chip boot side.
George Keishing034902d2017-11-10 13:15:38 -0600560
561 # Example:
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600562 # 0 - indicates chip select is current side.
563 # 32 - indicates chip select is alternate side.
George Keishing034902d2017-11-10 13:15:38 -0600564
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600565 ${boot_side} ${stderr} ${rc}= BMC Execute Command
566 ... cat /sys/class/watchdog/watchdog1/bootstatus
567
568 [Return] ${boot_side}
569
570
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600571Watchdog Object Should Exist
572 [Documentation] Check that watchdog object exists.
573
574 ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0
575 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
576 ... msg=Expected watchdog object does not exist.
Sweta Potthurif39022d2018-02-06 03:40:07 -0600577
578
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600579Get System LED State
580 [Documentation] Return the state of given system LED.
581 [Arguments] ${led_name}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600582
583 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600584 # led_name System LED name (e.g. heartbeat, identify, beep).
Sweta Potthurif39022d2018-02-06 03:40:07 -0600585
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600586 ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
587 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb9f407b2018-02-20 00:07:46 -0600588
589
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600590Verify LED State
591 [Documentation] Checks if LED is in given state.
592 [Arguments] ${led_name} ${led_state}
593 # Description of argument(s):
594 # led_name System LED name (e.g. heartbeat, identify, beep).
595 # led_state LED state to be verified (e.g. On, Off).
George Keishingb9f407b2018-02-20 00:07:46 -0600596
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600597 ${state}= Get System LED State ${led_name}
598 Should Be Equal ${state} ${led_state}
George Keishingb9f407b2018-02-20 00:07:46 -0600599
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600600
601Get LED State XYZ
602 [Documentation] Returns state of given LED.
603 [Arguments] ${led_name}
604
605 # Description of argument(s):
606 # led_name Name of LED.
607
608 ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted
609 # Returns the state of the LED, either On or Off.
610 [Return] ${state}
George Keishingb9f407b2018-02-20 00:07:46 -0600611
George Keishing78ce8dc2018-03-30 11:49:06 -0500612
613Verify Identify LED State
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500614 [Documentation] Verify that the identify state of the LED group matches caller's expectations.
George Keishing78ce8dc2018-03-30 11:49:06 -0500615 [Arguments] ${expected_state}
616
617 # Description of argument(s):
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500618 # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted).
George Keishing78ce8dc2018-03-30 11:49:06 -0500619
Alvin Wang32f7b3d2019-07-25 02:05:39 -0500620 ${led_state}= Get LED State XYZ enclosure_identify
621 Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state.
Sweta Potthuri39255032018-03-28 10:12:14 -0500622
623Verify The Attribute
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500624 [Documentation] Verify the given attribute.
Sweta Potthuri39255032018-03-28 10:12:14 -0500625 [Arguments] ${uri} ${attribute_name} ${attribute_value}
626
627 # Description of argument(s):
628 # uri URI path
629 # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable").
630 # attribute_name Name of attribute to be verified (e.g. "TPMEnable").
631 # attribute_value The expected value of attribute (e.g. "1", "0", etc.)
632
633 ${output}= Read Attribute ${uri} ${attribute_name}
634 Should Be Equal ${attribute_value} ${output}
635 ... msg=Attribute "${attribute_name} does not have the expected value.
George Keishingcf0d7772018-05-04 08:22:50 -0500636
637
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600638New Set Power Policy
639 [Documentation] Set the given BMC power policy (new method).
640 [Arguments] ${policy}
George Keishingb4adfc72018-10-26 09:39:32 -0500641
642 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600643 # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}).
George Keishingc5fef582018-07-18 08:41:28 -0500644
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600645 ${valueDict}= Create Dictionary data=${policy}
646 Write Attribute
647 ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict}
George Keishing216e5842018-08-31 14:58:15 -0500648
649
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600650Old Set Power Policy
651 [Documentation] Set the given BMC power policy (old method).
652 [Arguments] ${policy}
George Keishing3c004dc2018-10-10 07:16:47 -0500653
654 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600655 # policy Power restore policy (e.g. "ALWAYS_POWER_OFF").
656
657 ${valueDict}= create dictionary data=${policy}
658 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
George Keishing3c004dc2018-10-10 07:16:47 -0500659
660
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600661Set Auto Reboot
662 [Documentation] Set the given auto reboot setting.
663 [Arguments] ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500664
665 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600666 # setting The reboot setting, 1 for enabling and 0 for disabling.
George Keishing3c004dc2018-10-10 07:16:47 -0500667
Sridevi Ramesh68d72ff2019-02-04 09:24:46 -0600668 ${valueDict}= Convert To Integer ${setting}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600669 ${data}= Create Dictionary data=${valueDict}
670 Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data}
671 ${current_setting}= Get Auto Reboot
672 Should Be Equal As Integers ${current_setting} ${setting}
George Keishing3c004dc2018-10-10 07:16:47 -0500673
George Keishingc25c55d2018-10-30 02:23:44 -0500674
George Keishingc8a6dd22020-06-12 12:01:33 -0500675Redfish Set Auto Reboot
676 [Documentation] Set the given auto reboot setting.
677 [Arguments] ${setting}
678
679 # Description of argument(s):
680 # setting The reboot setting, "RetryAttempts" and "Disabled".
681
George Keishingc8a6dd22020-06-12 12:01:33 -0500682 Redfish.Login
George Keishinga8cb28d2020-06-15 03:10:29 -0500683 Redfish.Patch /redfish/v1/Systems/system body={"Boot": {"AutomaticRetryConfig": "${setting}"}}
684 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
685 Redfish.Logout
686
George Keishingc8a6dd22020-06-12 12:01:33 -0500687 ${current_setting}= Redfish Get Auto Reboot
688 Should Be Equal As Strings ${current_setting} ${setting}
689
690
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600691Set Control Boot Mode
692 [Documentation] Set given boot mode on the boot object path attribute.
693 [Arguments] ${boot_path} ${boot_mode}
George Keishingc25c55d2018-10-30 02:23:44 -0500694
695 # Description of argument(s):
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600696 # boot_path Boot object path.
697 # Example:
698 # /xyz/openbmc_project/control/host0/boot
699 # /xyz/openbmc_project/control/host0/boot/one_time
700 # boot_mode Boot mode which need to be set.
701 # Example:
702 # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
George Keishingc25c55d2018-10-30 02:23:44 -0500703
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600704 ${valueDict}= Create Dictionary data=${boot_mode}
705 Write Attribute ${boot_path} BootMode data=${valueDict}
George Keishingc25c55d2018-10-30 02:23:44 -0500706
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600707
708Is Power On
709 [Documentation] Verify that the BMC chassis state is on.
710 ${state}= Get Power State
711 Should be equal ${state} ${1}
712
713
714Is Power Off
715 [Documentation] Verify that the BMC chassis state is off.
716 ${state}= Get Power State
717 Should be equal ${state} ${0}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500718
719
720CLI Get BMC DateTime
721 [Documentation] Returns BMC date time from date command.
722
723 ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1
724 [Return] ${bmc_time_via_date}
George Keishing61364e52019-10-01 12:01:19 -0500725
726
727Update Root Password
728 [Documentation] Update system "root" user password.
729 [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD}
730
731 # Description of argument(s):
732 # openbmc_password The root password for the open BMC system.
733
734 @{password}= Create List ${openbmc_password}
735 ${data}= Create Dictionary data=@{password}
736
737 ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
738 ${resp}= Post Request openbmc ${BMC_USER_URI}root/action/SetPassword
739 ... data=${data} headers=${headers}
740 Valid Value resp.status_code [${HTTP_OK}]
Sushil Singh6624ce52020-01-22 00:53:41 -0600741
742
743Get Post Boot Action
744 [Documentation] Get post boot action.
745
George Keishing879f0842020-02-05 11:00:47 -0600746 # Post code update action dictionary.
Sushil Singh6624ce52020-01-22 00:53:41 -0600747 #
748 # {
749 # BMC image: {
750 # OnReset: Redfish OBMC Reboot (off),
751 # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
752 # },
753 # Host image: {
George Keishinge523fc02020-03-23 12:28:01 -0500754 # OnReset: RF SYS GracefulRestart,
Sushil Singh6624ce52020-01-22 00:53:41 -0600755 # Immediate: Wait State os_running_match_state 10 mins
756 # }
757 # }
758
759 ${code_base_dir_path}= Get Code Base Dir Path
760 ${post_code_update_actions}= Evaluate
761 ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json
762 Rprint Vars post_code_update_actions
763
764 [Return] ${post_code_update_actions}
765