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