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