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