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 | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 16 | ... ${OPENBMC_BASE_URI}settings/host0 org.freedesktop.DBus.Properties.Get |
| 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 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 21 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 22 | # Assign default value to QUIET for programs which may not define it. |
| 23 | ${QUIET} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 24 | |
| 25 | *** Keywords *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 26 | Wait For Host To Ping |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 27 | [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min |
| 28 | ... ${interval}=5 sec |
| 29 | |
| 30 | # host The DNS name or IP of the host to ping. |
| 31 | # timeout The amount of time after which attempts to ping cease. |
| 32 | # interval The amount of time in between attempts to ping. |
| 33 | |
| 34 | Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 35 | |
| 36 | Ping Host |
| 37 | [Arguments] ${host} |
George Keishing | 8a84f95 | 2016-08-25 04:54:53 -0500 | [diff] [blame] | 38 | Should Not Be Empty ${host} msg=No host provided |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 39 | ${RC} ${output}= Run and return RC and Output ping -c 4 ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 40 | Log RC: ${RC}\nOutput:\n${output} |
| 41 | Should be equal ${RC} ${0} |
| 42 | |
| 43 | Get Boot Progress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 44 | [Arguments] ${quiet}=${QUIET} |
| 45 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 46 | ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 47 | ... value quiet=${quiet} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 48 | [return] ${state} |
| 49 | |
| 50 | Is Power On |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 51 | ${state}= Get Power State |
| 52 | Should be equal ${state} ${1} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 53 | |
| 54 | Is Power Off |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 55 | ${state}= Get Power State |
| 56 | Should be equal ${state} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 57 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 58 | Initiate Power On |
| 59 | [Documentation] Initiates the power on and waits until the Is Power On |
| 60 | ... keyword returns that the power state has switched to on. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 61 | [Arguments] ${wait}=${1} |
| 62 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 63 | @{arglist}= Create List |
| 64 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 65 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 66 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 67 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 68 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 69 | # Does caller want to wait for power on status? |
| 70 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 71 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 72 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 73 | Initiate Power Off |
| 74 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 75 | ... keyword returns that the power state has switched to off. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 76 | @{arglist}= Create List |
| 77 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 78 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 79 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 80 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 81 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 82 | |
| 83 | Trigger Warm Reset |
| 84 | log to console "Triggering warm reset" |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 85 | ${data}= create dictionary data=@{EMPTY} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 86 | ${resp}= openbmc post request |
| 87 | ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 88 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 89 | ${session_active}= Check If warmReset is Initiated |
| 90 | Run Keyword If '${session_active}' == '${True}' |
| 91 | ... Fail msg=warm reset didn't occur |
| 92 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 93 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 94 | Wait For Host To Ping ${OPENBMC_HOST} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 95 | |
| 96 | Check OS |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 97 | [Documentation] Attempts to ping the host OS and then checks that the host |
| 98 | ... OS is up by running an SSH command. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 99 | |
| 100 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 101 | ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET} |
| 102 | ... ${print_string}=${EMPTY} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 103 | [Teardown] Close Connection |
| 104 | |
| 105 | # os_host The DNS name/IP of the OS host associated with our BMC. |
| 106 | # os_username The username to be used to sign on to the OS host. |
| 107 | # 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] | 108 | # quiet Indicates whether this keyword should write to console. |
| 109 | # print_string A string to be printed before checking the OS. |
| 110 | |
| 111 | rprint ${print_string} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 112 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 113 | # Attempt to ping the OS. Store the return code to check later. |
| 114 | ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host} |
| 115 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 116 | Open connection ${os_host} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 117 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 118 | ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username} |
| 119 | ... ${os_password} |
| 120 | ${err_msg1}= Sprint Error ${msg} |
| 121 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 122 | Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 123 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 124 | ... return_rc=True |
| 125 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 126 | ${temp_msg}= Catenate Could not execute a command on the operating |
| 127 | ... system.\n |
| 128 | ${err_msg1}= Sprint Error ${temp_msg} |
| 129 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 130 | |
| 131 | # If the return code returned by "Execute Command" is non-zero, this |
| 132 | # keyword will fail. |
| 133 | Should Be Equal ${rc} ${0} msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 134 | # We will likewise fail if there is any stderr data. |
| 135 | Should Be Empty ${stderr} |
| 136 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 137 | ${temp_msg}= Set Variable Could not ping the operating system.\n |
| 138 | ${err_msg1}= Sprint Error ${temp_msg} |
| 139 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 140 | # We will likewise fail if the OS did not ping, as we could SSH but not |
| 141 | # ping |
| 142 | Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 143 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 144 | Wait for OS |
| 145 | [Documentation] Waits for the host OS to come up via calls to "Check OS". |
| 146 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 147 | ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 148 | ... ${quiet}=${0} |
| 149 | [Teardown] rprintn |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 150 | |
| 151 | # os_host The DNS name or IP of the OS host associated with our |
| 152 | # BMC. |
| 153 | # os_username The username to be used to sign on to the OS host. |
| 154 | # os_password The password to be used to sign on to the OS host. |
| 155 | # timeout The timeout in seconds indicating how long you're |
| 156 | # willing to wait for the OS to respond. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 157 | # quiet Indicates whether this keyword should write to console. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 158 | |
| 159 | # The interval to be used between calls to "Check OS". |
| 160 | ${interval}= Set Variable 5 |
| 161 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 162 | ${message}= Catenate Checking every ${interval} seconds for up to |
| 163 | ... ${timeout} seconds for the operating system to communicate. |
| 164 | rqprint_timen ${message} |
| 165 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 166 | Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS |
| 167 | ... ${os_host} ${os_username} ${os_password} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 168 | ... print_string=\# |
| 169 | |
| 170 | rqprintn |
| 171 | |
| 172 | rqprint_timen The operating system is now communicating. |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 173 | |
| 174 | Get BMC State |
| 175 | [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] | 176 | [Arguments] ${quiet}=${QUIET} |
| 177 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 178 | @{arglist}= Create List |
| 179 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 180 | ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 181 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 182 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 183 | ${content}= to json ${resp.content} |
| 184 | [return] ${content["data"]} |
| 185 | |
| 186 | Get Power State |
| 187 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 188 | [Arguments] ${quiet}=${QUIET} |
| 189 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 190 | @{arglist}= Create List |
| 191 | ${args}= Create Dictionary data=@{arglist} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 192 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 193 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 194 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 195 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 196 | ${content}= to json ${resp.content} |
| 197 | [return] ${content["data"]} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 198 | |
| 199 | Clear BMC Record Log |
| 200 | [Documentation] Clears all the event logs on the BMC. This would be |
| 201 | ... equivalent to ipmitool sel clear. |
| 202 | @{arglist}= Create List |
| 203 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 204 | ${resp}= Call Method |
| 205 | ... ${OPENBMC_BASE_URI}records/events/ clear data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 206 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 207 | |
| 208 | Copy PNOR to BMC |
| 209 | Import Library SCPLibrary WITH NAME scp |
| 210 | Open Connection for SCP |
| 211 | Log Copying ${PNOR_IMAGE_PATH} to /tmp |
| 212 | scp.Put File ${PNOR_IMAGE_PATH} /tmp |
| 213 | |
| 214 | Flash PNOR |
| 215 | [Documentation] Calls flash bios update method to flash PNOR image |
| 216 | [arguments] ${pnor_image} |
| 217 | @{arglist}= Create List ${pnor_image} |
| 218 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 219 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 220 | ... data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 221 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 222 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 223 | |
| 224 | Get Flash BIOS Status |
| 225 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 226 | ... example 'Flashing', 'Flash Done', etc |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 227 | ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 228 | [return] ${data['status']} |
| 229 | |
| 230 | Is PNOR Flashing |
| 231 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 232 | ... flashing has started. |
| 233 | ${status}= Get Flash BIOS Status |
| 234 | should be equal as strings ${status} Flashing |
| 235 | |
| 236 | Is PNOR Flash Done |
| 237 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 238 | ... PNOR flashing has completed. |
Leah McNutt | 9ba3227 | 2016-11-17 15:48:39 +0000 | [diff] [blame] | 239 | ${status}= Get Flash BIOS Status |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 240 | should be equal as strings ${status} Flash Done |
| 241 | |
| 242 | Is System State Host Booted |
| 243 | [Documentation] Checks whether system state is HOST_BOOTED. |
| 244 | ${state}= Get BMC State |
| 245 | should be equal as strings ${state} HOST_BOOTED |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 246 | |
| 247 | Verify Ping and REST Authentication |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 248 | ${l_ping}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 249 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 250 | Run Keyword If '${l_ping}' == '${False}' |
| 251 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 252 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 253 | ${l_rest}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 254 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 255 | Run Keyword If '${l_rest}' == '${False}' |
| 256 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 257 | |
| 258 | # Just to make sure the SSH is working for SCP |
| 259 | Open Connection And Log In |
| 260 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 261 | Should Be Empty ${stderr} |
| 262 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 263 | Check If BMC is Up |
| 264 | [Documentation] Wait for Host to be online. Checks every X seconds |
| 265 | ... interval for Y minutes and fails if timed out. |
| 266 | ... Default MAX timedout is 10 min, interval 10 seconds. |
Leah McNutt | f968950 | 2016-11-03 15:38:08 +0000 | [diff] [blame] | 267 | [arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 268 | ... ${interval}=10 sec |
| 269 | |
| 270 | Wait Until Keyword Succeeds |
| 271 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 272 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 273 | |
| 274 | Check If warmReset is Initiated |
| 275 | [Documentation] Ping would be still alive, so try SSH to connect |
| 276 | ... if fails the ports are down indicating reboot |
| 277 | ... is in progress |
| 278 | ${alive}= Run Keyword and Return Status |
| 279 | ... Open Connection And Log In |
| 280 | Return From Keyword If '${alive}' == '${False}' ${False} |
| 281 | [return] ${True} |
| 282 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 283 | Flush REST Sessions |
| 284 | [Documentation] Removes all the active session objects |
| 285 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 286 | |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 287 | Initialize DBUS cmd |
| 288 | [Documentation] Initialize dbus string with property string to extract |
| 289 | [arguments] ${boot_property} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 290 | ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString} |
| 291 | ${cmd}= Catenate ${cmd}${boot_property} |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 292 | Set Global Variable ${dbuscmd} ${cmd} |
| 293 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 294 | |
| 295 | Start SOL Console Logging |
| 296 | [Documentation] Start logging to a file in /tmp so that it can |
| 297 | ... be read by any other test cases. Stop existing |
| 298 | ... running client processes if there is any. |
| 299 | ... By default logging at /tmp/obmc-console.log else |
| 300 | ... user input location. |
| 301 | ... The File is appended with datetime and pid of |
| 302 | ... process which created this log file. |
| 303 | [Arguments] ${file_path}=/tmp/obmc-console.log |
| 304 | |
| 305 | Open Connection And Log In |
| 306 | |
| 307 | ${cur_time}= Get Time Stamp |
| 308 | Set Global Variable ${LOG_TIME} ${cur_time} |
| 309 | Start Command |
| 310 | ... obmc-console-client > ${file_path}-${LOG_TIME}_$$ |
| 311 | |
| 312 | |
| 313 | Stop SOL Console Logging |
| 314 | [Documentation] Login to BMC and Stop the obmc-console-client process. |
| 315 | ... Find the pids from the log to filter the one started by |
| 316 | ... specific test datetime and stop that process only. |
| 317 | ... Ignore if there is no process running and return message |
| 318 | ... "No obmc-console-client process running" |
| 319 | ... By default retrieving log from /tmp/obmc-console.log else |
| 320 | ... user input location. |
| 321 | [Arguments] ${file_path}=/tmp/obmc-console.log |
| 322 | |
| 323 | Open Connection And Log In |
| 324 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 325 | ${pid} ${stderr}= |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 326 | ... Execute Command |
| 327 | ... ls ${file_path}-${LOG_TIME}_* | cut -d'_' -f 2 |
| 328 | ... return_stderr=True |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 329 | Should Be Empty ${stderr} |
| 330 | |
George Keishing | d467895 | 2016-10-12 04:29:28 -0500 | [diff] [blame] | 331 | ${rc}= |
| 332 | ... Execute Command |
| 333 | ... ps ax | grep ${pid} | grep -v grep |
| 334 | ... return_stdout=False return_rc=True |
| 335 | |
| 336 | Return From Keyword If '${rc}' == '${1}' |
| 337 | ... No obmc-console-client process running |
| 338 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 339 | ${console} ${stderr}= |
| 340 | ... Execute Command kill -s KILL ${pid} |
| 341 | ... return_stderr=True |
| 342 | Should Be Empty ${stderr} |
George Keishing | d467895 | 2016-10-12 04:29:28 -0500 | [diff] [blame] | 343 | Log Current Client PID:${pid} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 344 | |
| 345 | ${console} ${stderr}= |
| 346 | ... Execute Command |
| 347 | ... cat ${file_path}-${LOG_TIME}_${pid} |
| 348 | ... return_stderr=True |
| 349 | Should Be Empty ${stderr} |
| 350 | |
| 351 | [Return] ${console} |
| 352 | |
| 353 | |
| 354 | Get Time Stamp |
| 355 | [Documentation] Get the current time stamp data |
| 356 | ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 357 | [return] ${cur_time} |
| 358 | |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 359 | |
| 360 | Verify BMC State |
| 361 | [Documentation] Get the BMC state and verify if the current |
| 362 | ... BMC state is as expected. |
| 363 | [Arguments] ${expected} |
| 364 | |
| 365 | ${current}= Get BMC State |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 366 | Should Contain ${expected} ${current} |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 367 | |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 368 | Start Journal Log |
| 369 | [Documentation] Start capturing journal log to a file in /tmp using |
| 370 | ... journalctl command. By default journal log is collected |
| 371 | ... at /tmp/journal_log else user input location. |
| 372 | ... The File is appended with datetime. |
| 373 | [Arguments] ${file_path}=/tmp/journal_log |
| 374 | |
| 375 | Open Connection And Log In |
| 376 | |
| 377 | ${cur_time}= Get Time Stamp |
| 378 | Set Global Variable ${LOG_TIME} ${cur_time} |
| 379 | Start Command |
| 380 | ... journalctl -f > ${file_path}-${LOG_TIME} |
| 381 | Log Journal Log Started: ${file_path}-${LOG_TIME} |
| 382 | |
| 383 | Stop Journal Log |
| 384 | [Documentation] Stop journalctl process if its running. |
| 385 | ... By default return log from /tmp/journal_log else |
| 386 | ... user input location. |
| 387 | [Arguments] ${file_path}=/tmp/journal_log |
| 388 | |
| 389 | Open Connection And Log In |
| 390 | |
| 391 | ${rc}= |
| 392 | ... Execute Command |
| 393 | ... ps ax | grep journalctl | grep -v grep |
| 394 | ... return_stdout=False return_rc=True |
| 395 | |
| 396 | Return From Keyword If '${rc}' == '${1}' |
| 397 | ... No journal log process running |
| 398 | |
| 399 | ${output} ${stderr}= |
| 400 | ... Execute Command killall journalctl |
| 401 | ... return_stderr=True |
| 402 | Should Be Empty ${stderr} |
| 403 | |
| 404 | ${journal_log} ${stderr}= |
| 405 | ... Execute Command |
| 406 | ... cat ${file_path}-${LOG_TIME} |
| 407 | ... return_stderr=True |
| 408 | Should Be Empty ${stderr} |
| 409 | |
| 410 | Log ${journal_log} |
| 411 | |
| 412 | Execute Command rm ${file_path}-${LOG_TIME} |
| 413 | |
| 414 | [Return] ${journal_log} |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 415 | |
| 416 | Mac Address To Hex String |
| 417 | [Documentation] Converts MAC address into hex format. |
| 418 | ... Example |
| 419 | ... Given the following MAC: 00:01:6C:80:02:78 |
| 420 | ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78 |
| 421 | ... Description of arguments: |
| 422 | ... i_macaddress MAC address in the following format 00:01:6C:80:02:78 |
| 423 | [Arguments] ${i_macaddress} |
| 424 | |
| 425 | ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')} |
| 426 | [return] ${mac_hex} |
| 427 | |
| 428 | IP Address To Hex String |
| 429 | [Documentation] Converts IP address into hex format. |
| 430 | ... Example: |
| 431 | ... Given the following IP: 10.3.164.100 |
| 432 | ... This keyword will return: 0xa 0x3 0xa4 0xa0 |
| 433 | ... Description of arguments: |
| 434 | ... i_ipaddress IP address in the following format 10.10.10.10 |
| 435 | [Arguments] ${i_ipaddress} |
| 436 | |
| 437 | @{ip}= Split String ${i_ipaddress} . |
| 438 | ${index}= Set Variable ${0} |
| 439 | |
| 440 | :FOR ${item} IN @{ip} |
| 441 | \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes |
| 442 | \ Set List Value ${ip} ${index} ${hex} |
| 443 | \ ${index}= Set Variable ${index + 1} |
| 444 | ${ip_hex}= Catenate @{ip} |
| 445 | [return] ${ip_hex} |