Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../lib/resource.txt |
| 3 | Resource ../lib/rest_client.robot |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 4 | Resource ../lib/connection_client.robot |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 5 | Library DateTime |
| 6 | Library Process |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 7 | Library OperatingSystem |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 8 | Library gen_print.py |
| 9 | Library gen_robot_print.py |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 10 | |
| 11 | *** Variables *** |
| 12 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 13 | ${dbuscmdBase} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 14 | ... dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 15 | ${dbuscmdGet} |
George Keishing | 9485af9 | 2017-01-04 10:21:43 -0600 | [diff] [blame] | 16 | ... ${SETTINGS_URI}host0 org.freedesktop.DBus.Properties.Get |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 17 | # Enable when ready with openbmc/openbmc-test-automation#203 |
| 18 | #${dbuscmdString}= string:"xyz.openbmc_project.settings.Host" string: |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 19 | ${dbuscmdString}= string:"org.openbmc.settings.Host" string: |
| 20 | |
| 21 | # Assign default value to QUIET for programs which may not define it. |
| 22 | ${QUIET} ${0} |
Sivas SRR | ea85d1f | 2016-11-13 22:44:28 -0600 | [diff] [blame] | 23 | ${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4 |
| 24 | ${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2 |
| 25 | ${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9 |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 26 | ${HOST_SETTING} ${SETTINGS_URI}host0 |
Sivas SRR | 352bc16 | 2017-02-13 22:12:29 -0600 | [diff] [blame] | 27 | # /run/initramfs/ro associate filesystem should be 100% full always |
Sivas SRR | aca5571 | 2016-12-21 04:32:35 -0600 | [diff] [blame] | 28 | ${bmc_file_system_usage_cmd}= |
Sivas SRR | 352bc16 | 2017-02-13 22:12:29 -0600 | [diff] [blame] | 29 | ... df -h | grep -v /run/initramfs/ro | cut -c 52-54 | grep 100 | wc -l |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 30 | |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 31 | ${BOOT_TIME} ${0} |
| 32 | ${BOOT_COUNT} ${0} |
Sweta Potthuri | 025e012 | 2017-02-21 00:42:48 -0600 | [diff] [blame] | 33 | ${count} ${0} |
Sivas SRR | 8254db6 | 2017-02-07 09:39:46 -0600 | [diff] [blame] | 34 | ${devicetree_base} /sys/firmware/devicetree/base/model |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 35 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 36 | *** Keywords *** |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 37 | |
Sivas SRR | 8254db6 | 2017-02-07 09:39:46 -0600 | [diff] [blame] | 38 | Get BMC System Model |
| 39 | [Documentation] Get the BMC model from the device tree. |
| 40 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 41 | Open Connection And Log In |
George Keishing | 90ab177 | 2017-02-24 05:40:55 -0600 | [diff] [blame] | 42 | ${bmc_model} ${stderr}= Execute Command |
| 43 | ... cat ${devicetree_base} | cut -d " " -f 1 return_stderr=True |
Sivas SRR | 8254db6 | 2017-02-07 09:39:46 -0600 | [diff] [blame] | 44 | Should Be Empty ${stderr} |
| 45 | Should Not Be Empty ${bmc_model} |
| 46 | [Return] ${bmc_model} |
| 47 | |
| 48 | Verify BMC System Model |
| 49 | [Documentation] Verify the BMC model with ${OPENBMC_MODEL}. |
| 50 | [Arguments] ${bmc_model} |
| 51 | |
| 52 | ${tmp_bmc_model}= Fetch From Right ${OPENBMC_MODEL} / |
| 53 | ${tmp_bmc_model}= Fetch From Left ${tmp_bmc_model} . |
| 54 | ${ret}= Run Keyword And Return Status Should Contain ${bmc_model} |
| 55 | ... ${tmp_bmc_model} ignore_case=True |
| 56 | [Return] ${ret} |
| 57 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 58 | Wait For Host To Ping |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 59 | [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min |
| 60 | ... ${interval}=5 sec |
| 61 | |
| 62 | # host The DNS name or IP of the host to ping. |
| 63 | # timeout The amount of time after which attempts to ping cease. |
| 64 | # interval The amount of time in between attempts to ping. |
| 65 | |
| 66 | Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 67 | |
| 68 | Ping Host |
| 69 | [Arguments] ${host} |
George Keishing | 8a84f95 | 2016-08-25 04:54:53 -0500 | [diff] [blame] | 70 | Should Not Be Empty ${host} msg=No host provided |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 71 | ${RC} ${output}= Run and return RC and Output ping -c 4 ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 72 | Log RC: ${RC}\nOutput:\n${output} |
| 73 | Should be equal ${RC} ${0} |
| 74 | |
| 75 | Get Boot Progress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 76 | [Arguments] ${quiet}=${QUIET} |
| 77 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 78 | ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 79 | ... value quiet=${quiet} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 80 | [Return] ${state} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 81 | |
| 82 | Is Power On |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 83 | ${state}= Get Power State |
| 84 | Should be equal ${state} ${1} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 85 | |
| 86 | Is Power Off |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 87 | ${state}= Get Power State |
| 88 | Should be equal ${state} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 89 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 90 | Initiate Power On |
| 91 | [Documentation] Initiates the power on and waits until the Is Power On |
| 92 | ... keyword returns that the power state has switched to on. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 93 | [Arguments] ${wait}=${1} |
| 94 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 95 | @{arglist}= Create List |
| 96 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 97 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 98 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 99 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 100 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 101 | # Does caller want to wait for power on status? |
| 102 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 103 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 104 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 105 | Initiate Power Off |
| 106 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 107 | ... keyword returns that the power state has switched to off. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 108 | @{arglist}= Create List |
| 109 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 110 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 111 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 112 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 113 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 114 | |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 115 | Initiate OS Host Power Off |
| 116 | [Documentation] Initiate an OS reboot. |
| 117 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 118 | ... ${os_password}=${OS_PASSWORD} |
| 119 | |
| 120 | # Description of arguments: |
| 121 | # os_host The DNS name or IP of the OS. |
| 122 | # os_username The username to be used to sign in to the OS. |
| 123 | # os_password The password to be used to sign in to the OS. |
| 124 | |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 125 | SSHLibrary.Open connection ${os_host} |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 126 | Login ${os_username} ${os_password} |
| 127 | ${cmd_buf} Catenate shutdown |
| 128 | Start Command ${cmd_buf} |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 129 | SSHLibrary.Close Connection |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 130 | |
| 131 | Initiate OS Host Reboot |
| 132 | [Documentation] Initiate an OS reboot. |
| 133 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 134 | ... ${os_password}=${OS_PASSWORD} |
| 135 | |
| 136 | # Description of arguments: |
| 137 | # os_host The DNS name or IP of the OS. |
| 138 | # os_username The username to be used to sign in to the OS. |
| 139 | # os_password The password to be used to sign in to the OS. |
| 140 | |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 141 | SSHLibrary.Open connection ${os_host} |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 142 | Login ${os_username} ${os_password} |
| 143 | ${cmd_buf} Catenate reboot |
| 144 | Start Command ${cmd_buf} |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 145 | SSHLibrary.Close Connection |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 146 | |
| 147 | Initiate Auto Reboot |
| 148 | [Documentation] Initiate an auto reboot. |
| 149 | |
| 150 | # Set the auto reboot policy. |
| 151 | Set Auto Reboot yes |
| 152 | |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 153 | SSHLibrary.Open connection ${openbmc_host} |
Michael Walsh | 8184377 | 2017-03-02 14:44:44 -0600 | [diff] [blame] | 154 | Login ${openbmc_username} ${openbmc_password} |
| 155 | |
| 156 | # Set the watchdog timer. Note: 5000 = milliseconds which is 5 seconds. |
| 157 | ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0 |
| 158 | ... org.openbmc.Watchdog set i 5000 |
| 159 | ${output} ${stderr} ${rc}= Execute Command ${cmd_buf} |
| 160 | ... return_stderr=True return_rc=True |
| 161 | Should Be Empty ${stderr} |
| 162 | Should be equal ${rc} ${0} |
| 163 | |
| 164 | # Start the watchdog. |
| 165 | ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0 |
| 166 | ... org.openbmc.Watchdog start |
| 167 | ${output} ${stderr} ${rc}= Execute Command ${cmd_buf} |
| 168 | ... return_stderr=True return_rc=True |
| 169 | Should Be Empty ${stderr} |
| 170 | Should be equal ${rc} ${0} |
| 171 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 172 | Trigger Warm Reset |
| 173 | log to console "Triggering warm reset" |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 174 | ${data}= create dictionary data=@{EMPTY} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 175 | ${resp}= openbmc post request |
| 176 | ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 177 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 178 | ${session_active}= Check If warmReset is Initiated |
| 179 | Run Keyword If '${session_active}' == '${True}' |
| 180 | ... Fail msg=warm reset didn't occur |
| 181 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 182 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
Rahul Maheshwari | 5f253c4 | 2017-01-30 05:19:51 -0600 | [diff] [blame] | 183 | Check If BMC Is Up |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 184 | |
| 185 | Check OS |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 186 | [Documentation] Attempts to ping the host OS and then checks that the host |
| 187 | ... OS is up by running an SSH command. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 188 | |
| 189 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 190 | ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET} |
| 191 | ... ${print_string}=${EMPTY} |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 192 | [Teardown] SSHLibrary.Close Connection |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 193 | |
| 194 | # os_host The DNS name/IP of the OS host associated with our BMC. |
| 195 | # os_username The username to be used to sign on to the OS host. |
| 196 | # os_password The password to be used to sign on to the OS host. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 197 | # quiet Indicates whether this keyword should write to console. |
| 198 | # print_string A string to be printed before checking the OS. |
| 199 | |
| 200 | rprint ${print_string} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 201 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 202 | # Attempt to ping the OS. Store the return code to check later. |
| 203 | ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host} |
| 204 | |
Michael Walsh | ac27551 | 2017-03-07 11:39:28 -0600 | [diff] [blame] | 205 | SSHLibrary.Open connection ${os_host} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 206 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 207 | ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username} |
| 208 | ... ${os_password} |
| 209 | ${err_msg1}= Sprint Error ${msg} |
| 210 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 211 | Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 212 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 213 | ... return_rc=True |
| 214 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 215 | ${temp_msg}= Catenate Could not execute a command on the operating |
| 216 | ... system.\n |
| 217 | ${err_msg1}= Sprint Error ${temp_msg} |
| 218 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 219 | |
| 220 | # If the return code returned by "Execute Command" is non-zero, this |
| 221 | # keyword will fail. |
| 222 | Should Be Equal ${rc} ${0} msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 223 | # We will likewise fail if there is any stderr data. |
| 224 | Should Be Empty ${stderr} |
| 225 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 226 | ${temp_msg}= Set Variable Could not ping the operating system.\n |
| 227 | ${err_msg1}= Sprint Error ${temp_msg} |
| 228 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 229 | # We will likewise fail if the OS did not ping, as we could SSH but not |
| 230 | # ping |
| 231 | Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 232 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 233 | Wait for OS |
| 234 | [Documentation] Waits for the host OS to come up via calls to "Check OS". |
| 235 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 236 | ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 237 | ... ${quiet}=${0} |
| 238 | [Teardown] rprintn |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 239 | |
| 240 | # os_host The DNS name or IP of the OS host associated with our |
| 241 | # BMC. |
| 242 | # os_username The username to be used to sign on to the OS host. |
| 243 | # os_password The password to be used to sign on to the OS host. |
| 244 | # timeout The timeout in seconds indicating how long you're |
| 245 | # willing to wait for the OS to respond. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 246 | # quiet Indicates whether this keyword should write to console. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 247 | |
| 248 | # The interval to be used between calls to "Check OS". |
| 249 | ${interval}= Set Variable 5 |
| 250 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 251 | ${message}= Catenate Checking every ${interval} seconds for up to |
| 252 | ... ${timeout} seconds for the operating system to communicate. |
| 253 | rqprint_timen ${message} |
| 254 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 255 | Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS |
| 256 | ... ${os_host} ${os_username} ${os_password} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 257 | ... print_string=\# |
| 258 | |
| 259 | rqprintn |
| 260 | |
| 261 | rqprint_timen The operating system is now communicating. |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 262 | |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 263 | Get BMC State Deprecated |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 264 | [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY) |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 265 | [Arguments] ${quiet}=${QUIET} |
| 266 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 267 | @{arglist}= Create List |
| 268 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 269 | ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 270 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 271 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 272 | ${content}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 273 | [Return] ${content["data"]} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 274 | |
| 275 | Get Power State |
| 276 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 277 | [Arguments] ${quiet}=${QUIET} |
| 278 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 279 | @{arglist}= Create List |
| 280 | ${args}= Create Dictionary data=@{arglist} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 281 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 282 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 283 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 284 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 285 | ${content}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 286 | [Return] ${content["data"]} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 287 | |
| 288 | Clear BMC Record Log |
| 289 | [Documentation] Clears all the event logs on the BMC. This would be |
| 290 | ... equivalent to ipmitool sel clear. |
| 291 | @{arglist}= Create List |
| 292 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 293 | ${resp}= Call Method |
| 294 | ... ${OPENBMC_BASE_URI}records/events/ clear data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 295 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 296 | |
| 297 | Copy PNOR to BMC |
| 298 | Import Library SCPLibrary WITH NAME scp |
| 299 | Open Connection for SCP |
| 300 | Log Copying ${PNOR_IMAGE_PATH} to /tmp |
| 301 | scp.Put File ${PNOR_IMAGE_PATH} /tmp |
| 302 | |
| 303 | Flash PNOR |
| 304 | [Documentation] Calls flash bios update method to flash PNOR image |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 305 | [Arguments] ${pnor_image} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 306 | @{arglist}= Create List ${pnor_image} |
| 307 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 308 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 309 | ... data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 310 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 311 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 312 | |
| 313 | Get Flash BIOS Status |
| 314 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 315 | ... example 'Flashing', 'Flash Done', etc |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 316 | ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 317 | [Return] ${data['status']} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 318 | |
| 319 | Is PNOR Flashing |
| 320 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 321 | ... flashing has started. |
| 322 | ${status}= Get Flash BIOS Status |
Rahul Maheshwari | 449dfb7 | 2017-05-08 02:06:48 -0500 | [diff] [blame] | 323 | Should Contain ${status} Flashing |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 324 | |
| 325 | Is PNOR Flash Done |
| 326 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 327 | ... PNOR flashing has completed. |
Leah McNutt | 9ba3227 | 2016-11-17 15:48:39 +0000 | [diff] [blame] | 328 | ${status}= Get Flash BIOS Status |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 329 | should be equal as strings ${status} Flash Done |
| 330 | |
| 331 | Is System State Host Booted |
| 332 | [Documentation] Checks whether system state is HOST_BOOTED. |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 333 | ${state}= Get BMC State Deprecated |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 334 | should be equal as strings ${state} HOST_BOOTED |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 335 | |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 336 | Is OS Starting |
| 337 | [Documentation] Check if boot progress is OS starting. |
| 338 | ${boot_progress}= Get Boot Progress |
| 339 | Should Be Equal ${boot_progress} FW Progress, Starting OS |
| 340 | |
George Keishing | 0af2441 | 2017-03-10 13:33:23 -0600 | [diff] [blame] | 341 | Is OS Off |
| 342 | [Documentation] Check if boot progress is "Off". |
| 343 | ${boot_progress}= Get Boot Progress |
| 344 | Should Be Equal ${boot_progress} Off |
| 345 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 346 | Verify Ping and REST Authentication |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 347 | ${l_ping}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 348 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 349 | Run Keyword If '${l_ping}' == '${False}' |
| 350 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 351 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 352 | ${l_rest}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 353 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 354 | Run Keyword If '${l_rest}' == '${False}' |
| 355 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 356 | |
| 357 | # Just to make sure the SSH is working for SCP |
| 358 | Open Connection And Log In |
| 359 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 360 | Should Be Empty ${stderr} |
| 361 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 362 | Check If BMC is Up |
| 363 | [Documentation] Wait for Host to be online. Checks every X seconds |
| 364 | ... interval for Y minutes and fails if timed out. |
| 365 | ... Default MAX timedout is 10 min, interval 10 seconds. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 366 | [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 367 | ... ${interval}=10 sec |
| 368 | |
| 369 | Wait Until Keyword Succeeds |
| 370 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 371 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 372 | |
| 373 | Check If warmReset is Initiated |
| 374 | [Documentation] Ping would be still alive, so try SSH to connect |
| 375 | ... if fails the ports are down indicating reboot |
| 376 | ... is in progress |
George Keishing | 3c05d35 | 2016-12-13 06:54:50 -0600 | [diff] [blame] | 377 | |
| 378 | # Warm reset adds 3 seconds delay before forcing reboot |
| 379 | # To minimize race conditions, we wait for 7 seconds |
| 380 | Sleep 7s |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 381 | ${alive}= Run Keyword and Return Status |
| 382 | ... Open Connection And Log In |
| 383 | Return From Keyword If '${alive}' == '${False}' ${False} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 384 | [Return] ${True} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 385 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 386 | Flush REST Sessions |
| 387 | [Documentation] Removes all the active session objects |
| 388 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 389 | |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 390 | Initialize DBUS cmd |
| 391 | [Documentation] Initialize dbus string with property string to extract |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 392 | [Arguments] ${boot_property} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 393 | ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString} |
| 394 | ${cmd}= Catenate ${cmd}${boot_property} |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 395 | Set Global Variable ${dbuscmd} ${cmd} |
| 396 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 397 | Create OS Console File Path |
| 398 | [Documentation] Create OS console file path name and return it. |
| 399 | [Arguments] ${log_file_path}=${EMPTY} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 400 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 401 | # Description of arguements: |
| 402 | # file_path The caller's candidate value. If this value is ${EMPTY}, this |
| 403 | # keyword will compose a file path name. Otherwise, this |
| 404 | # keyword will use the caller's file_path value. In either |
| 405 | # case, the value will be returned. |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 406 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 407 | ${default_file_path}= Catenate /tmp/${OPENBMC_HOST}_os_console |
| 408 | ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}' |
| 409 | ... ${default_file_path} ${log_file_path} |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 410 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 411 | [Return] ${log_file_path} |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 412 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 413 | Create OS Console Command String |
| 414 | [Documentation] Return a command string to start OS console logging. |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 415 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 416 | # First make sure that the ssh_pw program is available. |
| 417 | ${cmd_buf}= Catenate which ssh_pw 2>&1 |
| 418 | Rdpissuing ${cmd_buf} |
| 419 | ${rc} ${output}= Run And Return Rc And Output ${cmd_buf} |
| 420 | Rdpvars rc output |
| 421 | Should Be Equal ${rc} ${0} msg=${output}\n |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 422 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 423 | ${cmd_buf}= Catenate ssh_pw ${OPENBMC_PASSWORD} -p 2200 |
| 424 | ... ${OPENBMC_USERNAME}@${OPENBMC_HOST} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 425 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 426 | [Return] ${cmd_buf} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 427 | |
| 428 | Stop SOL Console Logging |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 429 | [Documentation] Stop system console logging and return log output. |
| 430 | [Arguments] ${log_file_path}=${EMPTY} ${targ_file_path}=${EMPTY} |
| 431 | |
| 432 | # If there are muliple system console processes, they will all be stopped. |
| 433 | # If there is no existing log file this keyword will return an error |
| 434 | # message to that effect (and write that message to targ_file_path, if |
| 435 | # specified). |
| 436 | # NOTE: This keyword will not fail if there is no running system console |
| 437 | # process. |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 438 | |
| 439 | # Description of arguments: |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 440 | # log_file_path The file path that was used to call "Start SOL |
| 441 | # Console Logging". See that keyword (above) for details. |
| 442 | # targ_file_path If specified, the file path to which the source |
| 443 | # file path (i.e. "log_file_path") should be copied. |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 444 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 445 | ${log_file_path}= Create OS Console File Path ${log_file_path} |
| 446 | # Find the pid of the active system console logging session (if any). |
| 447 | ${search_string}= Create OS Console Command String |
| 448 | ${cmd_buf}= Catenate echo $(ps -ef | egrep '${search_string}' |
| 449 | ... | egrep -v grep | cut -c10-14) |
| 450 | Rdpissuing ${cmd_buf} |
| 451 | ${rc} ${os_con_pid}= Run And Return Rc And Output ${cmd_buf} |
| 452 | Rdpvars os_con_pid |
| 453 | # If rc is not zero it just means that there is no OS Console process |
| 454 | # running. |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 455 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 456 | ${cmd_buf}= Catenate kill -9 ${os_con_pid} |
| 457 | Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpissuing ${cmd_buf} |
| 458 | ${rc} ${output}= Run Keyword If '${os_con_pid}' != '${EMPTY}' |
| 459 | ... Run And Return Rc And Output ${cmd_buf} |
| 460 | Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpvars rc output |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 461 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 462 | ${cmd_buf}= Set Variable cat ${log_file_path} 2>&1 |
| 463 | Rdpissuing ${cmd_buf} |
| 464 | ${rc} ${output}= Run And Return Rc And Output ${cmd_buf} |
| 465 | Rdpvars rc |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 466 | |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 467 | Run Keyword If '${targ_file_path}' != '${EMPTY}' |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 468 | ... Run Keyword And Ignore Error |
| 469 | ... Copy File ${log_file_path} ${targ_file_path} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 470 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 471 | [Return] ${output} |
| 472 | |
| 473 | Start SOL Console Logging |
| 474 | [Documentation] Start system console log to file. |
| 475 | [Arguments] ${log_file_path}=${EMPTY} |
| 476 | |
| 477 | # This keyword will first call "Stop SOL Console Logging". Only then will |
| 478 | # it start SOL console logging. The data returned by "Stop SOL Console |
| 479 | # Logging" will in turn be returned by this keyword. |
| 480 | |
| 481 | # Description of arguments: |
| 482 | # log_file_path The file path to which system console log data should be |
| 483 | # written. Note that this path is taken to be a location on |
| 484 | # the machine where this program is running rather than on |
| 485 | # the Open BMC system. |
| 486 | |
| 487 | ${log_file_path}= Create OS Console File Path ${log_file_path} |
| 488 | |
| 489 | ${log_output}= Stop SOL Console Logging ${log_file_path} |
| 490 | |
| 491 | # Validate by making sure we can create the file. Problems creating the |
| 492 | # file would not be noticed by the subsequent ssh command because we fork |
| 493 | # the command. |
| 494 | Create File ${log_file_path} |
| 495 | ${sub_cmd_buf}= Create OS Console Command String |
| 496 | # Routing stderr to stdout so that any startup error text will go to the |
| 497 | # output file. |
| 498 | ${cmd_buf}= Catenate ${sub_cmd_buf} > ${log_file_path} 2>&1 & |
| 499 | Rdpissuing ${cmd_buf} |
| 500 | ${rc} ${output}= Run And Return Rc And Output ${cmd_buf} |
| 501 | # Because we are forking this command, we essentially will never get a |
| 502 | # non-zero return code or any output. |
| 503 | Should Be Equal ${rc} ${0} |
| 504 | |
| 505 | [Return] ${log_output} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 506 | |
| 507 | Get Time Stamp |
| 508 | [Documentation] Get the current time stamp data |
| 509 | ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 510 | [Return] ${cur_time} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 511 | |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 512 | |
| 513 | Verify BMC State |
| 514 | [Documentation] Get the BMC state and verify if the current |
| 515 | ... BMC state is as expected. |
| 516 | [Arguments] ${expected} |
| 517 | |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 518 | ${current}= Get BMC State Deprecated |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 519 | Should Contain ${expected} ${current} |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 520 | |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 521 | Start Journal Log |
| 522 | [Documentation] Start capturing journal log to a file in /tmp using |
| 523 | ... journalctl command. By default journal log is collected |
| 524 | ... at /tmp/journal_log else user input location. |
| 525 | ... The File is appended with datetime. |
| 526 | [Arguments] ${file_path}=/tmp/journal_log |
| 527 | |
| 528 | Open Connection And Log In |
| 529 | |
| 530 | ${cur_time}= Get Time Stamp |
| 531 | Set Global Variable ${LOG_TIME} ${cur_time} |
| 532 | Start Command |
| 533 | ... journalctl -f > ${file_path}-${LOG_TIME} |
| 534 | Log Journal Log Started: ${file_path}-${LOG_TIME} |
| 535 | |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 536 | |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 537 | Stop Journal Log |
| 538 | [Documentation] Stop journalctl process if its running. |
| 539 | ... By default return log from /tmp/journal_log else |
| 540 | ... user input location. |
| 541 | [Arguments] ${file_path}=/tmp/journal_log |
| 542 | |
| 543 | Open Connection And Log In |
| 544 | |
| 545 | ${rc}= |
| 546 | ... Execute Command |
| 547 | ... ps ax | grep journalctl | grep -v grep |
| 548 | ... return_stdout=False return_rc=True |
| 549 | |
| 550 | Return From Keyword If '${rc}' == '${1}' |
| 551 | ... No journal log process running |
| 552 | |
| 553 | ${output} ${stderr}= |
| 554 | ... Execute Command killall journalctl |
| 555 | ... return_stderr=True |
| 556 | Should Be Empty ${stderr} |
| 557 | |
| 558 | ${journal_log} ${stderr}= |
| 559 | ... Execute Command |
| 560 | ... cat ${file_path}-${LOG_TIME} |
| 561 | ... return_stderr=True |
| 562 | Should Be Empty ${stderr} |
| 563 | |
| 564 | Log ${journal_log} |
| 565 | |
| 566 | Execute Command rm ${file_path}-${LOG_TIME} |
| 567 | |
| 568 | [Return] ${journal_log} |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 569 | |
| 570 | Mac Address To Hex String |
| 571 | [Documentation] Converts MAC address into hex format. |
| 572 | ... Example |
| 573 | ... Given the following MAC: 00:01:6C:80:02:78 |
| 574 | ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78 |
| 575 | ... Description of arguments: |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 576 | ... i_macaddress MAC address in the following format |
| 577 | ... 00:01:6C:80:02:78 |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 578 | [Arguments] ${i_macaddress} |
| 579 | |
| 580 | ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 581 | [Return] ${mac_hex} |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 582 | |
| 583 | IP Address To Hex String |
| 584 | [Documentation] Converts IP address into hex format. |
| 585 | ... Example: |
| 586 | ... Given the following IP: 10.3.164.100 |
| 587 | ... This keyword will return: 0xa 0x3 0xa4 0xa0 |
| 588 | ... Description of arguments: |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 589 | ... i_ipaddress IP address in the following format |
| 590 | ... 10.10.10.10 |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 591 | [Arguments] ${i_ipaddress} |
| 592 | |
| 593 | @{ip}= Split String ${i_ipaddress} . |
| 594 | ${index}= Set Variable ${0} |
| 595 | |
| 596 | :FOR ${item} IN @{ip} |
| 597 | \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes |
| 598 | \ Set List Value ${ip} ${index} ${hex} |
| 599 | \ ${index}= Set Variable ${index + 1} |
| 600 | ${ip_hex}= Catenate @{ip} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 601 | [Return] ${ip_hex} |
Sivas SRR | ea85d1f | 2016-11-13 22:44:28 -0600 | [diff] [blame] | 602 | |
| 603 | BMC CPU Performance Check |
| 604 | [Documentation] Minimal 10% of proc should be free in this instance |
| 605 | |
| 606 | ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd} |
| 607 | ... return_stderr=True |
| 608 | Should be empty ${stderr} |
| 609 | ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} % |
| 610 | Should be true ${bmc_cpu_percentage} < 90 |
| 611 | |
| 612 | BMC Mem Performance Check |
| 613 | [Documentation] Minimal 10% of memory should be free in this instance |
| 614 | |
| 615 | ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd} |
| 616 | ... return_stderr=True |
| 617 | Should be empty ${stderr} |
| 618 | |
| 619 | ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd} |
| 620 | ... return_stderr=True |
| 621 | Should be empty ${stderr} |
| 622 | |
| 623 | ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100 |
| 624 | ${bmc_mem_percentage}= Evaluate |
| 625 | ... ${bmc_mem_percentage}/${bmc_mem_total_output} |
| 626 | Should be true ${bmc_mem_percentage} > 10 |
| 627 | |
Sivas SRR | aca5571 | 2016-12-21 04:32:35 -0600 | [diff] [blame] | 628 | BMC File System Usage Check |
| 629 | [Documentation] Check the file system space. None should be 100% full |
Sivas SRR | 352bc16 | 2017-02-13 22:12:29 -0600 | [diff] [blame] | 630 | ... except /run/initramfs/ro |
Sivas SRR | aca5571 | 2016-12-21 04:32:35 -0600 | [diff] [blame] | 631 | ${bmc_fs_usage_output} ${stderr}= Execute Command |
| 632 | ... ${bmc_file_system_usage_cmd} return_stderr=True |
| 633 | Should Be Empty ${stderr} |
| 634 | Should Be True ${bmc_fs_usage_output}==0 |
| 635 | |
Sivas SRR | ea85d1f | 2016-11-13 22:44:28 -0600 | [diff] [blame] | 636 | Check BMC CPU Performance |
| 637 | [Documentation] Minimal 10% of proc should be free in 3 sample |
| 638 | :FOR ${var} IN Range 1 4 |
| 639 | \ BMC CPU Performance check |
| 640 | |
| 641 | Check BMC Mem Performance |
| 642 | [Documentation] Minimal 10% of memory should be free |
| 643 | |
| 644 | :FOR ${var} IN Range 1 4 |
| 645 | \ BMC Mem Performance check |
| 646 | |
Sivas SRR | aca5571 | 2016-12-21 04:32:35 -0600 | [diff] [blame] | 647 | Check BMC File System Performance |
| 648 | [Documentation] Check for file system usage for 4 times |
| 649 | |
| 650 | :FOR ${var} IN Range 1 4 |
| 651 | \ BMC File System Usage check |
| 652 | |
Rahul Maheshwari | 9a8d3b1 | 2016-12-05 04:06:16 -0600 | [diff] [blame] | 653 | Get Endpoint Paths |
| 654 | [Documentation] Returns all url paths ending with given endpoint |
| 655 | ... Example: |
| 656 | ... Given the following endpoint: cpu |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 657 | ... This keyword will return: list of all urls ending with |
| 658 | ... cpu - |
Rahul Maheshwari | 9a8d3b1 | 2016-12-05 04:06:16 -0600 | [diff] [blame] | 659 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu0, |
| 660 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu1 |
| 661 | ... Description of arguments: |
| 662 | ... path URL path for enumeration |
| 663 | ... endpoint string for which url path ending |
| 664 | [Arguments] ${path} ${endpoint} |
| 665 | |
| 666 | ${resp}= Read Properties ${path}/enumerate timeout=30 |
| 667 | log Dictionary ${resp} |
| 668 | |
| 669 | ${list}= Get Dictionary Keys ${resp} |
| 670 | ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$ |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 671 | [Return] ${resp} |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 672 | |
| 673 | Check Zombie Process |
| 674 | [Documentation] Check if any defunct process exist or not on BMC |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 675 | ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 676 | ... return_stderr=True return_rc=True |
| 677 | Should Be True ${count}==0 |
| 678 | Should Be Empty ${stderr} |
George Keishing | 5327d01 | 2016-12-08 08:43:29 -0600 | [diff] [blame] | 679 | |
| 680 | Prune Journal Log |
| 681 | [Documentation] Prune archived journal logs. |
| 682 | [Arguments] ${vacuum_size}=1M |
| 683 | |
| 684 | # This keyword can be used to prevent the journal |
| 685 | # log from filling up the /run filesystem. |
| 686 | # This command will retain only the latest logs |
| 687 | # of the user specified size. |
| 688 | |
| 689 | Open Connection And Log In |
| 690 | ${output} ${stderr} ${rc}= |
| 691 | ... Execute Command |
| 692 | ... journalctl --vacuum-size=${vacuum_size} |
| 693 | ... return_stderr=True return_rc=True |
| 694 | |
| 695 | Should Be Equal ${rc} ${0} msg=${stderr} |
Sridevi Ramesh | 1699d37 | 2016-12-06 00:20:22 -0600 | [diff] [blame] | 696 | |
| 697 | Set BMC Power Policy |
| 698 | [Documentation] Set the given BMC power policy. |
| 699 | [arguments] ${policy} |
| 700 | |
| 701 | ${valueDict}= create dictionary data=${policy} |
| 702 | Write Attribute ${HOST_SETTING} power_policy data=${valueDict} |
| 703 | ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy |
| 704 | Should Be Equal ${currentPolicy} ${policy} |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 705 | |
George Keishing | 4d6f3d6 | 2017-02-06 09:50:41 -0600 | [diff] [blame] | 706 | Get System Power Policy |
| 707 | [Documentation] Get the BMC power policy. |
| 708 | ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy |
| 709 | [Return] ${currentPolicy} |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 710 | |
Rahul Maheshwari | 1cbf004 | 2017-02-13 05:17:37 -0600 | [diff] [blame] | 711 | Get Auto Reboot |
| 712 | [Documentation] Returns auto reboot setting. |
Sridevi Ramesh | 4dbe659 | 2017-04-06 01:47:52 -0500 | [diff] [blame] | 713 | ${setting}= Read Attribute ${HOST_SETTING} auto_reboot |
Rahul Maheshwari | 1cbf004 | 2017-02-13 05:17:37 -0600 | [diff] [blame] | 714 | [Return] ${setting} |
| 715 | |
| 716 | |
| 717 | Set Auto Reboot |
| 718 | [Documentation] Set the given auto reboot setting. |
| 719 | [Arguments] ${setting} |
| 720 | # setting auto reboot's setting, i.e. yes or no |
| 721 | |
| 722 | ${valueDict}= Set Variable ${setting} |
| 723 | ${data}= Create Dictionary data=${valueDict} |
Sridevi Ramesh | 4dbe659 | 2017-04-06 01:47:52 -0500 | [diff] [blame] | 724 | Write Attribute ${HOST_SETTING} auto_reboot data=${data} |
Rahul Maheshwari | 1cbf004 | 2017-02-13 05:17:37 -0600 | [diff] [blame] | 725 | ${current_setting}= Get Auto Reboot |
| 726 | Should Be Equal ${current_setting} ${setting} |
| 727 | |
| 728 | |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 729 | Set BMC Reset Reference Time |
| 730 | [Documentation] Set current boot time as a reference and increment |
George Keishing | 80dd5af | 2017-02-08 07:01:25 -0600 | [diff] [blame] | 731 | ... boot count. |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 732 | |
| 733 | ${cur_btime}= Get BMC Boot Time |
George Keishing | 80dd5af | 2017-02-08 07:01:25 -0600 | [diff] [blame] | 734 | Run Keyword If ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0} |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 735 | ... Set Global Variable ${BOOT_TIME} ${cur_btime} |
George Keishing | 80dd5af | 2017-02-08 07:01:25 -0600 | [diff] [blame] | 736 | ... ELSE IF ${cur_btime} > ${BOOT_TIME} |
| 737 | ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime} |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 738 | ... AND |
| 739 | ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1} |
| 740 | |
George Keishing | cce9df2 | 2017-01-24 06:19:33 -0600 | [diff] [blame] | 741 | Get BMC Boot Time |
| 742 | [Documentation] Get boot time from /proc/stat. |
| 743 | |
| 744 | Open Connection And Log In |
| 745 | ${output} ${stderr}= |
| 746 | ... Execute Command egrep '^btime ' /proc/stat | cut -f 2 -d ' ' |
| 747 | ... return_stderr=True |
| 748 | Should Be Empty ${stderr} |
| 749 | ${btime}= Convert To Integer ${output} |
| 750 | [Return] ${btime} |
George Keishing | ede3000 | 2017-02-02 09:33:07 -0600 | [diff] [blame] | 751 | |
George Keishing | ede3000 | 2017-02-02 09:33:07 -0600 | [diff] [blame] | 752 | Execute Command On BMC |
| 753 | [Documentation] Execute given command on BMC and return output. |
| 754 | [Arguments] ${command} |
| 755 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 756 | Should Be Empty ${stderr} |
| 757 | [Return] ${stdout} |
David Shaw | ba2d2c2 | 2017-01-23 16:56:38 -0600 | [diff] [blame] | 758 | |
Sridevi Ramesh | ea36b41 | 2017-03-09 04:08:02 -0600 | [diff] [blame] | 759 | |
George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 760 | Enable Core Dump On BMC |
| 761 | [Documentation] Enable core dump collection. |
| 762 | Open Connection And Log In |
| 763 | ${core_pattern}= Execute Command On BMC |
| 764 | ... echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern |
| 765 | Should Be Equal As Strings ${core_pattern} /tmp/core_%e.%p |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 766 | |
Sivas SRR | 01262bd | 2017-03-19 10:00:23 -0500 | [diff] [blame] | 767 | Get Number Of BMC Core Dump Files |
| 768 | [Documentation] Get number of core dump files on BMC. |
| 769 | Open Connection And Log In |
| 770 | ${num_of_core_dump}= Execute Command |
| 771 | ... ls /tmp/core* 2>/dev/null | wc -l |
| 772 | [Return] ${num_of_core_dump} |
| 773 | |
| 774 | Set Core Dump File Size Unlimited |
| 775 | [Documentation] Set core dump file size to unlimited. |
| 776 | Open Connection And Log In |
| 777 | Execute Command On BMC |
| 778 | ... ulimit -c unlimited |
| 779 | |
| 780 | Check For Core Dumps |
| 781 | [Documentation] Check for any core dumps exist. |
| 782 | ${output}= Get Number Of BMC Core Dump Files |
| 783 | Run Keyword If ${output} > 0 |
| 784 | ... Log **Warning** BMC core dump files exist level=WARN |
| 785 | |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 786 | Trigger Host Watchdog Error |
| 787 | [Documentation] Inject host watchdog error using BMC. |
| 788 | [Arguments] ${milliseconds}=1000 ${sleep_time}=5s |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 789 | # Description of argument(s): |
| 790 | # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 = |
| 791 | # 1 second). |
Rahul Maheshwari | e95622c | 2017-02-24 10:04:29 -0600 | [diff] [blame] | 792 | # sleep_time Time delay for host watchdog error to get injected. |
| 793 | # Default is 5 seconds. |
| 794 | |
| 795 | Execute Command On BMC |
| 796 | ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog set i ${milliseconds} |
| 797 | Execute Command On BMC |
| 798 | ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog start |
| 799 | Sleep ${sleep_time} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 800 | |
| 801 | Login To OS Host |
| 802 | [Documentation] Login to OS Host. |
| 803 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 804 | ... ${os_password}=${OS_PASSWORD} |
| 805 | # Desription of arguments: |
| 806 | # ${os_host} IP address of the OS Host. |
| 807 | # ${os_username} OS Host Login user name. |
| 808 | # ${os_password} OS Host Login passwrd. |
| 809 | |
| 810 | ${os_state}= Run Keyword And Return Status Ping Host ${os_host} |
| 811 | Run Keyword If '${os_state}' == 'False' |
| 812 | ... Run Keywords Initiate Host Reboot AND |
| 813 | ... Is Host Running AND |
| 814 | ... Wait for OS ${os_host} ${os_username} ${os_password} |
| 815 | |
| 816 | Open Connection ${os_host} |
Sridevi Ramesh | ea36b41 | 2017-03-09 04:08:02 -0600 | [diff] [blame] | 817 | ${resp}= Login ${os_username} ${os_password} |
| 818 | [Return] ${resp} |
Prashanth Katti | 884ee06 | 2017-03-16 05:05:03 -0500 | [diff] [blame] | 819 | |
| 820 | Configure Initial Settings |
| 821 | [Documentation] Restore old IP and route. |
| 822 | ... This keyword requires initial settings viz IP address, |
| 823 | ... Network Mask, default gatway and serial console IP and port |
| 824 | ... information which should be provided in command line. |
| 825 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 826 | [Arguments] ${host}=${OPENBMC_HOST} ${mask}=${NET_MASK} |
| 827 | ... ${gw_ip}=${GW_IP} |
Prashanth Katti | 884ee06 | 2017-03-16 05:05:03 -0500 | [diff] [blame] | 828 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 829 | # Open telnet connection and ignore the error, in case telnet session is |
| 830 | # already opened by the program calling this keyword. |
Prashanth Katti | 884ee06 | 2017-03-16 05:05:03 -0500 | [diff] [blame] | 831 | |
| 832 | Run Keyword And Ignore Error Open Telnet Connection to BMC Serial Console |
| 833 | Telnet.write ifconfig eth0 ${host} netmask ${mask} |
| 834 | Telnet.write route add default gw ${gw_ip} |
George Keishing | d05b108 | 2017-03-24 05:27:32 -0500 | [diff] [blame] | 835 | |
| 836 | Install Debug Tarball On BMC |
| 837 | [Documentation] Copy the tar file to BMC and install in "/usr/". |
| 838 | [Arguments] ${tarball_path} |
| 839 | # Description of arguments: |
| 840 | # tarball_path Absolute path of the debug tarball file. |
| 841 | # The tar file is downloaded from the build page |
| 842 | # https://openpower.xyz/job/openbmc-build/665/distro=ubuntu, |
| 843 | # target=witherspoon/artifact/images/witherspoon/ |
| 844 | # obmc-phosphor-debug-tarball-witherspoon.tar.xz |
| 845 | |
| 846 | OperatingSystem.File Should Exist ${tarball_path} |
| 847 | ... msg=${tarball_path} doesn't exist. |
| 848 | Import Library SCPLibrary WITH NAME scp |
| 849 | Open Connection for SCP |
| 850 | scp.Put File ${tarball_path} /tmp/debug-tarball.tar.xz |
| 851 | Open Connection And Log In |
| 852 | Execute Command On BMC tar -xf /tmp/debug-tarball.tar.xz -C /usr/ |
| 853 | # Remove the tarball file from BMC |
| 854 | Execute Command On BMC rm /tmp/debug-tarball.tar.xz |
| 855 | |
Sweta Potthuri | 025e012 | 2017-02-21 00:42:48 -0600 | [diff] [blame] | 856 | Get BMC Boot Count |
| 857 | [Documentation] Get BMC boot count based on boot time. |
| 858 | ${cur_btime}= Get BMC Boot Time |
| 859 | |
| 860 | # Set global variable BOOT_TIME to current boot time if current boot time |
| 861 | # is changed. Also increase value of global variable BOOT_COUNT by 1. |
| 862 | Run Keyword If ${cur_btime} > ${BOOT_TIME} |
| 863 | ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime} |
| 864 | ... AND |
| 865 | ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1} |
| 866 | [Return] ${BOOT_COUNT} |
| 867 | |
| 868 | Set BMC Boot Count |
| 869 | [Documentation] Set BMC boot count to given value. |
| 870 | [Arguments] ${count} |
| 871 | |
| 872 | # Description of arguments: |
| 873 | # count boot count value. |
| 874 | ${cur_btime}= Get BMC Boot Time |
| 875 | |
| 876 | # Set global variable BOOT_COUNT to given value. |
| 877 | Set Global Variable ${BOOT_COUNT} ${count} |
| 878 | |
| 879 | # Set BOOT_TIME variable to current boot time. |
| 880 | Set Global Variable ${BOOT_COUNT} ${count} |
Michael Walsh | 689fbbe | 2017-04-04 17:58:03 -0500 | [diff] [blame] | 881 | |
| 882 | ############################################################################### |
| 883 | Delete Error logs |
| 884 | [Documentation] Delete error logs. |
| 885 | |
| 886 | # The REST method to delete error openbmc/openbmc#1327 |
| 887 | # until then using logging restart. |
| 888 | Open Connection And Log In |
| 889 | Execute Command On BMC |
| 890 | ... systemctl restart xyz.openbmc_project.Logging.service |
| 891 | Sleep 10s reason=Wait for logging service to restart properly. |
George Keishing | db34c2f | 2017-04-18 13:20:25 -0500 | [diff] [blame] | 892 | |
| 893 | ############################################################################### |
| 894 | Delete Error log Entry |
| 895 | [Documentation] Delete error log entry. |
| 896 | [Arguments] ${entry_path} |
| 897 | |
| 898 | # Description of argument(s): |
| 899 | # entry_path Delete an error log entry. |
| 900 | # Ex. /xyz/openbmc_project/logging/entry/1 |
| 901 | |
| 902 | ${data}= Create Dictionary data=@{EMPTY} |
| 903 | ${resp}= Openbmc Delete Request ${entry_path} data=${data} |
| 904 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |