Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 2 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 3 | Documentation Utilities for Robot keywords that use REST. |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 4 | |
Sandhya Somashekar | 839a0c2 | 2019-01-31 05:05:43 -0600 | [diff] [blame] | 5 | Resource ../lib/resource.robot |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 6 | Resource ../lib/rest_client.robot |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 7 | Resource ../lib/connection_client.robot |
Rahul Maheshwari | d1f45f2 | 2018-10-26 05:16:39 -0500 | [diff] [blame] | 8 | Resource ../lib/boot_utils.robot |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 9 | Resource ../lib/common_utils.robot |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 10 | Resource ../lib/bmc_redfish_utils.robot |
Michael Walsh | 391ba9b | 2017-08-24 11:36:24 -0500 | [diff] [blame] | 11 | Library String |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 12 | Library DateTime |
| 13 | Library Process |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 14 | Library OperatingSystem |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 15 | Library gen_print.py |
Steven Sombar | aaaab22 | 2018-12-19 13:16:23 -0600 | [diff] [blame] | 16 | Library gen_misc.py |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 17 | Library gen_robot_print.py |
Michael Walsh | 5f3f414 | 2017-05-22 17:09:47 -0500 | [diff] [blame] | 18 | Library gen_cmd.py |
Sunil M | acd110a | 2017-05-23 04:14:32 -0500 | [diff] [blame] | 19 | Library gen_robot_keyword.py |
Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 20 | Library bmc_ssh_utils.py |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 21 | Library utils.py |
Charles Paul Hofer | 3581615 | 2017-10-02 11:55:11 -0500 | [diff] [blame] | 22 | Library var_funcs.py |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 23 | Library SCPLibrary WITH NAME scp |
George Keishing | 61364e5 | 2019-10-01 12:01:19 -0500 | [diff] [blame] | 24 | Library gen_robot_valid.py |
George Keishing | 83c737b | 2022-05-17 12:12:04 -0500 | [diff] [blame] | 25 | Library pldm_utils.py |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 26 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 27 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 28 | *** Variables *** |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 29 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 30 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
| 31 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 32 | # Assign default value to QUIET for programs which may not define it. |
| 33 | ${QUIET} ${0} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 34 | |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 35 | ${HOST_SETTING} ${SETTINGS_URI}host0 |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 36 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 37 | ${boot_prog_method} ${EMPTY} |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 38 | ${power_policy_setup} ${0} |
| 39 | ${bmc_power_policy_method} ${EMPTY} |
Sridevi Ramesh | 13d84bf | 2022-10-31 09:14:52 -0500 | [diff] [blame] | 40 | @{BOOT_PROGRESS_STATES} SystemHardwareInitializationComplete OSBootStarted OSRunning |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 41 | |
Sushil Singh | fd0f91b | 2023-11-10 07:35:11 -0600 | [diff] [blame] | 42 | ${REDFISH_SYS_STATE_WAIT_TIMEOUT} 120 Seconds |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 43 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 44 | *** Keywords *** |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 45 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 46 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 47 | Verify Ping and REST Authentication |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 48 | [Documentation] Verify ping and rest authentication. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 49 | ${l_ping}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 50 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 51 | Run Keyword If '${l_ping}' == '${False}' |
| 52 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 53 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 54 | ${l_rest}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 55 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 56 | Run Keyword If '${l_rest}' == '${False}' |
| 57 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 58 | |
| 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 Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 64 | |
George Keishing | 90b555a | 2021-05-20 11:54:16 -0500 | [diff] [blame] | 65 | Verify 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 Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 80 | Check 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 Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 84 | [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 85 | ... ${interval}=10 sec |
| 86 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 87 | # 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 Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 91 | # interval Interval to wait between status checks. |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 92 | # This should be expressed in Robot Framework's time format |
| 93 | # (e.g. "5 seconds"). |
| 94 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 95 | Wait Until Keyword Succeeds |
| 96 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 97 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 98 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 99 | Flush REST Sessions |
| 100 | [Documentation] Removes all the active session objects |
| 101 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 102 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 103 | |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 104 | Trigger Host Watchdog Error |
George Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 105 | [Documentation] Inject host watchdog timeout error via REST. |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 106 | [Arguments] ${milliseconds}=1000 ${sleep_time}=5s |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 107 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 108 | # Description of argument(s): |
| 109 | # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 = |
| 110 | # 1 second). |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 111 | # sleep_time Time delay for host watchdog error to get injected. |
| 112 | # Default is 5 seconds. |
| 113 | |
Michael Walsh | 4ffd1a1 | 2018-03-14 10:35:44 -0500 | [diff] [blame] | 114 | ${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 Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 120 | |
Sridevi Ramesh | eadeef0 | 2019-01-17 08:56:18 -0600 | [diff] [blame] | 121 | ${int_milliseconds}= Convert To Integer ${milliseconds} |
| 122 | ${data}= Create Dictionary data=${int_milliseconds} |
Michael Walsh | 4ffd1a1 | 2018-03-14 10:35:44 -0500 | [diff] [blame] | 123 | 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 Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 127 | |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 128 | Sleep ${sleep_time} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 129 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 130 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 131 | Login To OS Host |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 132 | [Documentation] Login to OS Host and return the Login response code. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 133 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 134 | ... ${os_password}=${OS_PASSWORD} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 135 | |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 136 | # Description of arguments: |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 137 | # ${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 Keishing | 1856d33 | 2021-11-15 08:38:53 -0600 | [diff] [blame] | 141 | Redfish Power On stack_mode=skip quiet=1 |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 142 | |
George Keishing | 3f223b8 | 2017-06-28 03:50:35 -0500 | [diff] [blame] | 143 | SSHLibrary.Open Connection ${os_host} |
George Keishing | e003088 | 2019-02-21 03:48:27 -0600 | [diff] [blame] | 144 | ${resp}= SSHLibrary.Login ${os_username} ${os_password} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 145 | RETURN ${resp} |
Prashanth Katti | 884ee06 | 2017-03-16 05:05:03 -0500 | [diff] [blame] | 146 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 147 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 148 | Initiate Auto Reboot |
| 149 | [Documentation] Initiate an auto reboot. |
| 150 | [Arguments] ${milliseconds}=5000 |
Sweta Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 151 | |
| 152 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 153 | # milliseconds The number of milliseconds for the watchdog timer. |
Sweta Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 154 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 155 | # Set the auto reboot policy. |
| 156 | Set Auto Reboot ${1} |
| 157 | # Set the watchdog timer. |
| 158 | Trigger Host Watchdog Error ${milliseconds} |
| 159 | |
| 160 | |
| 161 | Initiate 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 | |
| 180 | Initiate 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 Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 201 | |
George Keishing | 3987a1e | 2017-09-20 09:13:02 -0500 | [diff] [blame] | 202 | |
Steven Sombar | 5f3af44 | 2018-02-14 08:30:15 -0600 | [diff] [blame] | 203 | Set 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 Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 217 | Read Turbo Setting Via REST |
| 218 | [Documentation] Return turbo setting via REST. |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 219 | # Returns 1 if TurboAllowed, 0 if not. |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 220 | |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 221 | ${turbo_setting}= Read Attribute |
| 222 | ... ${CONTROL_HOST_URI}turbo_allowed TurboAllowed |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 223 | RETURN ${turbo_setting} |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 224 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 225 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 226 | Set Turbo Setting Via REST |
| 227 | [Documentation] Set turbo setting via REST. |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 228 | [Arguments] ${setting} ${verify}=${False} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 229 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 230 | # Description of argument(s): |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 231 | # setting State to set TurboAllowed, 1=allowed, 0=not allowed. |
| 232 | # verify If True, read the TurboAllowed setting to confirm. |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 233 | |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 234 | ${data}= Create Dictionary data=${${setting}} |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 235 | Write Attribute ${CONTROL_HOST_URI}turbo_allowed TurboAllowed |
| 236 | ... verify=${verify} data=${data} |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 237 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 238 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 239 | Set REST Logging Policy |
| 240 | [Documentation] Enable or disable REST logging setting. |
| 241 | [Arguments] ${policy_setting}=${True} |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 242 | |
| 243 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 244 | # policy_setting The policy setting value which can be either |
| 245 | # True or False. |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 246 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 247 | ${log_dict}= Create Dictionary data=${policy_setting} |
George Keishing | df3e65f | 2018-12-18 13:06:56 -0600 | [diff] [blame] | 248 | Write Attribute ${BMC_LOGGING_URI}rest_api_logs Enabled |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 249 | ... data=${log_dict} verify=${1} expected_value=${policy_setting} |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 250 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 251 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 252 | Old Get Boot Progress |
| 253 | [Documentation] Get the boot progress the old way (via org location). |
| 254 | [Arguments] ${quiet}=${QUIET} |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 255 | |
| 256 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 257 | # 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 Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 263 | RETURN ${state} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 264 | |
| 265 | |
| 266 | Set 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 | |
| 299 | Initiate 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 | |
| 319 | Initiate 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 | |
| 331 | Get 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 Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 345 | RETURN ${state} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 346 | |
| 347 | |
| 348 | New 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 Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 358 | RETURN ${state.rsplit('.', 1)[1]} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 359 | |
| 360 | |
| 361 | New Get Power Policy |
| 362 | [Documentation] Returns the BMC power policy (new method). |
| 363 | ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy |
| 364 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 365 | RETURN ${currentPolicy} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 366 | |
| 367 | |
| 368 | Old Get Power Policy |
| 369 | [Documentation] Returns the BMC power policy (old method). |
| 370 | ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy |
| 371 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 372 | RETURN ${currentPolicy} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 373 | |
| 374 | |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 375 | Redfish Get Power Restore Policy |
| 376 | [Documentation] Returns the BMC power restore policy. |
| 377 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 378 | ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} PowerRestorePolicy |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 379 | RETURN ${power_restore_policy} |
| 380 | |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 381 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 382 | Get Auto Reboot |
| 383 | [Documentation] Returns auto reboot setting. |
| 384 | ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot |
| 385 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 386 | RETURN ${setting} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 387 | |
| 388 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 389 | Redfish Get Auto Reboot |
| 390 | [Documentation] Returns auto reboot setting. |
| 391 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 392 | ${resp}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 393 | RETURN ${resp["AutomaticRetryConfig"]} |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 394 | |
| 395 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 396 | Trigger Warm Reset |
| 397 | [Documentation] Initiate a warm reset. |
| 398 | |
| 399 | log to console "Triggering warm reset" |
| 400 | ${data}= create dictionary data=@{EMPTY} |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 401 | ${resp}= Openbmc Post Request |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 402 | ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data} |
| 403 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 404 | ${session_active}= Check If warmReset is Initiated |
| 405 | Run Keyword If '${session_active}' == '${True}' |
| 406 | ... Fail msg=warm reset didn't occur |
| 407 | |
| 408 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 409 | Check If BMC Is Up |
| 410 | |
| 411 | |
| 412 | Get Power State |
| 413 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
| 414 | [Arguments] ${quiet}=${QUIET} |
| 415 | |
| 416 | # Description of argument(s): |
| 417 | # quiet Indicates whether this keyword should run without any output to |
| 418 | # the console. |
| 419 | |
| 420 | @{arglist}= Create List |
| 421 | ${args}= Create Dictionary data=@{arglist} |
| 422 | |
| 423 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState |
| 424 | ... data=${args} quiet=${quiet} |
| 425 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 426 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 427 | RETURN ${resp.json()["data"]} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 428 | |
| 429 | |
| 430 | Clear BMC Gard Record |
| 431 | [Documentation] Clear gard records from the system. |
| 432 | |
| 433 | @{arglist}= Create List |
| 434 | ${args}= Create Dictionary data=@{arglist} |
| 435 | ${resp}= Call Method |
| 436 | ... ${OPENPOWER_CONTROL}gard Reset data=${args} |
| 437 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 438 | |
| 439 | |
| 440 | Flash PNOR |
| 441 | [Documentation] Calls flash bios update method to flash PNOR image |
| 442 | [Arguments] ${pnor_image} |
| 443 | |
| 444 | # Description of argument(s): |
| 445 | # pnor_image The filename and path of the PNOR image |
| 446 | # (e.g. "/home/image/zaius.pnor"). |
| 447 | |
| 448 | @{arglist}= Create List ${pnor_image} |
| 449 | ${args}= Create Dictionary data=@{arglist} |
| 450 | ${resp}= Call Method /org/openbmc/control/flash/bios/ update |
| 451 | ... data=${args} |
| 452 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 453 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 454 | |
| 455 | |
| 456 | Get Flash BIOS Status |
| 457 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 458 | ... example 'Flashing', 'Flash Done', etc |
| 459 | ${data}= Read Properties /org/openbmc/control/flash/bios |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 460 | RETURN ${data['status']} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 461 | |
| 462 | |
| 463 | Is PNOR Flashing |
| 464 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 465 | ... flashing has started. |
| 466 | ${status}= Get Flash BIOS Status |
| 467 | Should Contain ${status} Flashing |
| 468 | |
| 469 | |
| 470 | Is PNOR Flash Done |
| 471 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 472 | ... PNOR flashing has completed. |
| 473 | ${status}= Get Flash BIOS Status |
| 474 | should be equal as strings ${status} Flash Done |
| 475 | |
| 476 | |
| 477 | Create OS Console File Path |
| 478 | [Documentation] Create OS console file path name and return it. |
| 479 | [Arguments] ${log_file_path}=${EMPTY} |
| 480 | |
| 481 | # Description of arguments: |
| 482 | # file_path The caller's candidate value. If this value is ${EMPTY}, this |
| 483 | # keyword will compose a file path name. Otherwise, this |
| 484 | # keyword will use the caller's file_path value. In either |
| 485 | # case, the value will be returned. |
| 486 | |
| 487 | ${status}= Run Keyword And Return Status Variable Should Exist |
| 488 | ... ${TEST_NAME} |
| 489 | |
| 490 | ${default_file_path}= Set Variable If ${status} == ${TRUE} |
George Keishing | 9161b10 | 2021-12-10 02:26:30 -0600 | [diff] [blame] | 491 | ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt |
| 492 | ... ${EXECDIR}${/}tmp${/}${OPENBMC_HOST}_os_console.txt |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 493 | |
| 494 | ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}' |
| 495 | ... ${default_file_path} ${log_file_path} |
| 496 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 497 | RETURN ${log_file_path} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 498 | |
| 499 | |
| 500 | Get Endpoint Paths |
| 501 | [Documentation] Returns all url paths ending with given endpoint |
| 502 | ... Example: |
| 503 | ... Given the following endpoint: cpu |
| 504 | ... This keyword will return: list of all urls ending with |
| 505 | ... cpu - |
| 506 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu0, |
| 507 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu1 |
| 508 | [Arguments] ${path} ${endpoint} |
| 509 | |
| 510 | # Description of arguments: |
| 511 | # path URL path for enumeration. |
| 512 | # endpoint Endpoint string (url path ending). |
| 513 | |
Steven Sombar | aaaab22 | 2018-12-19 13:16:23 -0600 | [diff] [blame] | 514 | # Make sure path ends with slash. |
| 515 | ${path}= Add Trailing Slash ${path} |
| 516 | |
| 517 | ${resp}= Read Properties ${path}enumerate timeout=30 |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 518 | Log Dictionary ${resp} |
| 519 | |
| 520 | ${list}= Get Dictionary Keys ${resp} |
| 521 | # For a given string, look for prefix and suffix for matching expression. |
| 522 | # Start of string followed by zero or more of any character followed by |
| 523 | # any digit or lower case character. |
George Keishing | 585afa3 | 2020-07-09 04:55:15 -0500 | [diff] [blame] | 524 | ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}\[_0-9a-z]*$ case_insensitive=${True} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 525 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 526 | RETURN ${resp} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 527 | |
| 528 | |
| 529 | Set BMC Power Policy |
| 530 | [Documentation] Set the given BMC power policy. |
| 531 | [Arguments] ${policy} |
| 532 | |
| 533 | # Note that this function will translate the old style "RESTORE_LAST_STATE" |
| 534 | # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy. |
| 535 | # Policy.Restore" for you. |
| 536 | |
| 537 | # Description of argument(s): |
| 538 | # policy Power restore policy (e.g "RESTORE_LAST_STATE", |
| 539 | # ${RESTORE_LAST_STATE}). |
| 540 | |
| 541 | # Set the bmc_power_policy_method to either 'Old' or 'New'. |
| 542 | Set Power Policy Method |
| 543 | # This translation helps bridge between old and new method for calling. |
| 544 | ${policy}= Translate Power Policy Value ${policy} |
| 545 | # Run the appropriate keyword. |
| 546 | Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy} |
| 547 | ${currentPolicy}= Get System Power Policy |
| 548 | Should Be Equal ${currentPolicy} ${policy} |
| 549 | |
| 550 | |
| 551 | Delete Error Logs |
| 552 | [Documentation] Delete error logs. |
Michael Shepos | cc490b4 | 2020-08-26 12:53:01 -0500 | [diff] [blame] | 553 | [Arguments] ${quiet}=${0} |
| 554 | # Description of argument(s): |
| 555 | # quiet If enabled, turns off logging to console. |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 556 | |
| 557 | # Check if error logs entries exist, if not return. |
Steven Sombar | a8800da | 2018-12-18 16:19:05 -0600 | [diff] [blame] | 558 | ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 559 | Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} |
| 560 | |
| 561 | # Get the list of error logs entries and delete them all. |
| 562 | ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY} |
David Shaw | 79247e4 | 2020-06-18 17:16:02 -0500 | [diff] [blame] | 563 | FOR ${entry} IN @{elog_entries} |
Michael Shepos | cc490b4 | 2020-08-26 12:53:01 -0500 | [diff] [blame] | 564 | Delete Error Log Entry ${entry} quiet=${quiet} |
David Shaw | 79247e4 | 2020-06-18 17:16:02 -0500 | [diff] [blame] | 565 | END |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 566 | |
| 567 | |
| 568 | Delete All Error Logs |
| 569 | [Documentation] Delete all error log entries using "DeleteAll" interface. |
| 570 | |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 571 | ${args}= Set Variable {"data": []} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 572 | ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 573 | ... data=${args} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 574 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 575 | |
| 576 | |
| 577 | Get Elog URL List |
| 578 | [Documentation] Return error log entry list of URLs. |
| 579 | |
| 580 | ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/ |
| 581 | Sort List ${url_list} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 582 | RETURN ${url_list} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 583 | |
| 584 | |
| 585 | Get BMC Flash Chip Boot Side |
| 586 | [Documentation] Return the BMC flash chip boot side. |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 587 | |
| 588 | # Example: |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 589 | # 0 - indicates chip select is current side. |
| 590 | # 32 - indicates chip select is alternate side. |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 591 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 592 | ${boot_side} ${stderr} ${rc}= BMC Execute Command |
| 593 | ... cat /sys/class/watchdog/watchdog1/bootstatus |
| 594 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 595 | RETURN ${boot_side} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 596 | |
| 597 | |
Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 598 | Watchdog Object Should Exist |
| 599 | [Documentation] Check that watchdog object exists. |
| 600 | |
| 601 | ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0 |
| 602 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 603 | ... msg=Expected watchdog object does not exist. |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 604 | |
| 605 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 606 | Get System LED State |
| 607 | [Documentation] Return the state of given system LED. |
| 608 | [Arguments] ${led_name} |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 609 | |
| 610 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 611 | # led_name System LED name (e.g. heartbeat, identify, beep). |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 612 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 613 | ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 614 | RETURN ${state.rsplit('.', 1)[1]} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 615 | |
| 616 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 617 | Verify LED State |
| 618 | [Documentation] Checks if LED is in given state. |
| 619 | [Arguments] ${led_name} ${led_state} |
| 620 | # Description of argument(s): |
| 621 | # led_name System LED name (e.g. heartbeat, identify, beep). |
| 622 | # led_state LED state to be verified (e.g. On, Off). |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 623 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 624 | ${state}= Get System LED State ${led_name} |
| 625 | Should Be Equal ${state} ${led_state} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 626 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 627 | |
| 628 | Get LED State XYZ |
| 629 | [Documentation] Returns state of given LED. |
| 630 | [Arguments] ${led_name} |
| 631 | |
| 632 | # Description of argument(s): |
| 633 | # led_name Name of LED. |
| 634 | |
| 635 | ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted |
| 636 | # Returns the state of the LED, either On or Off. |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 637 | RETURN ${state} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 638 | |
George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 639 | |
| 640 | Verify Identify LED State |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 641 | [Documentation] Verify that the identify state of the LED group matches caller's expectations. |
George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 642 | [Arguments] ${expected_state} |
| 643 | |
| 644 | # Description of argument(s): |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 645 | # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted). |
George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 646 | |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 647 | ${led_state}= Get LED State XYZ enclosure_identify |
| 648 | Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state. |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 649 | |
| 650 | Verify The Attribute |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 651 | [Documentation] Verify the given attribute. |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 652 | [Arguments] ${uri} ${attribute_name} ${attribute_value} |
| 653 | |
| 654 | # Description of argument(s): |
| 655 | # uri URI path |
| 656 | # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable"). |
| 657 | # attribute_name Name of attribute to be verified (e.g. "TPMEnable"). |
| 658 | # attribute_value The expected value of attribute (e.g. "1", "0", etc.) |
| 659 | |
| 660 | ${output}= Read Attribute ${uri} ${attribute_name} |
| 661 | Should Be Equal ${attribute_value} ${output} |
| 662 | ... msg=Attribute "${attribute_name} does not have the expected value. |
George Keishing | cf0d777 | 2018-05-04 08:22:50 -0500 | [diff] [blame] | 663 | |
| 664 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 665 | New Set Power Policy |
| 666 | [Documentation] Set the given BMC power policy (new method). |
| 667 | [Arguments] ${policy} |
George Keishing | b4adfc7 | 2018-10-26 09:39:32 -0500 | [diff] [blame] | 668 | |
| 669 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 670 | # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}). |
George Keishing | c5fef58 | 2018-07-18 08:41:28 -0500 | [diff] [blame] | 671 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 672 | ${valueDict}= Create Dictionary data=${policy} |
| 673 | Write Attribute |
| 674 | ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict} |
George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 675 | |
| 676 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 677 | Old Set Power Policy |
| 678 | [Documentation] Set the given BMC power policy (old method). |
| 679 | [Arguments] ${policy} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 680 | |
| 681 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 682 | # policy Power restore policy (e.g. "ALWAYS_POWER_OFF"). |
| 683 | |
| 684 | ${valueDict}= create dictionary data=${policy} |
| 685 | Write Attribute ${HOST_SETTING} power_policy data=${valueDict} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 686 | |
| 687 | |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 688 | Redfish Set Power Restore Policy |
| 689 | [Documentation] Set the BMC power restore policy. |
| 690 | [Arguments] ${power_restore_policy} |
| 691 | |
| 692 | # Description of argument(s): |
| 693 | # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState"). |
| 694 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 695 | Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"PowerRestorePolicy": "${power_restore_policy}"} |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 696 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 697 | |
| 698 | |
George Keishing | 9a28860 | 2021-12-10 04:50:25 -0600 | [diff] [blame] | 699 | IPMI Set Power Restore Policy |
| 700 | [Documentation] Set the BMC power restore policy using IPMI. |
| 701 | [Arguments] ${power_restore_policy}=always-off |
| 702 | |
| 703 | # Description of argument(s): |
| 704 | # power_restore_policy Power restore policies |
| 705 | # always-on : turn on when power is restored |
| 706 | # previous : return to previous state when power is restored |
| 707 | # always-off : stay off after power is restored |
| 708 | |
| 709 | ${resp}= Run IPMI Standard Command chassis policy ${power_restore_policy} |
| 710 | # Example: Set chassis power restore policy to always-off |
| 711 | Should Contain ${resp} ${power_restore_policy} |
| 712 | |
| 713 | |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 714 | Set Auto Reboot Setting |
| 715 | [Documentation] Set the given auto reboot setting (REST or Redfish). |
| 716 | [Arguments] ${value} |
| 717 | |
| 718 | # Description of argument(s): |
| 719 | # value The reboot setting, 1 for enabling and 0 for disabling. |
| 720 | |
| 721 | # This is to cater to boot call points and plugin script which will always |
| 722 | # send using value 0 or 1. This dictionary maps to redfish string values. |
| 723 | ${rest_redfish_dict}= Create Dictionary |
| 724 | ... 1=RetryAttempts |
| 725 | ... 0=Disabled |
| 726 | |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 727 | Run Keyword If ${REDFISH_SUPPORT_TRANS_STATE} == ${1} |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 728 | ... Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 729 | ... ELSE |
| 730 | ... Set Auto Reboot ${value} |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 731 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 732 | Set Auto Reboot |
| 733 | [Documentation] Set the given auto reboot setting. |
| 734 | [Arguments] ${setting} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 735 | |
| 736 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 737 | # setting The reboot setting, 1 for enabling and 0 for disabling. |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 738 | |
Sridevi Ramesh | 68d72ff | 2019-02-04 09:24:46 -0600 | [diff] [blame] | 739 | ${valueDict}= Convert To Integer ${setting} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 740 | ${data}= Create Dictionary data=${valueDict} |
| 741 | Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data} |
| 742 | ${current_setting}= Get Auto Reboot |
| 743 | Should Be Equal As Integers ${current_setting} ${setting} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 744 | |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 745 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 746 | Redfish Set Auto Reboot |
| 747 | [Documentation] Set the given auto reboot setting. |
| 748 | [Arguments] ${setting} |
| 749 | |
| 750 | # Description of argument(s): |
| 751 | # setting The reboot setting, "RetryAttempts" and "Disabled". |
| 752 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 753 | Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body={"Boot": {"AutomaticRetryConfig": "${setting}"}} |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 754 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 755 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 756 | ${current_setting}= Redfish Get Auto Reboot |
| 757 | Should Be Equal As Strings ${current_setting} ${setting} |
| 758 | |
| 759 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 760 | Set Control Boot Mode |
| 761 | [Documentation] Set given boot mode on the boot object path attribute. |
| 762 | [Arguments] ${boot_path} ${boot_mode} |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 763 | |
| 764 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 765 | # boot_path Boot object path. |
| 766 | # Example: |
| 767 | # /xyz/openbmc_project/control/host0/boot |
| 768 | # /xyz/openbmc_project/control/host0/boot/one_time |
| 769 | # boot_mode Boot mode which need to be set. |
| 770 | # Example: |
| 771 | # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular" |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 772 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 773 | ${valueDict}= Create Dictionary data=${boot_mode} |
| 774 | Write Attribute ${boot_path} BootMode data=${valueDict} |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 775 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 776 | |
| 777 | Is Power On |
| 778 | [Documentation] Verify that the BMC chassis state is on. |
| 779 | ${state}= Get Power State |
| 780 | Should be equal ${state} ${1} |
| 781 | |
| 782 | |
| 783 | Is Power Off |
| 784 | [Documentation] Verify that the BMC chassis state is off. |
| 785 | ${state}= Get Power State |
| 786 | Should be equal ${state} ${0} |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 787 | |
| 788 | |
| 789 | CLI Get BMC DateTime |
| 790 | [Documentation] Returns BMC date time from date command. |
| 791 | |
| 792 | ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1 |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 793 | RETURN ${bmc_time_via_date} |
George Keishing | 61364e5 | 2019-10-01 12:01:19 -0500 | [diff] [blame] | 794 | |
| 795 | |
| 796 | Update Root Password |
| 797 | [Documentation] Update system "root" user password. |
| 798 | [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD} |
| 799 | |
| 800 | # Description of argument(s): |
| 801 | # openbmc_password The root password for the open BMC system. |
| 802 | |
| 803 | @{password}= Create List ${openbmc_password} |
| 804 | ${data}= Create Dictionary data=@{password} |
| 805 | |
| 806 | ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN} |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 807 | ${resp}= POST On Session openbmc ${BMC_USER_URI}root/action/SetPassword |
George Keishing | 61364e5 | 2019-10-01 12:01:19 -0500 | [diff] [blame] | 808 | ... data=${data} headers=${headers} |
| 809 | Valid Value resp.status_code [${HTTP_OK}] |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 810 | |
| 811 | |
| 812 | Get Post Boot Action |
| 813 | [Documentation] Get post boot action. |
| 814 | |
George Keishing | 879f084 | 2020-02-05 11:00:47 -0600 | [diff] [blame] | 815 | # Post code update action dictionary. |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 816 | # |
| 817 | # { |
| 818 | # BMC image: { |
| 819 | # OnReset: Redfish OBMC Reboot (off), |
| 820 | # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']} |
| 821 | # }, |
| 822 | # Host image: { |
George Keishing | e523fc0 | 2020-03-23 12:28:01 -0500 | [diff] [blame] | 823 | # OnReset: RF SYS GracefulRestart, |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 824 | # Immediate: Wait State os_running_match_state 10 mins |
| 825 | # } |
| 826 | # } |
| 827 | |
| 828 | ${code_base_dir_path}= Get Code Base Dir Path |
| 829 | ${post_code_update_actions}= Evaluate |
| 830 | ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json |
| 831 | Rprint Vars post_code_update_actions |
| 832 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 833 | RETURN ${post_code_update_actions} |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 834 | |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 835 | |
Sushil Singh | 1560e65 | 2022-08-03 13:25:01 -0500 | [diff] [blame] | 836 | Get Task State From File |
| 837 | [Documentation] Get task states from pre-define data/task_state.json file. |
| 838 | |
| 839 | # Example: Task state JSON format. |
| 840 | # |
| 841 | # { |
| 842 | # "TaskRunning": { |
| 843 | # "TaskState": "Running", |
| 844 | # "TaskStatus": "OK" |
| 845 | # }, |
| 846 | # "TaskCompleted": { |
| 847 | # "TaskState": "Completed", |
| 848 | # "TaskStatus": "OK" |
| 849 | # }, |
| 850 | # "TaskException": { |
| 851 | # "TaskState": "Exception", |
| 852 | # "TaskStatus": "Warning" |
| 853 | # } |
| 854 | # } |
| 855 | |
| 856 | # Python module: get_code_base_dir_path() |
| 857 | ${code_base_dir_path}= Get Code Base Dir Path |
| 858 | ${task_state}= Evaluate |
| 859 | ... json.load(open('${code_base_dir_path}data/task_state.json')) modules=json |
| 860 | Rprint Vars task_state |
| 861 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 862 | RETURN ${task_state} |
Sushil Singh | 1560e65 | 2022-08-03 13:25:01 -0500 | [diff] [blame] | 863 | |
| 864 | |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 865 | Redfish Set Boot Default |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 866 | [Documentation] Set and Verify Boot source override |
| 867 | [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 868 | |
| 869 | # Description of argument(s): |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 870 | # override_enabled Boot source override enable type. |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 871 | # ('Once', 'Continuous', 'Disabled'). |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 872 | # override_target Boot source override target. |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 873 | # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None'). |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 874 | # override_mode Boot source override mode (relevant only for x86 arch). |
| 875 | # ('Legacy', 'UEFI'). |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 876 | |
| 877 | ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled} |
| 878 | ... BootSourceOverrideTarget=${override_target} |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 879 | |
| 880 | Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86' |
| 881 | ... Set To Dictionary ${data} BootSourceOverrideMode ${override_mode} |
| 882 | |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 883 | ${payload}= Create Dictionary Boot=${data} |
| 884 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 885 | Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID} body=&{payload} |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 886 | ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}] |
| 887 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 888 | ${resp}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID} Boot |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 889 | Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled} |
| 890 | Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target} |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 891 | Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86' |
| 892 | ... Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 893 | |
| 894 | |
| 895 | # Redfish state keywords. |
| 896 | |
| 897 | Redfish Get BMC State |
| 898 | [Documentation] Return BMC health state. |
| 899 | |
| 900 | # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady |
| 901 | |
| 902 | # Example: |
| 903 | # "Status": { |
| 904 | # "Health": "OK", |
| 905 | # "HealthRollup": "OK", |
| 906 | # "State": "Enabled" |
| 907 | # }, |
| 908 | |
ganesanb | 4d43028 | 2023-04-27 14:33:23 +0000 | [diff] [blame] | 909 | ${status}= Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 910 | RETURN ${status["State"]} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 911 | |
| 912 | |
Sushil Singh | 472177b | 2023-08-28 05:28:30 -0500 | [diff] [blame] | 913 | Redfish Verify BMC State |
| 914 | [Documentation] Verify BMC state is enabled. |
| 915 | [Arguments] ${match_state}=Enabled |
| 916 | |
| 917 | # Description of argument(s): |
| 918 | # match_state Expected match state (e.g. Enabled, Starting, Error) |
| 919 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 920 | ${Status}= Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Status |
Sushil Singh | 472177b | 2023-08-28 05:28:30 -0500 | [diff] [blame] | 921 | |
| 922 | Should Be Equal As Strings ${match_state} ${Status['State']} |
| 923 | |
| 924 | |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 925 | Redfish Get Host State |
| 926 | [Documentation] Return host power and health state. |
| 927 | |
| 928 | # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status |
| 929 | |
| 930 | # Example: |
| 931 | # "PowerState": "Off", |
| 932 | # "Status": { |
| 933 | # "Health": "OK", |
| 934 | # "HealthRollup": "OK", |
| 935 | # "State": "StandbyOffline" |
| 936 | # }, |
| 937 | |
George Keishing | b51d150 | 2021-03-25 03:30:33 -0500 | [diff] [blame] | 938 | ${chassis}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 939 | RETURN ${chassis["PowerState"]} ${chassis["Status"]["State"]} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 940 | |
| 941 | |
| 942 | Redfish Get Boot Progress |
| 943 | [Documentation] Return boot progress state. |
| 944 | |
| 945 | # Example: /redfish/v1/Systems/system/ |
| 946 | # "BootProgress": { |
| 947 | # "LastState": "OSRunning" |
| 948 | # }, |
| 949 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 950 | ${boot_progress}= Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/ |
George Keishing | b51d150 | 2021-03-25 03:30:33 -0500 | [diff] [blame] | 951 | |
| 952 | Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86" |
| 953 | ... NA ${boot_progress["Status"]["State"]} |
| 954 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 955 | RETURN ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 956 | |
| 957 | |
| 958 | Redfish Get States |
| 959 | [Documentation] Return all the BMC and host states in dictionary. |
Sushil Singh | fd0f91b | 2023-11-10 07:35:11 -0600 | [diff] [blame] | 960 | [Timeout] ${REDFISH_SYS_STATE_WAIT_TIMEOUT} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 961 | |
| 962 | # Refer: openbmc/docs/designs/boot-progress.md |
| 963 | |
George Keishing | 205f95f | 2021-03-10 02:25:53 -0600 | [diff] [blame] | 964 | Redfish.Login |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 965 | |
| 966 | ${bmc_state}= Redfish Get BMC State |
| 967 | ${chassis_state} ${chassis_status}= Redfish Get Host State |
| 968 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 969 | |
| 970 | ${states}= Create Dictionary |
| 971 | ... bmc=${bmc_state} |
| 972 | ... chassis=${chassis_state} |
| 973 | ... host=${host_state} |
| 974 | ... boot_progress=${boot_progress} |
| 975 | |
George Keishing | 64293c5 | 2021-03-24 08:21:23 -0500 | [diff] [blame] | 976 | # Disable loggoing state to prevent huge log.html record when boot |
| 977 | # test is run in loops. |
| 978 | #Log ${states} |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 979 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 980 | RETURN ${states} |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 981 | |
| 982 | |
Sushil Singh | 8002990 | 2023-03-06 01:33:00 -0600 | [diff] [blame] | 983 | Is BMC Not Quiesced |
| 984 | [Documentation] Verify BMC state is not quiesced. |
| 985 | |
| 986 | ${bmc_state}= Redfish Get States |
| 987 | |
| 988 | Log To Console BMC State : ${bmc_state} |
| 989 | |
| 990 | Should Not Be Equal As Strings Quiesced ${bmc_state['bmc']} |
| 991 | |
| 992 | |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 993 | Is BMC Standby |
| 994 | [Documentation] Check if BMC is ready and host at standby. |
| 995 | |
| 996 | ${standby_states}= Create Dictionary |
| 997 | ... bmc=Enabled |
| 998 | ... chassis=Off |
| 999 | ... host=Disabled |
| 1000 | ... boot_progress=None |
| 1001 | |
aravinth0510 | de1863d | 2022-06-27 17:26:14 +0000 | [diff] [blame] | 1002 | Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86' |
| 1003 | ... Set To Dictionary ${standby_states} boot_progress=NA |
| 1004 | |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 1005 | Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States |
| 1006 | |
Rahul Maheshwari | 258d592 | 2022-11-27 01:04:39 -0600 | [diff] [blame] | 1007 | Wait Until Keyword Succeeds 5 min 10 sec Match State ${standby_states} |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 1008 | |
| 1009 | |
| 1010 | Match State |
| 1011 | [Documentation] Check if the expected and current states are matched. |
| 1012 | [Arguments] ${match_state} |
| 1013 | |
| 1014 | # Description of argument(s): |
| 1015 | # match_state Expected states in dictionary. |
| 1016 | |
| 1017 | ${current_state}= Redfish Get States |
| 1018 | Dictionaries Should Be Equal ${match_state} ${current_state} |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1019 | |
| 1020 | |
praphullasuresh | 95589b3 | 2023-08-24 08:59:28 -0500 | [diff] [blame] | 1021 | Wait For Host Boot Progress To Reach Required State |
| 1022 | [Documentation] Wait till host boot progress reaches required state. |
praphullasuresh | eacfac9 | 2023-08-25 06:51:01 -0500 | [diff] [blame] | 1023 | [Arguments] ${expected_boot_state}=OSRunning |
praphullasuresh | 95589b3 | 2023-08-24 08:59:28 -0500 | [diff] [blame] | 1024 | |
| 1025 | # Description of argument(s): |
| 1026 | # expected_boot_state Expected boot state. E.g. OSRunning, SystemInitComplete etc. |
| 1027 | |
| 1028 | Wait Until Keyword Succeeds ${power_on_timeout} 20 sec |
| 1029 | ... Is Boot Progress At Required State ${expected_boot_state} |
| 1030 | |
| 1031 | |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1032 | Redfish Initiate Auto Reboot |
| 1033 | [Documentation] Initiate an auto reboot. |
| 1034 | [Arguments] ${interval}=2000 |
| 1035 | |
| 1036 | # Description of argument(s): |
| 1037 | # interval Value in milliseconds to set Watchdog interval |
| 1038 | |
| 1039 | # Set auto reboot policy |
| 1040 | Redfish Set Auto Reboot RetryAttempts |
| 1041 | |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 1042 | Redfish Power Operation On |
George Keishing | a4e1352 | 2022-04-13 11:14:53 -0500 | [diff] [blame] | 1043 | |
| 1044 | Wait Until Keyword Succeeds 2 min 5 sec Is Boot Progress Changed |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 1045 | |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1046 | # Set watchdog timer |
| 1047 | Set Watchdog Interval Using Busctl ${interval} |
| 1048 | |
| 1049 | |
George Keishing | a4e1352 | 2022-04-13 11:14:53 -0500 | [diff] [blame] | 1050 | Is Boot Progress Changed |
| 1051 | [Documentation] Get BootProgress state and expect boot state mismatch. |
| 1052 | [Arguments] ${boot_state}=None |
| 1053 | |
| 1054 | # Description of argument(s): |
| 1055 | # boot_state Value of the BootProgress state to match against. |
| 1056 | |
| 1057 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 1058 | |
| 1059 | Should Not Be Equal ${boot_progress} ${boot_state} |
| 1060 | |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1061 | |
Sridevi Ramesh | 13d84bf | 2022-10-31 09:14:52 -0500 | [diff] [blame] | 1062 | Is Boot Progress At Required State |
| 1063 | [Documentation] Get BootProgress state and expect boot state to match. |
| 1064 | [Arguments] ${boot_state}=None |
| 1065 | |
| 1066 | # Description of argument(s): |
| 1067 | # boot_state Value of the BootProgress state to match. |
| 1068 | |
| 1069 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 1070 | |
| 1071 | Should Be Equal ${boot_progress} ${boot_state} |
| 1072 | |
| 1073 | |
| 1074 | Is Boot Progress At Any State |
| 1075 | [Documentation] Get BootProgress state and expect boot state to match |
| 1076 | ... with any of the states mentioned in the list. |
| 1077 | [Arguments] ${boot_states}=@{BOOT_PROGRESS_STATES} |
| 1078 | |
| 1079 | # Description of argument(s): |
| 1080 | # boot_states List of the BootProgress states to match. |
| 1081 | |
| 1082 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 1083 | Should Contain Any ${boot_progress} @{boot_states} |
| 1084 | |
| 1085 | |
Sagar Anand | 0e26266 | 2023-01-24 11:36:01 -0600 | [diff] [blame] | 1086 | Is Host At State |
| 1087 | [Documentation] Get Host state and check if it matches |
| 1088 | ... user input expected state. |
| 1089 | [Arguments] ${expected_host_state} |
| 1090 | |
| 1091 | # Description of argument(s): |
| 1092 | # expected_host_state Expected Host State to check.(e.g. Quiesced). |
| 1093 | |
| 1094 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 1095 | |
| 1096 | Should Be Equal ${host_state} ${expected_host_state} |
| 1097 | |
| 1098 | |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1099 | Set Watchdog Interval Using Busctl |
| 1100 | [Documentation] Set Watchdog time interval. |
| 1101 | [Arguments] ${milliseconds}=1000 |
| 1102 | |
| 1103 | # Description of argument(s): |
George Keishing | 4b72949 | 2021-11-10 12:51:10 -0600 | [diff] [blame] | 1104 | # milliseconds Time interval for watchdog timer |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1105 | |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 1106 | ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog |
| 1107 | ... /xyz/openbmc_project/watchdog/host0 |
| 1108 | ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds} |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 1109 | BMC Execute Command ${cmd} |
| 1110 | |
George Keishing | f5fec0d | 2021-10-08 12:38:45 -0500 | [diff] [blame] | 1111 | |
| 1112 | Stop PLDM Service And Wait |
| 1113 | [Documentation] Stop PLDM service and wait for Host to initiate reset. |
| 1114 | |
| 1115 | BMC Execute Command systemctl stop pldmd.service |
| 1116 | |
George Keishing | ca76e37 | 2022-03-16 12:45:26 -0500 | [diff] [blame] | 1117 | |
| 1118 | Get BIOS Attribute |
| 1119 | [Documentation] Get the BIOS attribute for /redfish/v1/Systems/system/Bios. |
| 1120 | |
| 1121 | # Python module: get_member_list(resource_path) |
| 1122 | ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems |
| 1123 | ${bios_attr_dict}= Redfish.Get Attribute ${systems[0]}/Bios Attributes |
| 1124 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 1125 | RETURN ${bios_attr_dict} |
nagarjunb22 | cfb2c41 | 2022-03-15 15:49:27 +0530 | [diff] [blame] | 1126 | |
George Keishing | 8f610e7 | 2022-03-28 10:43:08 -0500 | [diff] [blame] | 1127 | |
| 1128 | Set BIOS Attribute |
| 1129 | [Documentation] PATCH the BIOS attribute for /redfish/v1/Systems/system/Bios. |
| 1130 | [Arguments] ${attribute_name} ${attribute_value} |
| 1131 | |
| 1132 | # Description of argument(s): |
| 1133 | # attribute_name Any valid BIOS attribute. |
| 1134 | # attribute_value Valid allowed attribute values. |
| 1135 | |
| 1136 | # Python module: get_member_list(resource_path) |
| 1137 | ${systems}= Redfish_Utils.Get Member List /redfish/v1/Systems |
| 1138 | Redfish.Patch ${systems[0]}/Bios/Settings body={"Attributes":{"${attribute_name}":"${attribute_value}"}} |
| 1139 | |
| 1140 | |
nagarjunb22 | cfb2c41 | 2022-03-15 15:49:27 +0530 | [diff] [blame] | 1141 | Is BMC Operational |
| 1142 | [Documentation] Check if BMC is enabled. |
ganesanb | 13fb3cf | 2023-05-12 00:42:18 +0000 | [diff] [blame] | 1143 | [Teardown] Redfish.Logout |
nagarjunb22 | cfb2c41 | 2022-03-15 15:49:27 +0530 | [diff] [blame] | 1144 | |
ganesanb | 13fb3cf | 2023-05-12 00:42:18 +0000 | [diff] [blame] | 1145 | Wait Until Keyword Succeeds 5 min 5 sec Ping Host ${OPENBMC_HOST} |
| 1146 | # In some of bmc stack, network services will gets loaded before redfish/ipmi services gets loaded. |
| 1147 | # Hence, 3mins sleep time is added to allow other service gets loaded. |
| 1148 | Sleep 180s |
| 1149 | Redfish.login |
| 1150 | ${bmc_status}= Redfish Get BMC State |
nagarjunb22 | cfb2c41 | 2022-03-15 15:49:27 +0530 | [diff] [blame] | 1151 | Should Be Equal ${bmc_status} Enabled |
George Keishing | 83c737b | 2022-05-17 12:12:04 -0500 | [diff] [blame] | 1152 | |
| 1153 | |
| 1154 | PLDM Set BIOS Attribute |
| 1155 | [Documentation] Set the BIOS attribute via pldmtool and verify the attribute is set. |
| 1156 | ... Defaulted for fw_boot_side for boot test usage caller. |
| 1157 | [Arguments] ${attribute_name}=fw_boot_side ${attribute_value}=Temp |
| 1158 | |
| 1159 | # Description of argument(s): |
| 1160 | # attribute_name Valid BIOS attribute name e.g ("fw_boot_side") |
| 1161 | # attribute_value Valid BIOS attribute value for fw_boot_side. |
| 1162 | |
| 1163 | # PLDM response output example: |
| 1164 | # { |
| 1165 | # "Response": "SUCCESS" |
| 1166 | # } |
| 1167 | |
| 1168 | ${resp}= pldmtool bios SetBIOSAttributeCurrentValue -a ${attribute_name} -d ${attribute_value} |
| 1169 | Should Be Equal As Strings ${resp["Response"]} SUCCESS |
| 1170 | |
| 1171 | # PLDM GET output example: |
| 1172 | # { |
| 1173 | # "CurrentValue": "Temp" |
| 1174 | # } |
| 1175 | |
| 1176 | ${pldm_output}= PLDM Get BIOS Attribute ${attribute_name} |
| 1177 | Should Be Equal As Strings ${pldm_output["CurrentValue"]} ${attribute_value} |
| 1178 | ... msg=Expecting ${attribute_value} but got ${pldm_output["CurrentValue"]} |
| 1179 | |
| 1180 | |
| 1181 | PLDM Get BIOS Attribute |
| 1182 | [Documentation] Get the BIOS attribute via pldmtool for a given attribute and return value. |
| 1183 | [Arguments] ${attribute_name} |
| 1184 | |
| 1185 | # Description of argument(s): |
| 1186 | # attribute_name Valid BIOS attribute name e.g ("fw_boot_side") |
| 1187 | |
| 1188 | ${pldm_output}= pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${attribute_name} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 1189 | RETURN ${pldm_output} |
nagarjunb22 | 00108dc | 2022-07-12 21:50:45 +0530 | [diff] [blame] | 1190 | |
| 1191 | |
| 1192 | Verify Host Power State |
| 1193 | [Documentation] Get the Host Power state and compare it with the expected state. |
| 1194 | [Arguments] ${expected_power_state} |
| 1195 | |
| 1196 | # Description of argument(s): |
| 1197 | # expected_power_state State of Host e.g. Off or On. |
| 1198 | |
| 1199 | ${power_state} ${health_status}= Redfish Get Host State |
| 1200 | Should Be Equal ${power_state} ${expected_power_state} |
| 1201 | |
| 1202 | |
| 1203 | Verify Host Is Up |
| 1204 | [Documentation] Verify Host is Up. |
| 1205 | |
| 1206 | Wait Until Keyword Succeeds 3 min 30 sec Verify Host Power State On |
| 1207 | # Python module: os_execute(cmd) |
| 1208 | Wait Until Keyword Succeeds 10 min 30 sec OS Execute Command uptime |