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