George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Methods to execute commands on BMC and collect |
| 3 | ... data to a list of FFDC files |
| 4 | |
| 5 | Resource openbmc_ffdc_utils.robot |
George Keishing | 8e47f53 | 2016-10-05 08:41:45 -0500 | [diff] [blame] | 6 | Resource rest_client.robot |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 7 | Resource utils.robot |
George Keishing | ab7a907 | 2017-02-24 13:03:24 -0600 | [diff] [blame] | 8 | Library SSHLibrary |
Sivas SRR | 0d657e8 | 2017-03-13 01:00:34 -0500 | [diff] [blame] | 9 | Library OperatingSystem |
George Keishing | 16333ec | 2017-03-21 06:18:29 -0500 | [diff] [blame] | 10 | Library Collections |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 11 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 12 | *** Keywords *** |
| 13 | |
| 14 | ################################################################ |
| 15 | # Method : Call FFDC Methods # |
| 16 | # Execute the user define keywords from the FFDC List # |
| 17 | # Unlike any other keywords this will call into the # |
| 18 | # list of keywords defined in the FFDC list at one go # |
| 19 | ################################################################ |
| 20 | |
| 21 | Call FFDC Methods |
| 22 | [Documentation] Calls into FFDC Keyword index list |
| 23 | |
| 24 | @{entries}= Get ffdc method index |
| 25 | :FOR ${index} IN @{entries} |
| 26 | \ Method Call Keyword List ${index} |
George Keishing | ab7a907 | 2017-02-24 13:03:24 -0600 | [diff] [blame] | 27 | SSHLibrary.Close All Connections |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 28 | |
| 29 | |
| 30 | Method Call Keyword List |
| 31 | [Documentation] Iterate the list through keyword index |
| 32 | [Arguments] ${index} |
| 33 | |
| 34 | @{method_list}= Get ffdc method call ${index} |
| 35 | :FOR ${method} IN @{method_list} |
| 36 | \ Execute Keyword Method ${method[1]} |
| 37 | |
| 38 | |
| 39 | Execute Keyword Method |
| 40 | [Documentation] Calls into BMC method keywords. Don't let one |
| 41 | ... failure skips the remaining. Get whatever data |
| 42 | ... it could gather at worse case scenario. |
| 43 | [Arguments] ${keyword_name} |
| 44 | |
| 45 | Run Keyword And Continue On Failure ${keyword_name} |
| 46 | |
| 47 | |
| 48 | ################################################################ |
| 49 | # Method : BMC FFDC Manifest # |
| 50 | # Execute command on BMC and write to ffdc_report.txt # |
| 51 | ################################################################ |
| 52 | |
| 53 | BMC FFDC Manifest |
| 54 | [Documentation] Get the commands index for the FFDC_BMC_CMD, |
| 55 | ... login to BMC and execute commands. |
| 56 | Open Connection And Log In |
| 57 | |
| 58 | @{entries}= Get ffdc cmd index |
| 59 | :FOR ${index} IN @{entries} |
| 60 | \ Iterate BMC Command List Pairs ${index} |
| 61 | |
| 62 | |
| 63 | Iterate BMC Command List Pairs |
| 64 | [Documentation] Feed in key pair list from dictionary to execute |
| 65 | [Arguments] ${key_index} |
| 66 | |
| 67 | @{cmd_list}= Get ffdc bmc cmd ${key_index} |
| 68 | Set Suite Variable ${ENTRY_INDEX} ${key_index} |
| 69 | :FOR ${cmd} IN @{cmd_list} |
| 70 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} |
| 71 | |
| 72 | |
| 73 | Execute Command and Write FFDC |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 74 | [Documentation] Execute command on BMC or OS and write to ffdc |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 75 | ... By default to ffdc_report.txt file else to |
| 76 | ... specified file path. |
| 77 | [Arguments] ${key_index} |
| 78 | ... ${cmd} |
| 79 | ... ${logpath}=${FFDC_FILE_PATH} |
| 80 | |
| 81 | Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}' |
| 82 | ... Write Cmd Output to FFDC File ${key_index} ${cmd} |
| 83 | |
| 84 | ${stdout} ${stderr}= |
| 85 | ... Execute Command ${cmd} return_stderr=True |
| 86 | |
Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 87 | # Write stdout on success and stderr/stdout to the file on failure. |
| 88 | Run Keyword If $stderr == '${EMPTY}' |
Sweta Potthuri | 15e6d2f | 2017-02-28 03:10:02 -0600 | [diff] [blame] | 89 | ... Write Data To File ${stdout}${\n} ${logpath} |
| 90 | ... ELSE Write Data To File |
Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 91 | ... ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n} |
| 92 | ... ${logpath} |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 93 | |
| 94 | |
| 95 | ################################################################ |
| 96 | # Method : BMC FFDC Files # |
| 97 | # Execute command on BMC and write to individual file # |
| 98 | # based on the file name pre-defined in the list # |
| 99 | ################################################################ |
| 100 | |
| 101 | BMC FFDC Files |
| 102 | [Documentation] Get the command list and iterate |
| 103 | Open Connection And Log In |
| 104 | @{entries}= Get ffdc file index |
| 105 | :FOR ${index} IN @{entries} |
| 106 | \ Create File and Write Data ${index} |
| 107 | |
| 108 | |
| 109 | Create File and Write Data |
| 110 | [Documentation] Create files to current FFDC log directory, |
| 111 | ... executes command and write to corresponding |
| 112 | ... file name in the current FFDC directory. |
| 113 | [Arguments] ${key_index} |
| 114 | |
Sivas SRR | 0d657e8 | 2017-03-13 01:00:34 -0500 | [diff] [blame] | 115 | # To build IP address in searchable form eg: dummy\.domain\.com |
| 116 | ${OPENBMC_HOST_REGEX}= Run echo ${OPENBMC_HOST} | sed 's/\(\.\)/\\\1/g' |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 117 | @{cmd_list}= Get ffdc bmc file ${key_index} |
| 118 | :FOR ${cmd} IN @{cmd_list} |
Gunnar Mills | 50070fa | 2016-11-14 11:17:30 -0600 | [diff] [blame] | 119 | \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 120 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} |
Sivas SRR | 0d657e8 | 2017-03-13 01:00:34 -0500 | [diff] [blame] | 121 | # Rename OPENBMC_HOST IP address from given file to DUMMYIP |
| 122 | \ Run sed -i 's/'${OPENBMC_HOST_REGEX}'/DUMMYIP/g' ${logpath} |
| 123 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 124 | |
| 125 | |
| 126 | ################################################################ |
| 127 | # Method : Log Test Case Status # |
| 128 | # Creates test result history footprint for reference # |
| 129 | ################################################################ |
| 130 | |
| 131 | Log Test Case Status |
Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 132 | [Documentation] Test case execution result history. |
| 133 | ... Create once and append to this file |
| 134 | ... logs/test_history.txt |
| 135 | ... Format Date:Test suite:Test case:Status |
| 136 | ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 137 | Create Directory ${FFDC_LOG_PATH} |
| 138 | |
| 139 | ${exist}= Run Keyword and Return Status |
| 140 | ... OperatingSystem.File Should Exist ${TEST_HISTORY} |
| 141 | |
| 142 | Run Keyword If '${exist}' == '${False}' |
| 143 | ... Create File ${TEST_HISTORY} |
| 144 | |
| 145 | ${cur_time}= Get Current Time Stamp |
| 146 | |
| 147 | Append To File ${TEST_HISTORY} |
| 148 | ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n} |
| 149 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 150 | |
| 151 | Log FFDC Get Requests |
| 152 | [Documentation] Create file in current FFDC log directory. |
| 153 | ... Do openbmc get request and write to |
| 154 | ... corresponding file name. |
George Keishing | 8e47f53 | 2016-10-05 08:41:45 -0500 | [diff] [blame] | 155 | ... JSON pretty print for logging to file. |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 156 | [Arguments] ${key_index} |
| 157 | |
| 158 | @{cmd_list}= Get ffdc get request ${key_index} |
| 159 | :FOR ${cmd} IN @{cmd_list} |
Gunnar Mills | 50070fa | 2016-11-14 11:17:30 -0600 | [diff] [blame] | 160 | \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt |
George Keishing | d71e912 | 2016-11-30 11:15:21 -0600 | [diff] [blame] | 161 | \ ${resp}= OpenBMC Get Request ${cmd[1]} quiet=${1} |
George Keishing | 8e47f53 | 2016-10-05 08:41:45 -0500 | [diff] [blame] | 162 | \ ${status}= Run Keyword and Return Status |
| 163 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 164 | \ Run Keyword If '${status}' == '${False}' Continue For Loop |
| 165 | \ ${jsondata}= to json ${resp.content} pretty_print=True |
Sweta Potthuri | 15e6d2f | 2017-02-28 03:10:02 -0600 | [diff] [blame] | 166 | \ Write Data To File ${\n}${jsondata}${\n} ${logpath} |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 167 | |
| 168 | |
| 169 | BMC FFDC Get Requests |
| 170 | [Documentation] Get the command list and iterate |
| 171 | Open Connection And Log In |
| 172 | @{entries}= Get ffdc get request index |
| 173 | :FOR ${index} IN @{entries} |
| 174 | \ Log FFDC Get Requests ${index} |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 175 | |
| 176 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 177 | Log OS ALL DISTROS FFDC |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 178 | [Documentation] Create file in current FFDC log directory. |
| 179 | ... Executes OS command and write to |
| 180 | ... corresponding file name. |
| 181 | [Arguments] ${key_index} |
| 182 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 183 | @{cmd_list}= get ffdc os all distros call ${key_index} |
| 184 | :FOR ${cmd} IN @{cmd_list} |
Gunnar Mills | 50070fa | 2016-11-14 11:17:30 -0600 | [diff] [blame] | 185 | \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 186 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} |
| 187 | |
| 188 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 189 | Log OS SPECIFIC DISTRO FFDC |
| 190 | [Documentation] Create file in current FFDC log directory. |
| 191 | ... Executes OS command and write to |
| 192 | ... corresponding file name. |
| 193 | [Arguments] ${key_index} ${linux_distro} |
| 194 | |
| 195 | @{cmd_list}= get ffdc os distro call ${key_index} ${linux_distro} |
| 196 | :FOR ${cmd} IN @{cmd_list} |
Gunnar Mills | 50070fa | 2016-11-14 11:17:30 -0600 | [diff] [blame] | 197 | \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 198 | \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} |
| 199 | |
| 200 | |
| 201 | |
George Keishing | ca8c4c6 | 2016-10-14 10:08:40 -0500 | [diff] [blame] | 202 | OS FFDC Files |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 203 | [Documentation] Get the command list and iterate |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 204 | [Arguments] ${OS_HOST}=${OS_HOST} ${OS_USERNAME}=${OS_USERNAME} |
| 205 | ... ${OS_PASSWORD}=${OS_PASSWORD} |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 206 | |
| 207 | Return From Keyword If '${OS_HOST}' == '${EMPTY}' |
| 208 | ... No OS Host Provided |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 209 | |
| 210 | # If can't ping, return |
| 211 | ${rc}= Run Keyword and Return Status Ping Host ${OS_HOST} |
| 212 | Return From Keyword If '${rc}' == '${False}' |
| 213 | ... Could not ping OS |
| 214 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 215 | Open Connection And Log In host=${OS_HOST} username=${OS_USERNAME} |
| 216 | ... password=${OS_PASSWORD} |
| 217 | |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 218 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 219 | ... return_rc=True |
| 220 | |
| 221 | # If the return code returned by "Execute Command" is non-zero, return |
| 222 | Return From Keyword If '${rc}' != '${0}' |
| 223 | ... Could not connect to OS |
| 224 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 225 | @{entries}= Get ffdc os all distros index |
| 226 | :FOR ${index} IN @{entries} |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 227 | \ Log OS ALL DISTROS FFDC ${index} |
| 228 | |
| 229 | ${linux_distro}= Execute Command |
| 230 | ... . /etc/os-release; echo $ID |
| 231 | ... return_stdout=True return_stderr=False return_rc=False |
| 232 | |
Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 233 | Return From Keyword If |
| 234 | ... '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None' |
| 235 | ... Could not determine Linux Distribution |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 236 | |
| 237 | @{entries}= Get ffdc os distro index ${linux_distro} |
| 238 | :FOR ${index} IN @{entries} |
| 239 | \ Log OS SPECIFIC DISTRO FFDC ${index} ${linux_distro} |
George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 240 | |
| 241 | |
| 242 | ############################################################################## |
| 243 | SCP Coredump Files |
| 244 | [Documentation] Copy core dump file from BMC to local system. |
| 245 | # Check if core dump exist in the /tmp |
| 246 | Open Connection And Log In |
Michael Walsh | 87b1ce3 | 2017-03-03 15:21:42 -0600 | [diff] [blame] | 247 | ${core_files}= Execute Command ls /tmp/core_* |
George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 248 | @{core_list} = Split String ${core_files} |
| 249 | # Copy the core files |
| 250 | Open Connection for SCP |
| 251 | :FOR ${index} IN @{core_list} |
| 252 | \ scp.Get File ${index} ${LOG_PREFIX}${index.lstrip("/tmp/")} |
| 253 | # Remove the file from remote to avoid re-copying on next FFDC call |
| 254 | \ Execute Command On BMC rm ${index} |
| 255 | |
George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 256 | |
| 257 | ############################################################################## |
| 258 | Collect eSEL Log |
| 259 | [Documentation] Collect eSEL log from logging entry. |
| 260 | ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}/enumerate quiet=${1} |
| 261 | ${status}= Run Keyword And Return Status |
| 262 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 263 | Return From Keyword If '${status}' == '${False}' |
| 264 | |
| 265 | ${content}= To Json ${resp.content} |
| 266 | # Grab the list of entries from logging/entry/ |
| 267 | # The data shown below is the result of the "Get Dictionary Keys". |
| 268 | # Example: |
| 269 | # /xyz/openbmc_project/logging/entry/1 |
| 270 | # /xyz/openbmc_project/logging/entry/2 |
| 271 | ${esel_list}= Get Dictionary Keys ${content['data']} |
| 272 | |
Sweta Potthuri | 92e7b13 | 2017-03-17 06:02:32 -0500 | [diff] [blame] | 273 | ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} esel |
George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 274 | Create File ${logpath} |
| 275 | # Fetch data from /xyz/openbmc_project/logging/entry/1/attr/AdditionalData |
| 276 | # "ESEL=00 00 df 00 00 00 00 20 00 04 12 35 6f aa 00 00 " |
| 277 | # Sample eSEL entry: |
| 278 | # "/xyz/openbmc_project/logging/entry/1": { |
| 279 | # "Timestamp": 1487744317025, |
| 280 | # "AdditionalData": [ |
| 281 | # "ESEL=00 00 df 00 00 00 00 20 00 04 12 35 6f aa 00 00 " |
| 282 | # ], |
| 283 | # "Message": "org.open_power.Error.Host.Event.Event", |
| 284 | # "Id": 1, |
| 285 | # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Emergency" |
| 286 | # } |
| 287 | |
| 288 | :FOR ${entry_path} IN @{esel_list} |
| 289 | \ ${esel_data}= Read Attribute ${entry_path} AdditionalData quiet=${1} |
George Keishing | 16333ec | 2017-03-21 06:18:29 -0500 | [diff] [blame] | 290 | \ ${length}= Get Length ${esel_data} |
| 291 | # Skip writting to file if eSEL AdditionalData is empty |
| 292 | \ Continue For Loop If ${length} == ${0} |
George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 293 | \ Write Data To File "${esel_data[0]}" ${logpath} |
| 294 | \ Write Data To File ${\n} ${logpath} |
| 295 | |
| 296 | ############################################################################## |