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 |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 25 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 26 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 27 | *** Variables *** |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 28 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 29 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
| 30 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 31 | # Assign default value to QUIET for programs which may not define it. |
| 32 | ${QUIET} ${0} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 33 | |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 34 | ${HOST_SETTING} ${SETTINGS_URI}host0 |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 35 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 36 | ${boot_prog_method} ${EMPTY} |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 37 | ${power_policy_setup} ${0} |
| 38 | ${bmc_power_policy_method} ${EMPTY} |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 39 | |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 40 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 41 | *** Keywords *** |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 42 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 43 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 44 | Verify Ping and REST Authentication |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 45 | [Documentation] Verify ping and rest authentication. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 46 | ${l_ping}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 47 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 48 | Run Keyword If '${l_ping}' == '${False}' |
| 49 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 50 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 51 | ${l_rest}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 52 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 53 | Run Keyword If '${l_rest}' == '${False}' |
| 54 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 55 | |
| 56 | # Just to make sure the SSH is working for SCP |
| 57 | Open Connection And Log In |
| 58 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 59 | Should Be Empty ${stderr} |
| 60 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 61 | |
George Keishing | 90b555a | 2021-05-20 11:54:16 -0500 | [diff] [blame] | 62 | Verify Ping SSH And Redfish Authentication |
| 63 | [Documentation] Verify ping, SSH and redfish authentication. |
| 64 | |
| 65 | ${l_ping}= Run Keyword And Return Status Ping Host ${OPENBMC_HOST} |
| 66 | Run Keyword If '${l_ping}' == '${False}' Fail msg=Ping Failed |
| 67 | |
| 68 | ${l_rest}= Run Keyword And Return Status Redfish.Login |
| 69 | Run Keyword If '${l_rest}' == '${False}' Fail msg=REST Authentication Failed |
| 70 | |
| 71 | # Just to make sure the SSH is working. |
| 72 | Open Connection And Log In |
| 73 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 74 | Should Be Empty ${stderr} |
| 75 | |
| 76 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 77 | Check If BMC is Up |
| 78 | [Documentation] Wait for Host to be online. Checks every X seconds |
| 79 | ... interval for Y minutes and fails if timed out. |
| 80 | ... Default MAX timedout is 10 min, interval 10 seconds. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 81 | [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 82 | ... ${interval}=10 sec |
| 83 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 84 | # Description of argument(s): |
| 85 | # max_timeout Maximum time to wait. |
| 86 | # This should be expressed in Robot Framework's time format |
| 87 | # (e.g. "10 minutes"). |
George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 88 | # interval Interval to wait between status checks. |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 89 | # This should be expressed in Robot Framework's time format |
| 90 | # (e.g. "5 seconds"). |
| 91 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 92 | Wait Until Keyword Succeeds |
| 93 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 94 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 95 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 96 | Flush REST Sessions |
| 97 | [Documentation] Removes all the active session objects |
| 98 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 99 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 100 | |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 101 | Trigger Host Watchdog Error |
George Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 102 | [Documentation] Inject host watchdog timeout error via REST. |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 103 | [Arguments] ${milliseconds}=1000 ${sleep_time}=5s |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 104 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 105 | # Description of argument(s): |
| 106 | # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 = |
| 107 | # 1 second). |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 108 | # sleep_time Time delay for host watchdog error to get injected. |
| 109 | # Default is 5 seconds. |
| 110 | |
Michael Walsh | 4ffd1a1 | 2018-03-14 10:35:44 -0500 | [diff] [blame] | 111 | ${data}= Create Dictionary |
| 112 | ... data=xyz.openbmc_project.State.Watchdog.Action.PowerCycle |
| 113 | ${status} ${result}= Run Keyword And Ignore Error |
| 114 | ... Read Attribute ${HOST_WATCHDOG_URI} ExpireAction |
| 115 | Run Keyword If '${status}' == 'PASS' |
| 116 | ... Write Attribute ${HOST_WATCHDOG_URI} ExpireAction data=${data} |
George Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 117 | |
Sridevi Ramesh | eadeef0 | 2019-01-17 08:56:18 -0600 | [diff] [blame] | 118 | ${int_milliseconds}= Convert To Integer ${milliseconds} |
| 119 | ${data}= Create Dictionary data=${int_milliseconds} |
Michael Walsh | 4ffd1a1 | 2018-03-14 10:35:44 -0500 | [diff] [blame] | 120 | Write Attribute ${HOST_WATCHDOG_URI} Interval data=${data} |
| 121 | |
| 122 | ${data}= Create Dictionary data=${True} |
| 123 | Write Attribute ${HOST_WATCHDOG_URI} Enabled data=${data} |
George Keishing | 37cfa6b | 2017-06-15 10:25:55 -0500 | [diff] [blame] | 124 | |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 125 | Sleep ${sleep_time} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 126 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 127 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 128 | Login To OS Host |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 129 | [Documentation] Login to OS Host and return the Login response code. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 130 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 131 | ... ${os_password}=${OS_PASSWORD} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 132 | |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 133 | # Description of arguments: |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 134 | # ${os_host} IP address of the OS Host. |
| 135 | # ${os_username} OS Host Login user name. |
| 136 | # ${os_password} OS Host Login passwrd. |
| 137 | |
Rahul Maheshwari | d1f45f2 | 2018-10-26 05:16:39 -0500 | [diff] [blame] | 138 | REST Power On stack_mode=skip quiet=1 |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 139 | |
George Keishing | 3f223b8 | 2017-06-28 03:50:35 -0500 | [diff] [blame] | 140 | SSHLibrary.Open Connection ${os_host} |
George Keishing | e003088 | 2019-02-21 03:48:27 -0600 | [diff] [blame] | 141 | ${resp}= SSHLibrary.Login ${os_username} ${os_password} |
Sridevi Ramesh | ea36b41 | 2017-03-09 04:08:02 -0600 | [diff] [blame] | 142 | [Return] ${resp} |
Prashanth Katti | 884ee06 | 2017-03-16 05:05:03 -0500 | [diff] [blame] | 143 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 144 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 145 | Initiate Auto Reboot |
| 146 | [Documentation] Initiate an auto reboot. |
| 147 | [Arguments] ${milliseconds}=5000 |
Sweta Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 148 | |
| 149 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 150 | # milliseconds The number of milliseconds for the watchdog timer. |
Sweta Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 151 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 152 | # Set the auto reboot policy. |
| 153 | Set Auto Reboot ${1} |
| 154 | # Set the watchdog timer. |
| 155 | Trigger Host Watchdog Error ${milliseconds} |
| 156 | |
| 157 | |
| 158 | Initiate OS Host Reboot |
| 159 | [Documentation] Initiate an OS reboot. |
| 160 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 161 | ... ${os_password}=${OS_PASSWORD} |
| 162 | |
| 163 | # Description of argument(s): |
| 164 | # os_host The host name or IP address of the OS. |
| 165 | # os_username The username to be used to sign in to the OS. |
| 166 | # os_password The password to be used to sign in to the OS. |
| 167 | |
| 168 | ${cmd_buf}= Run Keyword If '${os_username}' == 'root' |
| 169 | ... Set Variable reboot |
| 170 | ... ELSE |
| 171 | ... Set Variable echo ${os_password} | sudo -S reboot |
| 172 | |
| 173 | ${output} ${stderr} ${rc}= OS Execute Command |
| 174 | ... ${cmd_buf} fork=${1} |
| 175 | |
| 176 | |
| 177 | Initiate OS Host Power Off |
| 178 | [Documentation] Initiate an OS reboot. |
| 179 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 180 | ... ${os_password}=${OS_PASSWORD} ${hard}=${0} |
| 181 | |
| 182 | # Description of argument(s): |
| 183 | # os_host The DNS name or IP of the OS. |
| 184 | # os_username The username to be used to sign in to the OS. |
| 185 | # os_password The password to be used to sign in to the OS. |
| 186 | # hard Indicates whether to do a hard vs. soft power off. |
| 187 | |
| 188 | ${time_string}= Run Keyword If ${hard} Set Variable ${SPACE}now |
| 189 | ... ELSE Set Variable ${EMPTY} |
| 190 | |
| 191 | ${cmd_buf}= Run Keyword If '${os_username}' == 'root' |
| 192 | ... Set Variable shutdown${time_string} |
| 193 | ... ELSE |
| 194 | ... Set Variable echo ${os_password} | sudo -S shutdown${time_string} |
| 195 | |
| 196 | ${output} ${stderr} ${rc}= OS Execute Command |
| 197 | ... ${cmd_buf} fork=${1} |
Sweta Potthuri | e5a9fc7 | 2017-05-03 07:02:46 -0500 | [diff] [blame] | 198 | |
George Keishing | 3987a1e | 2017-09-20 09:13:02 -0500 | [diff] [blame] | 199 | |
Steven Sombar | 5f3af44 | 2018-02-14 08:30:15 -0600 | [diff] [blame] | 200 | Set System LED State |
| 201 | [Documentation] Set given system LED via REST. |
| 202 | [Arguments] ${led_name} ${led_state} |
| 203 | # Description of argument(s): |
| 204 | # led_name System LED name (e.g. heartbeat, identify, beep). |
| 205 | # led_state LED state to be set (e.g. On, Off). |
| 206 | |
| 207 | ${args}= Create Dictionary |
| 208 | ... data=xyz.openbmc_project.Led.Physical.Action.${led_state} |
| 209 | Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args} |
| 210 | |
| 211 | Verify LED State ${led_name} ${led_state} |
| 212 | |
| 213 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 214 | Read Turbo Setting Via REST |
| 215 | [Documentation] Return turbo setting via REST. |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 216 | # Returns 1 if TurboAllowed, 0 if not. |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 217 | |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 218 | ${turbo_setting}= Read Attribute |
| 219 | ... ${CONTROL_HOST_URI}turbo_allowed TurboAllowed |
| 220 | [Return] ${turbo_setting} |
| 221 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 222 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 223 | Set Turbo Setting Via REST |
| 224 | [Documentation] Set turbo setting via REST. |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 225 | [Arguments] ${setting} ${verify}=${False} |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 226 | |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 227 | # Description of argument(s): |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 228 | # setting State to set TurboAllowed, 1=allowed, 0=not allowed. |
| 229 | # verify If True, read the TurboAllowed setting to confirm. |
Steven Sombar | aaf72c4 | 2017-09-05 12:02:00 -0500 | [diff] [blame] | 230 | |
Steven Sombar | ea79a49 | 2018-04-18 11:14:57 -0500 | [diff] [blame] | 231 | ${data}= Create Dictionary data=${${setting}} |
Steven Sombar | 80bc859 | 2018-04-24 11:44:53 -0500 | [diff] [blame] | 232 | Write Attribute ${CONTROL_HOST_URI}turbo_allowed TurboAllowed |
| 233 | ... verify=${verify} data=${data} |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 234 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 235 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 236 | Set REST Logging Policy |
| 237 | [Documentation] Enable or disable REST logging setting. |
| 238 | [Arguments] ${policy_setting}=${True} |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 239 | |
| 240 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 241 | # policy_setting The policy setting value which can be either |
| 242 | # True or False. |
George Keishing | ef74a8c | 2017-10-20 10:23:52 -0500 | [diff] [blame] | 243 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 244 | ${log_dict}= Create Dictionary data=${policy_setting} |
George Keishing | df3e65f | 2018-12-18 13:06:56 -0600 | [diff] [blame] | 245 | Write Attribute ${BMC_LOGGING_URI}rest_api_logs Enabled |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 246 | ... data=${log_dict} verify=${1} expected_value=${policy_setting} |
Sridevi Ramesh | 0d88ab3 | 2017-09-21 11:07:28 -0500 | [diff] [blame] | 247 | |
Steven Sombar | 0acb341 | 2018-01-24 09:38:42 -0600 | [diff] [blame] | 248 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 249 | Old Get Boot Progress |
| 250 | [Documentation] Get the boot progress the old way (via org location). |
| 251 | [Arguments] ${quiet}=${QUIET} |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 252 | |
| 253 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 254 | # quiet Indicates whether this keyword should run without any output to |
| 255 | # the console. |
| 256 | |
| 257 | ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress |
| 258 | ... value quiet=${quiet} |
| 259 | |
| 260 | [Return] ${state} |
| 261 | |
| 262 | |
| 263 | Set Boot Progress Method |
| 264 | [Documentation] Set the boot_prog_method to either 'Old' or 'New'. |
| 265 | |
| 266 | # The boot progress data has moved from an 'org' location to an 'xyz' |
| 267 | # location. This keyword will determine whether the new method of getting |
| 268 | # the boot progress is valid and will set the global boot_prog_method |
| 269 | # variable accordingly. If boot_prog_method is already set (either by a |
| 270 | # prior call to this function or via a -v parm), this keyword will simply |
| 271 | # return. |
| 272 | |
| 273 | # Note: There are interim builds that contain boot_progress in both the |
| 274 | # old and the new location values. It is nearly impossible for this |
| 275 | # keyword to determine whether the old boot_progress or the new one is |
| 276 | # active. When using such builds where the old boot_progress is active, |
| 277 | # the only recourse users will have is that they may specify |
| 278 | # -v boot_prog_method:Old to force old behavior on such builds. |
| 279 | |
| 280 | Run Keyword If '${boot_prog_method}' != '${EMPTY}' Return From Keyword |
| 281 | |
| 282 | ${new_status} ${new_value}= Run Keyword And Ignore Error |
| 283 | ... New Get Boot Progress |
| 284 | # If the new style read fails, the method must necessarily be "Old". |
| 285 | Run Keyword If '${new_status}' == 'PASS' |
| 286 | ... Run Keywords |
| 287 | ... Set Global Variable ${boot_prog_method} New AND |
| 288 | ... Rqpvars boot_prog_method AND |
| 289 | ... Return From Keyword |
| 290 | |
| 291 | # Default method is "Old". |
| 292 | Set Global Variable ${boot_prog_method} Old |
| 293 | Rqpvars boot_prog_method |
| 294 | |
| 295 | |
| 296 | Initiate Power On |
| 297 | [Documentation] Initiates the power on and waits until the Is Power On |
| 298 | ... keyword returns that the power state has switched to on. |
| 299 | [Arguments] ${wait}=${1} |
| 300 | |
| 301 | # Description of argument(s): |
| 302 | # wait Indicates whether to wait for a powered on state after issuing |
| 303 | # the power on command. |
| 304 | |
| 305 | @{arglist}= Create List |
| 306 | ${args}= Create Dictionary data=@{arglist} |
| 307 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn |
| 308 | ... data=${args} |
| 309 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 310 | |
| 311 | # Does caller want to wait for power on status? |
| 312 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 313 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
| 314 | |
| 315 | |
| 316 | Initiate Power Off |
| 317 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 318 | ... keyword returns that the power state has switched to off. |
| 319 | |
| 320 | @{arglist}= Create List |
| 321 | ${args}= Create Dictionary data=@{arglist} |
| 322 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff |
| 323 | ... data=${args} |
| 324 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 325 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
| 326 | |
| 327 | |
| 328 | Get Boot Progress |
| 329 | [Documentation] Get the boot progress and return it. |
| 330 | [Arguments] ${quiet}=${QUIET} |
| 331 | |
| 332 | # Description of argument(s): |
| 333 | # quiet Indicates whether this keyword should run without any output to |
| 334 | # the console. |
| 335 | |
| 336 | Set Boot Progress Method |
| 337 | ${state}= Run Keyword If '${boot_prog_method}' == 'New' |
| 338 | ... New Get Boot Progress quiet=${quiet} |
| 339 | ... ELSE |
| 340 | ... Old Get Boot Progress quiet=${quiet} |
| 341 | |
| 342 | [Return] ${state} |
| 343 | |
| 344 | |
| 345 | New Get Boot Progress |
| 346 | [Documentation] Get the boot progress the new way (via xyz location). |
| 347 | [Arguments] ${quiet}=${QUIET} |
| 348 | |
| 349 | # Description of argument(s): |
| 350 | # quiet Indicates whether this keyword should run without any output to |
| 351 | # the console. |
| 352 | |
| 353 | ${state}= Read Attribute ${HOST_STATE_URI} BootProgress quiet=${quiet} |
| 354 | |
| 355 | [Return] ${state.rsplit('.', 1)[1]} |
| 356 | |
| 357 | |
| 358 | New Get Power Policy |
| 359 | [Documentation] Returns the BMC power policy (new method). |
| 360 | ${currentPolicy}= Read Attribute ${POWER_RESTORE_URI} PowerRestorePolicy |
| 361 | |
| 362 | [Return] ${currentPolicy} |
| 363 | |
| 364 | |
| 365 | Old Get Power Policy |
| 366 | [Documentation] Returns the BMC power policy (old method). |
| 367 | ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy |
| 368 | |
| 369 | [Return] ${currentPolicy} |
| 370 | |
| 371 | |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 372 | Redfish Get Power Restore Policy |
| 373 | [Documentation] Returns the BMC power restore policy. |
| 374 | |
| 375 | ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/system PowerRestorePolicy |
| 376 | [Return] ${power_restore_policy} |
| 377 | |
| 378 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 379 | Get Auto Reboot |
| 380 | [Documentation] Returns auto reboot setting. |
| 381 | ${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot |
| 382 | |
| 383 | [Return] ${setting} |
| 384 | |
| 385 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 386 | Redfish Get Auto Reboot |
| 387 | [Documentation] Returns auto reboot setting. |
| 388 | |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 389 | ${resp}= Redfish.Get Attribute /redfish/v1/Systems/system Boot |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 390 | [Return] ${resp["AutomaticRetryConfig"]} |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 391 | |
| 392 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 393 | Trigger Warm Reset |
| 394 | [Documentation] Initiate a warm reset. |
| 395 | |
| 396 | log to console "Triggering warm reset" |
| 397 | ${data}= create dictionary data=@{EMPTY} |
| 398 | ${resp}= openbmc post request |
| 399 | ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data} |
| 400 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 401 | ${session_active}= Check If warmReset is Initiated |
| 402 | Run Keyword If '${session_active}' == '${True}' |
| 403 | ... Fail msg=warm reset didn't occur |
| 404 | |
| 405 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 406 | Check If BMC Is Up |
| 407 | |
| 408 | |
| 409 | Get Power State |
| 410 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
| 411 | [Arguments] ${quiet}=${QUIET} |
| 412 | |
| 413 | # Description of argument(s): |
| 414 | # quiet Indicates whether this keyword should run without any output to |
| 415 | # the console. |
| 416 | |
| 417 | @{arglist}= Create List |
| 418 | ${args}= Create Dictionary data=@{arglist} |
| 419 | |
| 420 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState |
| 421 | ... data=${args} quiet=${quiet} |
| 422 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 423 | ${content}= to json ${resp.content} |
| 424 | |
| 425 | [Return] ${content["data"]} |
| 426 | |
| 427 | |
| 428 | Clear BMC Gard Record |
| 429 | [Documentation] Clear gard records from the system. |
| 430 | |
| 431 | @{arglist}= Create List |
| 432 | ${args}= Create Dictionary data=@{arglist} |
| 433 | ${resp}= Call Method |
| 434 | ... ${OPENPOWER_CONTROL}gard Reset data=${args} |
| 435 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 436 | |
| 437 | |
| 438 | Flash PNOR |
| 439 | [Documentation] Calls flash bios update method to flash PNOR image |
| 440 | [Arguments] ${pnor_image} |
| 441 | |
| 442 | # Description of argument(s): |
| 443 | # pnor_image The filename and path of the PNOR image |
| 444 | # (e.g. "/home/image/zaius.pnor"). |
| 445 | |
| 446 | @{arglist}= Create List ${pnor_image} |
| 447 | ${args}= Create Dictionary data=@{arglist} |
| 448 | ${resp}= Call Method /org/openbmc/control/flash/bios/ update |
| 449 | ... data=${args} |
| 450 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 451 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 452 | |
| 453 | |
| 454 | Get Flash BIOS Status |
| 455 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 456 | ... example 'Flashing', 'Flash Done', etc |
| 457 | ${data}= Read Properties /org/openbmc/control/flash/bios |
| 458 | [Return] ${data['status']} |
| 459 | |
| 460 | |
| 461 | Is PNOR Flashing |
| 462 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 463 | ... flashing has started. |
| 464 | ${status}= Get Flash BIOS Status |
| 465 | Should Contain ${status} Flashing |
| 466 | |
| 467 | |
| 468 | Is PNOR Flash Done |
| 469 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 470 | ... PNOR flashing has completed. |
| 471 | ${status}= Get Flash BIOS Status |
| 472 | should be equal as strings ${status} Flash Done |
| 473 | |
| 474 | |
| 475 | Create OS Console File Path |
| 476 | [Documentation] Create OS console file path name and return it. |
| 477 | [Arguments] ${log_file_path}=${EMPTY} |
| 478 | |
| 479 | # Description of arguments: |
| 480 | # file_path The caller's candidate value. If this value is ${EMPTY}, this |
| 481 | # keyword will compose a file path name. Otherwise, this |
| 482 | # keyword will use the caller's file_path value. In either |
| 483 | # case, the value will be returned. |
| 484 | |
| 485 | ${status}= Run Keyword And Return Status Variable Should Exist |
| 486 | ... ${TEST_NAME} |
| 487 | |
| 488 | ${default_file_path}= Set Variable If ${status} == ${TRUE} |
| 489 | ... /tmp/${OPENBMC_HOST}_${TEST_NAME.replace(' ', '')}_os_console.txt |
| 490 | ... /tmp/${OPENBMC_HOST}_os_console.txt |
| 491 | |
| 492 | ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}' |
| 493 | ... ${default_file_path} ${log_file_path} |
| 494 | |
| 495 | [Return] ${log_file_path} |
| 496 | |
| 497 | |
| 498 | Get Endpoint Paths |
| 499 | [Documentation] Returns all url paths ending with given endpoint |
| 500 | ... Example: |
| 501 | ... Given the following endpoint: cpu |
| 502 | ... This keyword will return: list of all urls ending with |
| 503 | ... cpu - |
| 504 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu0, |
| 505 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu1 |
| 506 | [Arguments] ${path} ${endpoint} |
| 507 | |
| 508 | # Description of arguments: |
| 509 | # path URL path for enumeration. |
| 510 | # endpoint Endpoint string (url path ending). |
| 511 | |
Steven Sombar | aaaab22 | 2018-12-19 13:16:23 -0600 | [diff] [blame] | 512 | # Make sure path ends with slash. |
| 513 | ${path}= Add Trailing Slash ${path} |
| 514 | |
| 515 | ${resp}= Read Properties ${path}enumerate timeout=30 |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 516 | Log Dictionary ${resp} |
| 517 | |
| 518 | ${list}= Get Dictionary Keys ${resp} |
| 519 | # For a given string, look for prefix and suffix for matching expression. |
| 520 | # Start of string followed by zero or more of any character followed by |
| 521 | # any digit or lower case character. |
George Keishing | 585afa3 | 2020-07-09 04:55:15 -0500 | [diff] [blame] | 522 | ${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] | 523 | |
| 524 | [Return] ${resp} |
| 525 | |
| 526 | |
| 527 | Set BMC Power Policy |
| 528 | [Documentation] Set the given BMC power policy. |
| 529 | [Arguments] ${policy} |
| 530 | |
| 531 | # Note that this function will translate the old style "RESTORE_LAST_STATE" |
| 532 | # policy to the new style "xyz.openbmc_project.Control.Power.RestorePolicy. |
| 533 | # Policy.Restore" for you. |
| 534 | |
| 535 | # Description of argument(s): |
| 536 | # policy Power restore policy (e.g "RESTORE_LAST_STATE", |
| 537 | # ${RESTORE_LAST_STATE}). |
| 538 | |
| 539 | # Set the bmc_power_policy_method to either 'Old' or 'New'. |
| 540 | Set Power Policy Method |
| 541 | # This translation helps bridge between old and new method for calling. |
| 542 | ${policy}= Translate Power Policy Value ${policy} |
| 543 | # Run the appropriate keyword. |
| 544 | Run Key ${bmc_power_policy_method} Set Power Policy \ ${policy} |
| 545 | ${currentPolicy}= Get System Power Policy |
| 546 | Should Be Equal ${currentPolicy} ${policy} |
| 547 | |
| 548 | |
| 549 | Delete Error Logs |
| 550 | [Documentation] Delete error logs. |
Michael Shepos | cc490b4 | 2020-08-26 12:53:01 -0500 | [diff] [blame] | 551 | [Arguments] ${quiet}=${0} |
| 552 | # Description of argument(s): |
| 553 | # quiet If enabled, turns off logging to console. |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 554 | |
| 555 | # Check if error logs entries exist, if not return. |
Steven Sombar | a8800da | 2018-12-18 16:19:05 -0600 | [diff] [blame] | 556 | ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 557 | Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} |
| 558 | |
| 559 | # Get the list of error logs entries and delete them all. |
| 560 | ${elog_entries}= Get URL List ${BMC_LOGGING_ENTRY} |
David Shaw | 79247e4 | 2020-06-18 17:16:02 -0500 | [diff] [blame] | 561 | FOR ${entry} IN @{elog_entries} |
Michael Shepos | cc490b4 | 2020-08-26 12:53:01 -0500 | [diff] [blame] | 562 | Delete Error Log Entry ${entry} quiet=${quiet} |
David Shaw | 79247e4 | 2020-06-18 17:16:02 -0500 | [diff] [blame] | 563 | END |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 564 | |
| 565 | |
| 566 | Delete All Error Logs |
| 567 | [Documentation] Delete all error log entries using "DeleteAll" interface. |
| 568 | |
| 569 | ${data}= Create Dictionary data=@{EMPTY} |
| 570 | ${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll |
| 571 | ... data=${data} |
| 572 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 573 | |
| 574 | |
| 575 | Get Elog URL List |
| 576 | [Documentation] Return error log entry list of URLs. |
| 577 | |
| 578 | ${url_list}= Read Properties /xyz/openbmc_project/logging/entry/ |
| 579 | Sort List ${url_list} |
| 580 | [Return] ${url_list} |
| 581 | |
| 582 | |
| 583 | Get BMC Flash Chip Boot Side |
| 584 | [Documentation] Return the BMC flash chip boot side. |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 585 | |
| 586 | # Example: |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 587 | # 0 - indicates chip select is current side. |
| 588 | # 32 - indicates chip select is alternate side. |
George Keishing | 034902d | 2017-11-10 13:15:38 -0600 | [diff] [blame] | 589 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 590 | ${boot_side} ${stderr} ${rc}= BMC Execute Command |
| 591 | ... cat /sys/class/watchdog/watchdog1/bootstatus |
| 592 | |
| 593 | [Return] ${boot_side} |
| 594 | |
| 595 | |
Sweta Potthuri | 7d3af3c | 2018-01-29 03:07:07 -0600 | [diff] [blame] | 596 | Watchdog Object Should Exist |
| 597 | [Documentation] Check that watchdog object exists. |
| 598 | |
| 599 | ${resp}= OpenBMC Get Request ${WATCHDOG_URI}host0 |
| 600 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 601 | ... msg=Expected watchdog object does not exist. |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 602 | |
| 603 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 604 | Get System LED State |
| 605 | [Documentation] Return the state of given system LED. |
| 606 | [Arguments] ${led_name} |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 607 | |
| 608 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 609 | # led_name System LED name (e.g. heartbeat, identify, beep). |
Sweta Potthuri | f39022d | 2018-02-06 03:40:07 -0600 | [diff] [blame] | 610 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 611 | ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State |
| 612 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 613 | |
| 614 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 615 | Verify LED State |
| 616 | [Documentation] Checks if LED is in given state. |
| 617 | [Arguments] ${led_name} ${led_state} |
| 618 | # Description of argument(s): |
| 619 | # led_name System LED name (e.g. heartbeat, identify, beep). |
| 620 | # led_state LED state to be verified (e.g. On, Off). |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 621 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 622 | ${state}= Get System LED State ${led_name} |
| 623 | Should Be Equal ${state} ${led_state} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 624 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 625 | |
| 626 | Get LED State XYZ |
| 627 | [Documentation] Returns state of given LED. |
| 628 | [Arguments] ${led_name} |
| 629 | |
| 630 | # Description of argument(s): |
| 631 | # led_name Name of LED. |
| 632 | |
| 633 | ${state}= Read Attribute ${LED_GROUPS_URI}${led_name} Asserted |
| 634 | # Returns the state of the LED, either On or Off. |
| 635 | [Return] ${state} |
George Keishing | b9f407b | 2018-02-20 00:07:46 -0600 | [diff] [blame] | 636 | |
George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 637 | |
| 638 | Verify Identify LED State |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 639 | [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] | 640 | [Arguments] ${expected_state} |
| 641 | |
| 642 | # Description of argument(s): |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 643 | # expected_state The expected LED asserted state (1 = asserted, 0 = not asserted). |
George Keishing | 78ce8dc | 2018-03-30 11:49:06 -0500 | [diff] [blame] | 644 | |
Alvin Wang | 32f7b3d | 2019-07-25 02:05:39 -0500 | [diff] [blame] | 645 | ${led_state}= Get LED State XYZ enclosure_identify |
| 646 | Should Be Equal ${led_state} ${expected_state} msg=Unexpected LED state. |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 647 | |
| 648 | Verify The Attribute |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 649 | [Documentation] Verify the given attribute. |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 650 | [Arguments] ${uri} ${attribute_name} ${attribute_value} |
| 651 | |
| 652 | # Description of argument(s): |
| 653 | # uri URI path |
| 654 | # (e.g. "/xyz/openbmc_project/control/host0/TPMEnable"). |
| 655 | # attribute_name Name of attribute to be verified (e.g. "TPMEnable"). |
| 656 | # attribute_value The expected value of attribute (e.g. "1", "0", etc.) |
| 657 | |
| 658 | ${output}= Read Attribute ${uri} ${attribute_name} |
| 659 | Should Be Equal ${attribute_value} ${output} |
| 660 | ... msg=Attribute "${attribute_name} does not have the expected value. |
George Keishing | cf0d777 | 2018-05-04 08:22:50 -0500 | [diff] [blame] | 661 | |
| 662 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 663 | New Set Power Policy |
| 664 | [Documentation] Set the given BMC power policy (new method). |
| 665 | [Arguments] ${policy} |
George Keishing | b4adfc7 | 2018-10-26 09:39:32 -0500 | [diff] [blame] | 666 | |
| 667 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 668 | # policy Power restore policy (e.g. ${ALWAYS_POWER_OFF}). |
George Keishing | c5fef58 | 2018-07-18 08:41:28 -0500 | [diff] [blame] | 669 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 670 | ${valueDict}= Create Dictionary data=${policy} |
| 671 | Write Attribute |
| 672 | ... ${POWER_RESTORE_URI} PowerRestorePolicy data=${valueDict} |
George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 673 | |
| 674 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 675 | Old Set Power Policy |
| 676 | [Documentation] Set the given BMC power policy (old method). |
| 677 | [Arguments] ${policy} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 678 | |
| 679 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 680 | # policy Power restore policy (e.g. "ALWAYS_POWER_OFF"). |
| 681 | |
| 682 | ${valueDict}= create dictionary data=${policy} |
| 683 | Write Attribute ${HOST_SETTING} power_policy data=${valueDict} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 684 | |
| 685 | |
George Keishing | a54e06f | 2020-06-12 10:42:41 -0500 | [diff] [blame] | 686 | Redfish Set Power Restore Policy |
| 687 | [Documentation] Set the BMC power restore policy. |
| 688 | [Arguments] ${power_restore_policy} |
| 689 | |
| 690 | # Description of argument(s): |
| 691 | # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState"). |
| 692 | |
| 693 | Redfish.Patch /redfish/v1/Systems/system body={"PowerRestorePolicy": "${power_restore_policy}"} |
| 694 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 695 | |
| 696 | |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 697 | Set Auto Reboot Setting |
| 698 | [Documentation] Set the given auto reboot setting (REST or Redfish). |
| 699 | [Arguments] ${value} |
| 700 | |
| 701 | # Description of argument(s): |
| 702 | # value The reboot setting, 1 for enabling and 0 for disabling. |
| 703 | |
| 704 | # This is to cater to boot call points and plugin script which will always |
| 705 | # send using value 0 or 1. This dictionary maps to redfish string values. |
| 706 | ${rest_redfish_dict}= Create Dictionary |
| 707 | ... 1=RetryAttempts |
| 708 | ... 0=Disabled |
| 709 | |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 710 | Run Keyword If ${REDFISH_SUPPORT_TRANS_STATE} == ${1} |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 711 | ... Redfish Set Auto Reboot ${rest_redfish_dict["${value}"]} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 712 | ... ELSE |
| 713 | ... Set Auto Reboot ${value} |
George Keishing | a5cedb3 | 2020-07-17 15:50:34 -0500 | [diff] [blame] | 714 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 715 | Set Auto Reboot |
| 716 | [Documentation] Set the given auto reboot setting. |
| 717 | [Arguments] ${setting} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 718 | |
| 719 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 720 | # setting The reboot setting, 1 for enabling and 0 for disabling. |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 721 | |
Sridevi Ramesh | 68d72ff | 2019-02-04 09:24:46 -0600 | [diff] [blame] | 722 | ${valueDict}= Convert To Integer ${setting} |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 723 | ${data}= Create Dictionary data=${valueDict} |
| 724 | Write Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot data=${data} |
| 725 | ${current_setting}= Get Auto Reboot |
| 726 | Should Be Equal As Integers ${current_setting} ${setting} |
George Keishing | 3c004dc | 2018-10-10 07:16:47 -0500 | [diff] [blame] | 727 | |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 728 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 729 | Redfish Set Auto Reboot |
| 730 | [Documentation] Set the given auto reboot setting. |
| 731 | [Arguments] ${setting} |
| 732 | |
| 733 | # Description of argument(s): |
| 734 | # setting The reboot setting, "RetryAttempts" and "Disabled". |
| 735 | |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 736 | Redfish.Patch /redfish/v1/Systems/system body={"Boot": {"AutomaticRetryConfig": "${setting}"}} |
| 737 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
George Keishing | a8cb28d | 2020-06-15 03:10:29 -0500 | [diff] [blame] | 738 | |
George Keishing | c8a6dd2 | 2020-06-12 12:01:33 -0500 | [diff] [blame] | 739 | ${current_setting}= Redfish Get Auto Reboot |
| 740 | Should Be Equal As Strings ${current_setting} ${setting} |
| 741 | |
| 742 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 743 | Set Control Boot Mode |
| 744 | [Documentation] Set given boot mode on the boot object path attribute. |
| 745 | [Arguments] ${boot_path} ${boot_mode} |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 746 | |
| 747 | # Description of argument(s): |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 748 | # boot_path Boot object path. |
| 749 | # Example: |
| 750 | # /xyz/openbmc_project/control/host0/boot |
| 751 | # /xyz/openbmc_project/control/host0/boot/one_time |
| 752 | # boot_mode Boot mode which need to be set. |
| 753 | # Example: |
| 754 | # "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular" |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 755 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 756 | ${valueDict}= Create Dictionary data=${boot_mode} |
| 757 | Write Attribute ${boot_path} BootMode data=${valueDict} |
George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 758 | |
Steven Sombar | f60cbcf | 2018-12-07 08:12:18 -0600 | [diff] [blame] | 759 | |
| 760 | Is Power On |
| 761 | [Documentation] Verify that the BMC chassis state is on. |
| 762 | ${state}= Get Power State |
| 763 | Should be equal ${state} ${1} |
| 764 | |
| 765 | |
| 766 | Is Power Off |
| 767 | [Documentation] Verify that the BMC chassis state is off. |
| 768 | ${state}= Get Power State |
| 769 | Should be equal ${state} ${0} |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 770 | |
| 771 | |
| 772 | CLI Get BMC DateTime |
| 773 | [Documentation] Returns BMC date time from date command. |
| 774 | |
| 775 | ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1 |
| 776 | [Return] ${bmc_time_via_date} |
George Keishing | 61364e5 | 2019-10-01 12:01:19 -0500 | [diff] [blame] | 777 | |
| 778 | |
| 779 | Update Root Password |
| 780 | [Documentation] Update system "root" user password. |
| 781 | [Arguments] ${openbmc_password}=${OPENBMC_PASSWORD} |
| 782 | |
| 783 | # Description of argument(s): |
| 784 | # openbmc_password The root password for the open BMC system. |
| 785 | |
| 786 | @{password}= Create List ${openbmc_password} |
| 787 | ${data}= Create Dictionary data=@{password} |
| 788 | |
| 789 | ${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN} |
| 790 | ${resp}= Post Request openbmc ${BMC_USER_URI}root/action/SetPassword |
| 791 | ... data=${data} headers=${headers} |
| 792 | Valid Value resp.status_code [${HTTP_OK}] |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 793 | |
| 794 | |
| 795 | Get Post Boot Action |
| 796 | [Documentation] Get post boot action. |
| 797 | |
George Keishing | 879f084 | 2020-02-05 11:00:47 -0600 | [diff] [blame] | 798 | # Post code update action dictionary. |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 799 | # |
| 800 | # { |
| 801 | # BMC image: { |
| 802 | # OnReset: Redfish OBMC Reboot (off), |
| 803 | # Immediate: Wait For Reboot start_boot_seconds=${state['epoch_seconds']} |
| 804 | # }, |
| 805 | # Host image: { |
George Keishing | e523fc0 | 2020-03-23 12:28:01 -0500 | [diff] [blame] | 806 | # OnReset: RF SYS GracefulRestart, |
Sushil Singh | 6624ce5 | 2020-01-22 00:53:41 -0600 | [diff] [blame] | 807 | # Immediate: Wait State os_running_match_state 10 mins |
| 808 | # } |
| 809 | # } |
| 810 | |
| 811 | ${code_base_dir_path}= Get Code Base Dir Path |
| 812 | ${post_code_update_actions}= Evaluate |
| 813 | ... json.load(open('${code_base_dir_path}data/applytime_table.json')) modules=json |
| 814 | Rprint Vars post_code_update_actions |
| 815 | |
| 816 | [Return] ${post_code_update_actions} |
| 817 | |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 818 | |
| 819 | Redfish Set Boot Default |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 820 | [Documentation] Set and Verify Boot source override |
| 821 | [Arguments] ${override_enabled} ${override_target} ${override_mode}=UEFI |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 822 | |
| 823 | # Description of argument(s): |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 824 | # override_enabled Boot source override enable type. |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 825 | # ('Once', 'Continuous', 'Disabled'). |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 826 | # override_target Boot source override target. |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 827 | # ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None'). |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 828 | # override_mode Boot source override mode (relevant only for x86 arch). |
| 829 | # ('Legacy', 'UEFI'). |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 830 | |
| 831 | ${data}= Create Dictionary BootSourceOverrideEnabled=${override_enabled} |
| 832 | ... BootSourceOverrideTarget=${override_target} |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 833 | |
| 834 | Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86' |
| 835 | ... Set To Dictionary ${data} BootSourceOverrideMode ${override_mode} |
| 836 | |
George Keishing | 1eeff9c | 2020-06-16 04:03:34 -0500 | [diff] [blame] | 837 | ${payload}= Create Dictionary Boot=${data} |
| 838 | |
| 839 | Redfish.Patch /redfish/v1/Systems/system body=&{payload} |
| 840 | ... valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}] |
| 841 | |
| 842 | ${resp}= Redfish.Get Attribute /redfish/v1/Systems/system Boot |
| 843 | Should Be Equal As Strings ${resp["BootSourceOverrideEnabled"]} ${override_enabled} |
| 844 | Should Be Equal As Strings ${resp["BootSourceOverrideTarget"]} ${override_target} |
Konstantin Aladyshev | 0043fc5 | 2021-04-15 12:07:29 +0300 | [diff] [blame] | 845 | Run Keyword If '${PLATFORM_ARCH_TYPE}' == 'x86' |
| 846 | ... Should Be Equal As Strings ${resp["BootSourceOverrideMode"]} ${override_mode} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 847 | |
| 848 | |
| 849 | # Redfish state keywords. |
| 850 | |
| 851 | Redfish Get BMC State |
| 852 | [Documentation] Return BMC health state. |
| 853 | |
| 854 | # "Enabled" -> BMC Ready, "Starting" -> BMC NotReady |
| 855 | |
| 856 | # Example: |
| 857 | # "Status": { |
| 858 | # "Health": "OK", |
| 859 | # "HealthRollup": "OK", |
| 860 | # "State": "Enabled" |
| 861 | # }, |
| 862 | |
| 863 | ${status}= Redfish.Get Attribute /redfish/v1/Managers/bmc Status |
| 864 | [Return] ${status["State"]} |
| 865 | |
| 866 | |
| 867 | Redfish Get Host State |
| 868 | [Documentation] Return host power and health state. |
| 869 | |
| 870 | # Refer: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status |
| 871 | |
| 872 | # Example: |
| 873 | # "PowerState": "Off", |
| 874 | # "Status": { |
| 875 | # "Health": "OK", |
| 876 | # "HealthRollup": "OK", |
| 877 | # "State": "StandbyOffline" |
| 878 | # }, |
| 879 | |
George Keishing | b51d150 | 2021-03-25 03:30:33 -0500 | [diff] [blame] | 880 | ${chassis}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID} |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 881 | [Return] ${chassis["PowerState"]} ${chassis["Status"]["State"]} |
| 882 | |
| 883 | |
| 884 | Redfish Get Boot Progress |
| 885 | [Documentation] Return boot progress state. |
| 886 | |
| 887 | # Example: /redfish/v1/Systems/system/ |
| 888 | # "BootProgress": { |
| 889 | # "LastState": "OSRunning" |
| 890 | # }, |
| 891 | |
| 892 | ${boot_progress}= Redfish.Get Properties /redfish/v1/Systems/system/ |
George Keishing | b51d150 | 2021-03-25 03:30:33 -0500 | [diff] [blame] | 893 | |
| 894 | Return From Keyword If "${PLATFORM_ARCH_TYPE}" == "x86" |
| 895 | ... NA ${boot_progress["Status"]["State"]} |
| 896 | |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 897 | [Return] ${boot_progress["BootProgress"]["LastState"]} ${boot_progress["Status"]["State"]} |
| 898 | |
| 899 | |
| 900 | Redfish Get States |
| 901 | [Documentation] Return all the BMC and host states in dictionary. |
George Keishing | 366033f | 2021-04-01 13:49:06 -0500 | [diff] [blame] | 902 | [Timeout] 120 Seconds |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 903 | |
| 904 | # Refer: openbmc/docs/designs/boot-progress.md |
| 905 | |
George Keishing | 205f95f | 2021-03-10 02:25:53 -0600 | [diff] [blame] | 906 | Redfish.Login |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 907 | |
| 908 | ${bmc_state}= Redfish Get BMC State |
| 909 | ${chassis_state} ${chassis_status}= Redfish Get Host State |
| 910 | ${boot_progress} ${host_state}= Redfish Get Boot Progress |
| 911 | |
| 912 | ${states}= Create Dictionary |
| 913 | ... bmc=${bmc_state} |
| 914 | ... chassis=${chassis_state} |
| 915 | ... host=${host_state} |
| 916 | ... boot_progress=${boot_progress} |
| 917 | |
George Keishing | 64293c5 | 2021-03-24 08:21:23 -0500 | [diff] [blame] | 918 | # Disable loggoing state to prevent huge log.html record when boot |
| 919 | # test is run in loops. |
| 920 | #Log ${states} |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 921 | |
George Keishing | e187964 | 2020-12-09 13:20:15 -0600 | [diff] [blame] | 922 | [Return] ${states} |
George Keishing | 95cf865 | 2021-02-08 11:32:33 -0600 | [diff] [blame] | 923 | |
| 924 | |
| 925 | Is BMC Standby |
| 926 | [Documentation] Check if BMC is ready and host at standby. |
| 927 | |
| 928 | ${standby_states}= Create Dictionary |
| 929 | ... bmc=Enabled |
| 930 | ... chassis=Off |
| 931 | ... host=Disabled |
| 932 | ... boot_progress=None |
| 933 | |
| 934 | Wait Until Keyword Succeeds 3 min 10 sec Redfish Get States |
| 935 | |
| 936 | Wait Until Keyword Succeeds 1 min 10 sec Match State ${standby_states} |
| 937 | |
| 938 | |
| 939 | Match State |
| 940 | [Documentation] Check if the expected and current states are matched. |
| 941 | [Arguments] ${match_state} |
| 942 | |
| 943 | # Description of argument(s): |
| 944 | # match_state Expected states in dictionary. |
| 945 | |
| 946 | ${current_state}= Redfish Get States |
| 947 | Dictionaries Should Be Equal ${match_state} ${current_state} |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 948 | |
| 949 | |
| 950 | Redfish Initiate Auto Reboot |
| 951 | [Documentation] Initiate an auto reboot. |
| 952 | [Arguments] ${interval}=2000 |
| 953 | |
| 954 | # Description of argument(s): |
| 955 | # interval Value in milliseconds to set Watchdog interval |
| 956 | |
| 957 | # Set auto reboot policy |
| 958 | Redfish Set Auto Reboot RetryAttempts |
| 959 | |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 960 | Redfish Power Operation On |
| 961 | Sleep 30s |
| 962 | |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 963 | # Set watchdog timer |
| 964 | Set Watchdog Interval Using Busctl ${interval} |
| 965 | |
| 966 | |
| 967 | |
| 968 | Set Watchdog Interval Using Busctl |
| 969 | [Documentation] Set Watchdog time interval. |
| 970 | [Arguments] ${milliseconds}=1000 |
| 971 | |
| 972 | # Description of argument(s): |
George Keishing | 4b72949 | 2021-11-10 12:51:10 -0600 | [diff] [blame] | 973 | # milliseconds Time interval for watchdog timer |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 974 | |
George Keishing | c070110 | 2021-09-30 12:12:04 -0500 | [diff] [blame] | 975 | ${cmd}= Catenate busctl set-property xyz.openbmc_project.Watchdog |
| 976 | ... /xyz/openbmc_project/watchdog/host0 |
| 977 | ... xyz.openbmc_project.State.Watchdog Interval t ${milliseconds} |
Peter D Phan | 49739b2 | 2021-09-29 14:30:08 -0500 | [diff] [blame] | 978 | BMC Execute Command ${cmd} |
| 979 | |