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