| 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 |  | 
| Michael Walsh | 265ae41 | 2018-11-16 15:32:03 -0600 | [diff] [blame] | 5 | Resource               openbmc_ffdc_utils.robot | 
|  | 6 | Resource               rest_client.robot | 
|  | 7 | Resource               utils.robot | 
|  | 8 | Resource               list_utils.robot | 
|  | 9 | Resource               logging_utils.robot | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 10 | Resource               bmc_redfish_resource.robot | 
| Michael Walsh | 265ae41 | 2018-11-16 15:32:03 -0600 | [diff] [blame] | 11 | Library                SSHLibrary | 
|  | 12 | Library                OperatingSystem | 
|  | 13 | Library                Collections | 
|  | 14 | Library                String | 
|  | 15 | Library                gen_print.py | 
|  | 16 | Library                gen_cmd.py | 
|  | 17 | Library                gen_robot_keyword.py | 
|  | 18 | Library                dump_utils.py | 
|  | 19 | Library                logging_utils.py | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 20 |  | 
| Michael Walsh | de5e937 | 2018-11-15 11:28:23 -0600 | [diff] [blame] | 21 | *** Variables *** | 
|  | 22 |  | 
| Michael Walsh | 265ae41 | 2018-11-16 15:32:03 -0600 | [diff] [blame] | 23 | ${FFDC_CMD_TIMEOUT}    240 | 
| George Keishing | be3d1df | 2022-03-29 08:49:10 -0500 | [diff] [blame] | 24 | ${FFDC_BMC_FILES_CLEANUP}  rm -rf /tmp/BMC_* /tmp/PEL_* /tmp/PLDM_* | 
|  | 25 | ...                        /tmp/OCC_* /tmp/fan_* /tmp/GUARD_* /tmp/DEVTREE | 
| Michael Walsh | de5e937 | 2018-11-15 11:28:23 -0600 | [diff] [blame] | 26 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 27 | *** Keywords *** | 
|  | 28 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 29 | # Method : Call FFDC Methods                                   # | 
|  | 30 | #          Execute the user define keywords from the FFDC List # | 
|  | 31 | #          Unlike any other keywords this will call into the   # | 
|  | 32 | #          list of keywords defined in the FFDC list at one go # | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 33 |  | 
|  | 34 | Call FFDC Methods | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 35 | [Documentation]   Call into FFDC Keyword index list. | 
|  | 36 | [Arguments]  ${ffdc_function_list}=${EMPTY} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 37 |  | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 38 | # Description of argument(s): | 
|  | 39 | # ffdc_function_list  A colon-delimited list naming the kinds of FFDC that | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 40 | #                     are to be collected | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 41 | #                     (e.g. "FFDC Generic Report:BMC Specific Files"). | 
|  | 42 | #                     Acceptable values can be found in the description | 
|  | 43 | #                     field of FFDC_METHOD_CALL in | 
|  | 44 | #                     lib/openbmc_ffdc_list.py.  Those values can be | 
|  | 45 | #                     obtained via a call to 'Get FFDC Method Desc' (also | 
|  | 46 | #                     from lib/openbmc_ffdc_list.py). | 
|  | 47 |  | 
|  | 48 | @{entries}=  Get FFDC Method Index | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 49 | # Example entries: | 
|  | 50 | # entries: | 
|  | 51 | #   entries[0]:  BMC LOGS | 
|  | 52 |  | 
|  | 53 | @{ffdc_file_list}=  Create List | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 54 | FOR  ${index}  IN  @{entries} | 
|  | 55 | ${ffdc_file_sub_list}=  Method Call Keyword List  ${index}  ${ffdc_function_list} | 
|  | 56 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 57 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 58 |  | 
| Michael Walsh | 6bad841 | 2017-06-27 14:09:36 -0500 | [diff] [blame] | 59 | Run Key U  SSHLibrary.Close All Connections | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 60 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 61 | RETURN  ${ffdc_file_list} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 62 |  | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 63 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 64 | Method Call Keyword List | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 65 | [Documentation]  Process FFDC request and return a list of generated files. | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 66 | [Arguments]  ${index}  ${ffdc_function_list}=${EMPTY} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 67 |  | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 68 | # Description of argument(s): | 
|  | 69 | # index               The index into the FFDC_METHOD_CALL dictionary (e.g. | 
|  | 70 | #                     'BMC LOGS'). | 
|  | 71 | # ffdc_function_list  See ffdc_function_list description in | 
|  | 72 | #                     "Call FFDC Methods" (above). | 
|  | 73 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 74 | @{method_list}=  Get FFDC Method Call  ${index} | 
|  | 75 | # Example method_list: | 
|  | 76 | # method_list: | 
|  | 77 | #   method_list[0]: | 
|  | 78 | #     method_list[0][0]: FFDC Generic Report | 
|  | 79 | #     method_list[0][1]: BMC FFDC Manifest | 
|  | 80 | #   method_list[1]: | 
|  | 81 | #     method_list[1][0]: Get Request FFDC | 
|  | 82 | #     method_list[1][1]: BMC FFDC Get Requests | 
|  | 83 | # (etc.) | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 84 |  | 
|  | 85 | # If function list is empty assign default (i.e. a list of all allowable | 
|  | 86 | # values).  In either case, convert ffdc_function_list from a string to | 
|  | 87 | # a list. | 
|  | 88 | @{ffdc_function_list}= | 
|  | 89 | ...  Run Keyword If  '${ffdc_function_list}' == '${EMPTY}' | 
|  | 90 | ...    Get FFDC Method Desc  ${index} | 
|  | 91 | ...  ELSE | 
|  | 92 | ...    Split String  ${ffdc_function_list}  separator=: | 
|  | 93 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 94 | @{ffdc_file_list}=  Create List | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 95 | FOR  ${method}  IN  @{method_list} | 
|  | 96 | ${ffdc_file_sub_list}=  Execute Keyword Method  ${method[0]}  ${method[1]}  @{ffdc_function_list} | 
|  | 97 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 98 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 99 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 100 | RETURN  ${ffdc_file_list} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 101 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 102 |  | 
|  | 103 | Execute Keyword Method | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 104 | [Documentation]  Call into BMC method keywords. Don't let one | 
|  | 105 | ...              failure skip the remaining. Get whatever data | 
|  | 106 | ...              it could gather at worse case scenario. | 
|  | 107 | [Arguments]  ${description}  ${keyword_name}  @{ffdc_function_list} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 108 |  | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 109 | # Description of argument(s): | 
|  | 110 | # description         The description of the FFDC to be collected.  This | 
|  | 111 | #                     would be any value returned by | 
|  | 112 | #                     'Get FFDC Method Desc' (e.g. "FFDC Generic Report"). | 
|  | 113 | # keyword_name        The name of the keyword to call to collect the FFDC | 
|  | 114 | #                     data (again, see FFDC_METHOD_CALL). | 
|  | 115 | # ffdc_function_list  See ffdc_function_list description in | 
|  | 116 | #                     "Call FFDC Methods" (above).  The only difference is | 
|  | 117 | #                     in this case, it should be a list rather than a | 
|  | 118 | #                     colon-delimited value. | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 119 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 120 | @{ffdc_file_list}=  Create List | 
| Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 121 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 122 | ${index}=  Get Index From List  ${ffdc_function_list}  ${description} | 
|  | 123 | Run Keyword If  '${index}' == '${-1}'  Return from Keyword | 
|  | 124 | ...  ${ffdc_file_list} | 
|  | 125 |  | 
|  | 126 | ${status}  ${ffdc_file_list}=  Run Key  ${keyword_name}  ignore=1 | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 127 | RETURN  ${ffdc_file_list} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 128 |  | 
| George Keishing | be3d1df | 2022-03-29 08:49:10 -0500 | [diff] [blame] | 129 |  | 
|  | 130 | BMC FFDC Cleanup | 
|  | 131 | [Documentation]  Run the ssh commands from FFDC_BMC_FILES_CLEANUP. | 
|  | 132 |  | 
|  | 133 | Log To Console  BMC FFDC Files clean up: ${FFDC_BMC_FILES_CLEANUP} | 
|  | 134 | BMC Execute Command   ${FFDC_BMC_FILES_CLEANUP}  ignore_err=1 | 
|  | 135 |  | 
|  | 136 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 137 | # Method : BMC FFDC Manifest                                   # | 
|  | 138 | #          Execute command on BMC and write to ffdc_report.txt # | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 139 |  | 
|  | 140 | BMC FFDC Manifest | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 141 | [Documentation]  Run the ssh commands from FFDC_BMC_CMD and return a list | 
|  | 142 | ...              of generated files. | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 143 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 144 | @{ffdc_file_list}=  Create List  ${FFDC_FILE_PATH} | 
|  | 145 | @{entries}=  Get FFDC Cmd Index | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 146 |  | 
|  | 147 | FOR  ${index}  IN  @{entries} | 
|  | 148 | Iterate BMC Command List Pairs  ${index} | 
|  | 149 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 150 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 151 | RETURN  ${ffdc_file_list} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 152 |  | 
|  | 153 |  | 
|  | 154 | Iterate BMC Command List Pairs | 
|  | 155 | [Documentation]    Feed in key pair list from dictionary to execute | 
|  | 156 | [Arguments]        ${key_index} | 
|  | 157 |  | 
|  | 158 | @{cmd_list}=      Get ffdc bmc cmd    ${key_index} | 
|  | 159 | Set Suite Variable   ${ENTRY_INDEX}   ${key_index} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 160 |  | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 161 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 162 | Execute Command and Write FFDC    ${cmd[0]}  ${cmd[1]} | 
|  | 163 | END | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 164 |  | 
|  | 165 | Execute Command and Write FFDC | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 166 | [Documentation]  Run a command on the BMC or OS, write the output to the | 
|  | 167 | ...              specified file and return a list of generated files. | 
|  | 168 | [Arguments]  ${key_index}  ${cmd}  ${logpath}=${FFDC_FILE_PATH} | 
|  | 169 | ...          ${target}=BMC | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 170 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 171 | Run Keyword If  '${logpath}' == '${FFDC_FILE_PATH}' | 
|  | 172 | ...    Write Cmd Output to FFDC File  ${key_index}  ${cmd} | 
|  | 173 |  | 
|  | 174 | @{ffdc_file_list}=  Create List  ${log_path} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 175 |  | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 176 | ${cmd_buf}=  Catenate  ${target} Execute Command \ ${cmd} \ ignore_err=${1} | 
| Michael Walsh | 265ae41 | 2018-11-16 15:32:03 -0600 | [diff] [blame] | 177 | ...  \ time_out=${FFDC_CMD_TIMEOUT} | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 178 | ${status}  ${ret_values}=  Run Key  ${cmd_buf}  ignore=${1} | 
| Michael Walsh | de5e937 | 2018-11-15 11:28:23 -0600 | [diff] [blame] | 179 | # If the command times out, status will be 'FAIL'. | 
|  | 180 | Return From Keyword If  '${status}' == 'FAIL'  ${ffdc_file_list} | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 181 |  | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 182 | ${stdout}=  Set Variable  ${ret_values}[0] | 
|  | 183 | ${stderr}=  Set Variable  ${ret_values}[1] | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 184 |  | 
| Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 185 | # Write stdout on success and stderr/stdout to the file on failure. | 
|  | 186 | Run Keyword If  $stderr == '${EMPTY}' | 
| Sweta Potthuri | 15e6d2f | 2017-02-28 03:10:02 -0600 | [diff] [blame] | 187 | ...    Write Data To File  ${stdout}${\n}  ${logpath} | 
|  | 188 | ...  ELSE  Write Data To File | 
| Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 189 | ...    ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n} | 
|  | 190 | ...    ${logpath} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 191 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 192 | RETURN  ${ffdc_file_list} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 193 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 194 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 195 | # Method : BMC FFDC Files                                      # | 
|  | 196 | #          Execute command on BMC and write to individual file # | 
|  | 197 | #          based on the file name pre-defined in the list      # | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 198 |  | 
|  | 199 | BMC FFDC Files | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 200 | [Documentation]  Run the commands from FFDC_BMC_FILE and return a list of | 
|  | 201 | ...              generated files. | 
|  | 202 |  | 
|  | 203 | @{entries}=  Get FFDC File Index | 
|  | 204 | # Example of entries: | 
|  | 205 | # entries: | 
|  | 206 | #   entries[0]: BMC FILES | 
|  | 207 |  | 
| Steven Sombar | a31f4c8 | 2019-08-01 16:00:23 -0500 | [diff] [blame] | 208 | scp.Open Connection | 
| vinaybs6 | b811094 | 2020-01-29 23:15:29 -0600 | [diff] [blame] | 209 | ...  ${OPENBMC_HOST}  username=${OPENBMC_USERNAME}  password=${OPENBMC_PASSWORD}  port=${SSH_PORT} | 
| Steven Sombar | a31f4c8 | 2019-08-01 16:00:23 -0500 | [diff] [blame] | 210 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 211 | @{ffdc_file_list}=  Create List | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 212 |  | 
|  | 213 | FOR  ${index}  IN  @{entries} | 
|  | 214 | ${ffdc_file_sub_list}=  Create File and Write Data  ${index} | 
|  | 215 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 216 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 217 |  | 
| Michael Walsh | 17eaafe | 2019-08-22 11:05:20 -0500 | [diff] [blame] | 218 | BMC Execute Command  rm -rf /tmp/BMC_* | 
| Steven Sombar | a31f4c8 | 2019-08-01 16:00:23 -0500 | [diff] [blame] | 219 | scp.Close Connection | 
|  | 220 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 221 | RETURN  ${ffdc_file_list} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 222 |  | 
|  | 223 |  | 
|  | 224 | Create File and Write Data | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 225 | [Documentation]  Run commands from FFDC_BMC_FILE to create FFDC files and | 
|  | 226 | ...              return a list of generated files. | 
|  | 227 | [Arguments]  ${key_index} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 228 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 229 | # Description of argument(s): | 
|  | 230 | # key_index  The index into the FFDC_BMC_FILE dictionary. | 
|  | 231 |  | 
|  | 232 | @{ffdc_file_list}=  Create List | 
|  | 233 | @{cmd_list}=  Get FFDC BMC File  ${key_index} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 234 |  | 
|  | 235 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 236 | ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]} | 
|  | 237 | ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}  ${logpath} | 
| George Keishing | 89974c9 | 2022-02-14 10:43:03 -0600 | [diff] [blame] | 238 | Run Key U  scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}  ignore=1 | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 239 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 240 | END | 
| Sivas SRR | 0d657e8 | 2017-03-13 01:00:34 -0500 | [diff] [blame] | 241 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 242 | RETURN  ${ffdc_file_list} | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 243 |  | 
|  | 244 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 245 | # Method : Log Test Case Status                                # | 
|  | 246 | #          Creates test result history footprint for reference # | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 247 |  | 
|  | 248 | Log Test Case Status | 
| Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 249 | [Documentation]  Test case execution result history. | 
|  | 250 | ...  Create once and append to this file | 
|  | 251 | ...  logs/test_history.txt | 
|  | 252 | ...  Format   Date:Test suite:Test case:Status | 
|  | 253 | ...  20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL | 
| Michael Walsh | fa9f70f | 2017-04-21 16:00:18 -0500 | [diff] [blame] | 254 |  | 
|  | 255 | ${FFDC_DIR_PATH_STYLE}=  Get Variable Value  ${FFDC_DIR_PATH_STYLE} | 
|  | 256 | ...  ${EMPTY} | 
|  | 257 | ${FFDC_DIR_PATH}=  Get Variable Value  ${FFDC_DIR_PATH}  ${EMPTY} | 
|  | 258 |  | 
|  | 259 | Run Keyword If  '${FFDC_DIR_PATH}' == '${EMPTY}'  Set FFDC Defaults | 
|  | 260 |  | 
|  | 261 | Run Keyword If  '${FFDC_DIR_PATH_STYLE}' == '${1}'  Run Keywords | 
|  | 262 | ...  Set Global Variable  ${FFDC_LOG_PATH}  ${FFDC_DIR_PATH}  AND | 
|  | 263 | ...  Set Global Variable  ${TEST_HISTORY}  ${FFDC_DIR_PATH}test_history.txt | 
|  | 264 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 265 | Create Directory   ${FFDC_LOG_PATH} | 
|  | 266 |  | 
|  | 267 | ${exist}=   Run Keyword and Return Status | 
|  | 268 | ...   OperatingSystem.File Should Exist   ${TEST_HISTORY} | 
|  | 269 |  | 
|  | 270 | Run Keyword If  '${exist}' == '${False}' | 
|  | 271 | ...   Create File  ${TEST_HISTORY} | 
|  | 272 |  | 
| Michael Walsh | fa9f70f | 2017-04-21 16:00:18 -0500 | [diff] [blame] | 273 | Rpvars  TEST_HISTORY | 
|  | 274 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 275 | ${cur_time}=      Get Current Time Stamp | 
|  | 276 |  | 
|  | 277 | Append To File    ${TEST_HISTORY} | 
|  | 278 | ...   ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n} | 
|  | 279 |  | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 280 |  | 
|  | 281 | Log FFDC Get Requests | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 282 | [Documentation]  Run the get requests associated with the key and return a | 
|  | 283 | ...              list of generated files. | 
|  | 284 | [Arguments]  ${key_index} | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 285 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 286 | # Note: Output will be in JSON pretty_print format. | 
|  | 287 |  | 
|  | 288 | # Description of argument(s): | 
|  | 289 | # key_index  The key to the FFDC_GET_REQUEST dictionary that contains the | 
|  | 290 | #            get requests that are to be run. | 
|  | 291 |  | 
|  | 292 | @{ffdc_file_list}=  Create List | 
|  | 293 | @{cmd_list}=  Get FFDC Get Request  ${key_index} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 294 |  | 
|  | 295 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 296 | ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]} | 
| George Keishing | ccd20e1 | 2020-07-29 11:14:26 -0500 | [diff] [blame] | 297 | ${resp}=  OpenBMC Get Request  ${cmd[1]}  quiet=${1}  timeout=${30} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 298 | ${status}=  Run Keyword and Return Status  Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK} | 
|  | 299 | Run Keyword If  '${status}' == '${False}'  Continue For Loop | 
| George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 300 | Write Data To File  ${\n}${resp.json()}${\n}  ${logpath} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 301 | Append To List  ${ffdc_file_list}  ${logpath} | 
|  | 302 | END | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 303 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 304 | RETURN  ${ffdc_file_list} | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 305 |  | 
| George Keishing | 8c42bbc | 2021-09-28 14:52:54 -0500 | [diff] [blame] | 306 |  | 
|  | 307 | Log FFDC Get Redfish Requests | 
|  | 308 | [Documentation]  Run the get requests associated with the key and return a | 
|  | 309 | ...              list of generated files. | 
|  | 310 | [Arguments]  ${key_index} | 
|  | 311 |  | 
|  | 312 | # Note: Output will be in JSON pretty_print format. | 
|  | 313 |  | 
|  | 314 | # Description of argument(s): | 
|  | 315 | # key_index  The key to the FFDC_GET_REDFISH_REQUEST dictionary that contains the | 
|  | 316 | #            get requests that are to be run. | 
|  | 317 |  | 
|  | 318 | @{ffdc_file_list}=  Create List | 
|  | 319 | @{cmd_list}=  Get FFDC Get Redfish Request  ${key_index} | 
|  | 320 |  | 
|  | 321 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 322 | ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]} | 
|  | 323 | ${resp}=  Redfish.Get  ${cmd[1]} | 
|  | 324 | Write Data To File  ${\n}${resp}${\n}  ${logpath} | 
|  | 325 | Append To List  ${ffdc_file_list}  ${logpath} | 
|  | 326 | END | 
|  | 327 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 328 | RETURN  ${ffdc_file_list} | 
| George Keishing | 8c42bbc | 2021-09-28 14:52:54 -0500 | [diff] [blame] | 329 |  | 
|  | 330 |  | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 331 | BMC FFDC Get Requests | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 332 | [Documentation]  Iterate over get request list and return a list of | 
|  | 333 | ...              generated files. | 
|  | 334 |  | 
|  | 335 | @{ffdc_file_list}=  Create List | 
|  | 336 |  | 
| Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 337 | @{entries}=  Get ffdc get request index | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 338 | # Example of entries: | 
|  | 339 | # entries: | 
|  | 340 | #  entries[0]:  GET REQUESTS | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 341 |  | 
|  | 342 | FOR  ${index}  IN  @{entries} | 
|  | 343 | ${ffdc_file_sub_list}=  Log FFDC Get Requests  ${index} | 
|  | 344 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 345 | END | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 346 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 347 | RETURN  ${ffdc_file_list} | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 348 |  | 
| George Keishing | 8c42bbc | 2021-09-28 14:52:54 -0500 | [diff] [blame] | 349 |  | 
|  | 350 | BMC FFDC Get Redfish Requests | 
|  | 351 | [Documentation]  Iterate over get request list and return a list of | 
|  | 352 | ...              generated files. | 
|  | 353 |  | 
|  | 354 | @{ffdc_file_list}=  Create List | 
|  | 355 |  | 
|  | 356 | @{entries}=  Get ffdc get redfish request index | 
|  | 357 | # Example of entries: | 
|  | 358 | # entries: | 
|  | 359 | #  entries[0]:  GET REQUESTS | 
|  | 360 |  | 
|  | 361 | FOR  ${index}  IN  @{entries} | 
|  | 362 | ${ffdc_file_sub_list}=  Log FFDC Get Redfish Requests  ${index} | 
|  | 363 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 364 | END | 
|  | 365 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 366 | RETURN  ${ffdc_file_list} | 
| George Keishing | 8c42bbc | 2021-09-28 14:52:54 -0500 | [diff] [blame] | 367 |  | 
|  | 368 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 369 | Log OS All distros FFDC | 
|  | 370 | [Documentation]  Run commands from FFDC_OS_ALL_DISTROS_FILE to create FFDC | 
|  | 371 | ...              files and return a list of generated files. | 
|  | 372 | [Arguments]  ${key_index} | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 373 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 374 | # Description of argument(s): | 
|  | 375 | # key_index  The index into the FFDC_OS_ALL_DISTROS_FILE dictionary. | 
|  | 376 |  | 
|  | 377 | @{ffdc_file_list}=  Create List | 
|  | 378 |  | 
|  | 379 | @{cmd_list}=  Get FFDC OS All Distros Call  ${key_index} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 380 |  | 
|  | 381 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 382 | ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]} | 
|  | 383 | ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}  ${logpath}  target=OS | 
|  | 384 | # scp it to the LOG_PREFIX ffdc directory. | 
| George Keishing | 89974c9 | 2022-02-14 10:43:03 -0600 | [diff] [blame] | 385 | Run Key U  scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}  ignore=1 | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 386 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 387 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 388 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 389 | RETURN  ${ffdc_file_list} | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 390 |  | 
|  | 391 |  | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 392 | Log OS SPECIFIC DISTRO FFDC | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 393 | [Documentation]  Run commands from the FFDC_OS_<distro>_FILE to create FFDC | 
|  | 394 | ...              files and return a list of generated files. | 
|  | 395 | [Arguments]  ${key_index}  ${linux_distro} | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 396 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 397 | # Description of argument(s): | 
|  | 398 | # key_index  The index into the FFDC_OS_<distro>_FILE dictionary. | 
|  | 399 | # linux_distro  Your OS's linux distro (e.g. "UBUNTU", "RHEL", etc). | 
|  | 400 |  | 
| George Keishing | 671dd66 | 2021-05-28 03:26:30 -0500 | [diff] [blame] | 401 | Log To Console  Collecting log for ${linux_distro} | 
|  | 402 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 403 | @{ffdc_file_list}=  Create List | 
|  | 404 |  | 
|  | 405 | @{cmd_list}=  Get FFDC OS Distro Call  ${key_index}  ${linux_distro} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 406 |  | 
|  | 407 | FOR  ${cmd}  IN  @{cmd_list} | 
|  | 408 | ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]} | 
|  | 409 | ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}  ${logpath}  target=OS | 
| George Keishing | 89974c9 | 2022-02-14 10:43:03 -0600 | [diff] [blame] | 410 | Run Key U  scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}  ignore=1 | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 411 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
| George Keishing | 4609d2f | 2021-05-28 04:40:58 -0500 | [diff] [blame] | 412 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 413 |  | 
| Steven Sombar | e70acbe | 2019-08-20 14:37:47 -0500 | [diff] [blame] | 414 | # Get the name of the sosreport file. | 
|  | 415 | ${sosreport_file_path}  ${stderr}  ${rc}=  OS Execute Command | 
|  | 416 | ...  ls /tmp/sosreport*FFDC*tar.xz  ignore_err=${True} | 
|  | 417 | # Example:  sosreport_file_path="/tmp/sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz". | 
|  | 418 |  | 
|  | 419 | # Return if there is no sosreport file. | 
|  | 420 | Return From Keyword If  ${rc} != ${0}  ${ffdc_file_list} | 
|  | 421 |  | 
|  | 422 | ${sosreport_dir_path}  ${sosreport_file_name}=  Split Path  ${sosreport_file_path} | 
|  | 423 | # Example:  sosreport_dir_path="/tmp", | 
|  | 424 | #           sosreport_file_name="sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz". | 
|  | 425 |  | 
|  | 426 | # Location where the sosreport file will be copied to. | 
|  | 427 | ${local_sosreport_file_path}=  Set Variable  ${LOG_PREFIX}OS_${sosreport_file_name} | 
|  | 428 |  | 
|  | 429 | # Change file permissions otherwise scp will not see the file. | 
|  | 430 | OS Execute Command  chmod 644 ${sosreport_file_path} | 
|  | 431 |  | 
|  | 432 | # SCP the sosreport file from the OS. | 
| George Keishing | 89974c9 | 2022-02-14 10:43:03 -0600 | [diff] [blame] | 433 | Run Key U  scp.Get File \ ${sosreport_file_path} \ ${local_sosreport_file_path}  ignore=1 | 
| Steven Sombar | e70acbe | 2019-08-20 14:37:47 -0500 | [diff] [blame] | 434 |  | 
|  | 435 | # Add the file location to the ffdc_file_list. | 
|  | 436 | Append To List  ${ffdc_file_list}  ${local_sosreport_file_path} | 
|  | 437 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 438 | RETURN  ${ffdc_file_list} | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 439 |  | 
|  | 440 |  | 
| George Keishing | ca8c4c6 | 2016-10-14 10:08:40 -0500 | [diff] [blame] | 441 | OS FFDC Files | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 442 | [Documentation]  Run the commands from FFDC_OS_ALL_DISTROS_FILE to create | 
|  | 443 | ...              FFDC files and return a list of generated files. | 
| Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 444 | [Arguments]  ${OS_HOST}=${OS_HOST}  ${OS_USERNAME}=${OS_USERNAME} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 445 | ...  ${OS_PASSWORD}=${OS_PASSWORD} | 
| Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 446 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 447 | @{ffdc_file_list}=  Create List | 
| Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 448 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 449 | Run Keyword If  '${OS_HOST}' == '${EMPTY}'  Run Keywords | 
|  | 450 | ...  Print Timen  No OS Host provided so no OS FFDC will be done.  AND | 
|  | 451 | ...  Return From Keyword  ${ffdc_file_list} | 
| Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 452 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 453 | ${match_state}=  Create Dictionary  os_ping=^1$  os_login=^1$ | 
|  | 454 | ...  os_run_cmd=^1$ | 
|  | 455 | ${status}  ${ret_values}=  Run Keyword and Ignore Error  Check State | 
|  | 456 | ...  ${match_state}  quiet=0 | 
|  | 457 |  | 
|  | 458 | Run Keyword If  '${status}' == 'FAIL'  Run Keywords | 
| Michael Walsh | c3b28d7 | 2017-11-16 10:43:14 -0600 | [diff] [blame] | 459 | ...  Print Timen  The OS is not communicating so no OS FFDC will be done.\n | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 460 | ...  AND | 
|  | 461 | ...  Return From Keyword  ${ffdc_file_list} | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 462 |  | 
| George Keishing | 671dd66 | 2021-05-28 03:26:30 -0500 | [diff] [blame] | 463 | ${stdout}=  OS Distro Type | 
|  | 464 |  | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 465 | Set Global Variable  ${linux_distro}  ${stdout} | 
| Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 466 |  | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 467 | Rpvars  linux_distro | 
| Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 468 |  | 
| Steven Sombar | fc024cb | 2019-04-22 11:16:16 -0500 | [diff] [blame] | 469 | scp.Open Connection | 
|  | 470 | ...  ${OS_HOST}  username=${OS_USERNAME}  password=${OS_PASSWORD} | 
|  | 471 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 472 | @{entries}=  Get FFDC OS All Distros Index | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 473 |  | 
|  | 474 | FOR  ${index}  IN  @{entries} | 
|  | 475 | ${ffdc_file_sub_list}=  Log OS All distros FFDC  ${index} | 
|  | 476 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 477 | END | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 478 |  | 
| Jeff Whitlock | 7d805b2 | 2017-01-20 14:04:33 -0600 | [diff] [blame] | 479 | Return From Keyword If | 
|  | 480 | ...  '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None' | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 481 | ...  ${ffdc_file_list} | 
| Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 482 |  | 
|  | 483 | @{entries}=  Get ffdc os distro index  ${linux_distro} | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 484 |  | 
|  | 485 | FOR  ${index}  IN  @{entries} | 
|  | 486 | ${ffdc_file_sub_list}=  Log OS SPECIFIC DISTRO FFDC  ${index}  ${linux_distro} | 
|  | 487 | ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list} | 
|  | 488 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 489 |  | 
| Steven Sombar | fc024cb | 2019-04-22 11:16:16 -0500 | [diff] [blame] | 490 | # Delete ffdc files still on OS and close scp. | 
| Steven Sombar | e70acbe | 2019-08-20 14:37:47 -0500 | [diff] [blame] | 491 | OS Execute Command  rm -rf /tmp/OS_* /tmp/sosreport*FFDC*  ignore_err=${True} | 
| Steven Sombar | fc024cb | 2019-04-22 11:16:16 -0500 | [diff] [blame] | 492 | scp.Close Connection | 
|  | 493 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 494 | RETURN  ${ffdc_file_list} | 
| George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 495 |  | 
|  | 496 |  | 
| Steven Sombar | 96de573 | 2017-08-17 09:04:52 -0500 | [diff] [blame] | 497 | System Inventory Files | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 498 | [Documentation]  Copy systest os_inventory files and return a list of | 
|  | 499 | ...              generated files.. | 
| Steven Sombar | 96de573 | 2017-08-17 09:04:52 -0500 | [diff] [blame] | 500 | # The os_inventory files are the result of running | 
|  | 501 | # systest/htx_hardbootme_test.  If these files exist | 
|  | 502 | # they are copied to the FFDC directory. | 
|  | 503 | # Global variable ffdc_dir_path is the path name of the | 
|  | 504 | # directory they are copied to. | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 505 |  | 
|  | 506 | @{ffdc_file_list}=  Create List | 
|  | 507 |  | 
|  | 508 | ${globex}=  Set Variable  os_inventory_*.json | 
|  | 509 |  | 
|  | 510 | @{file_list}=  OperatingSystem.List Files In Directory  .  ${globex} | 
|  | 511 |  | 
|  | 512 | Copy Files  ${globex}  ${ffdc_dir_path} | 
|  | 513 |  | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 514 | FOR  ${file_name}  IN  @{file_list} | 
|  | 515 | Append To List  ${ffdc_file_list}  ${ffdc_dir_path}${file_name} | 
|  | 516 | END | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 517 |  | 
|  | 518 | Run Keyword and Ignore Error  Remove Files  ${globex} | 
|  | 519 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 520 | RETURN  ${ffdc_file_list} | 
| Steven Sombar | 96de573 | 2017-08-17 09:04:52 -0500 | [diff] [blame] | 521 |  | 
|  | 522 |  | 
| George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 523 | SCP Coredump Files | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 524 | [Documentation]  Copy core dump files from BMC to local system and return a | 
|  | 525 | ...              list of generated file names. | 
|  | 526 |  | 
|  | 527 | @{ffdc_file_list}=  Create List | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 528 |  | 
| George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 529 | # Check if core dump exist in the /tmp | 
| Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 530 | ${core_files}  ${stderr}  ${rc}=  BMC Execute Command  ls /tmp/core_* | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 531 | ...  ignore_err=${1} | 
|  | 532 | Run Keyword If  '${rc}' != '${0}'  Return From Keyword  ${ffdc_file_list} | 
|  | 533 |  | 
| George Keishing | 6e36ad7 | 2024-10-14 22:51:23 +0530 | [diff] [blame] | 534 | # Core dumps if configured to dump on /tmp via /proc/sys/kernel/core_pattern | 
|  | 535 | Run Keyword and Ignore Error | 
|  | 536 | ...  BMC Execute Command  chown ${OPENBMC_USERNAME}:${OPENBMC_USERNAME} /tmp/core_* | 
|  | 537 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 538 | @{core_list}=  Split String  ${core_files} | 
| George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 539 | # Copy the core files | 
| Michael Walsh | 6bad841 | 2017-06-27 14:09:36 -0500 | [diff] [blame] | 540 | Run Key U  Open Connection for SCP | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 541 |  | 
|  | 542 | FOR  ${index}  IN  @{core_list} | 
|  | 543 | ${ffdc_file_path}=  Catenate  ${LOG_PREFIX}${index.lstrip("/tmp/")} | 
|  | 544 | ${status}=  Run Keyword and Return Status  scp.Get File  ${index}  ${ffdc_file_path} | 
|  | 545 | Run Keyword If  '${status}' == '${False}'  Continue For Loop | 
|  | 546 | Append To List  ${ffdc_file_list}  ${ffdc_file_path} | 
|  | 547 |  | 
|  | 548 | # Remove the file from remote to avoid re-copying on next FFDC call | 
|  | 549 |  | 
|  | 550 | BMC Execute Command  rm ${index}  ignore_err=${1} | 
|  | 551 | # I can't find a way to do this: scp.Close Connection | 
|  | 552 |  | 
|  | 553 | END | 
| George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 554 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 555 | RETURN  ${ffdc_file_list} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 556 |  | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 557 |  | 
| Sweta Potthuri | a82efd6 | 2017-10-18 05:34:59 -0500 | [diff] [blame] | 558 | SCP Dump Files | 
|  | 559 | [Documentation]  Copy all dump files from BMC to local system. | 
|  | 560 |  | 
|  | 561 | # Check if dumps exist | 
|  | 562 | ${ffdc_file_list}=  Scp Dumps  ${FFDC_DIR_PATH}  ${FFDC_PREFIX} | 
|  | 563 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 564 | RETURN  ${ffdc_file_list} | 
| Sweta Potthuri | a82efd6 | 2017-10-18 05:34:59 -0500 | [diff] [blame] | 565 |  | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 566 |  | 
| George Keishing | be396b8 | 2020-03-23 10:23:58 -0500 | [diff] [blame] | 567 | Collect PEL Log | 
|  | 568 | [Documentation]  Collect PEL files from from BMC. | 
|  | 569 |  | 
|  | 570 | Create Directory  ${FFDC_DIR_PATH}${/}pel_files/ | 
|  | 571 | scp.Get File  /var/lib/phosphor-logging/extensions/pels/logs/ | 
|  | 572 | ...  ${FFDC_DIR_PATH}${/}pel_files  recursive=True | 
|  | 573 |  | 
|  | 574 |  | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 575 | Enumerate Redfish Resources | 
|  | 576 | [Documentation]  Enumerate /redfish/v1 resources and properties to | 
|  | 577 | ...              a file. Return a list which contains the file name. | 
| George Keishing | 5942d20 | 2021-10-04 13:09:24 -0500 | [diff] [blame] | 578 | [Arguments]  ${log_prefix_path}=${LOG_PREFIX}  ${enum_uri}=/redfish/v1 | 
|  | 579 | ...          ${file_enum_name}=redfish_resource_properties.txt | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 580 |  | 
|  | 581 | # Description of argument(s): | 
|  | 582 | # log_prefix_path    The location specifying where to create FFDC file(s). | 
|  | 583 |  | 
|  | 584 | # Login is needed to fetch Redfish information. | 
|  | 585 | # If login fails, return from keyword. | 
| George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 586 | ${status}=  Run Keyword And Return Status  Redfish.Login | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 587 | Return From Keyword If   ${status} == ${False} | 
|  | 588 |  | 
|  | 589 | # Get the Redfish resources and properties. | 
| George Keishing | 5942d20 | 2021-10-04 13:09:24 -0500 | [diff] [blame] | 590 | ${json_data}=  redfish_utils.Enumerate Request  ${enum_uri} | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 591 | # Typical output: | 
|  | 592 | # { | 
|  | 593 | #  "@odata.id": "/redfish/v1", | 
|  | 594 | #  "@odata.type": "#ServiceRoot.v1_1_1.ServiceRoot", | 
|  | 595 | #  "AccountService": { | 
|  | 596 | #    "@odata.id": "/redfish/v1/AccountService" | 
|  | 597 | #  }, | 
|  | 598 | #  "Chassis": { | 
|  | 599 | #    "@odata.id": "/redfish/v1/Chassis" | 
|  | 600 | #  }, | 
|  | 601 | #  "Id": "RootService", | 
|  | 602 | #  "JsonSchemas": { | 
|  | 603 | #    "@odata.id": "/redfish/v1/JsonSchemas" | 
|  | 604 | #  }, | 
|  | 605 | # ..etc... | 
|  | 606 | # } | 
|  | 607 |  | 
|  | 608 | @{ffdc_file_list}=  Create List | 
| George Keishing | 5942d20 | 2021-10-04 13:09:24 -0500 | [diff] [blame] | 609 | ${logpath}=  Catenate  SEPARATOR=  ${log_prefix_path}  ${file_enum_name} | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 610 | Create File  ${logpath} | 
|  | 611 | Write Data To File  "${\n}${json_data}${\n}"  ${logpath} | 
|  | 612 |  | 
|  | 613 | Append To List  ${ffdc_file_list}  ${logpath} | 
|  | 614 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 615 | RETURN  ${ffdc_file_list} | 
| Steven Sombar | 2da175f | 2019-02-04 10:32:58 -0600 | [diff] [blame] | 616 |  | 
|  | 617 |  | 
| George Keishing | 985659a | 2021-06-23 02:52:13 -0500 | [diff] [blame] | 618 | Enumerate Redfish OEM Resources | 
|  | 619 | [Documentation]  Enumerate /<oem>/v1 resources and properties to | 
|  | 620 | ...              a file. Return a list which contains the file name. | 
|  | 621 | [Arguments]  ${log_prefix_path}=${LOG_PREFIX} | 
|  | 622 |  | 
|  | 623 | # Description of argument(s): | 
|  | 624 | # log_prefix_path    The location specifying where to create FFDC file(s). | 
|  | 625 |  | 
|  | 626 | # No-op by default if input is not supplied from command line. | 
|  | 627 | Return From Keyword If   "${OEM_REDFISH_PATH}" == "${EMPTY}" | 
|  | 628 |  | 
|  | 629 | # Login is needed to fetch Redfish information. | 
|  | 630 | # If login fails, return from keyword. | 
|  | 631 | ${status}=  Run Keyword And Return Status  Redfish.Login | 
|  | 632 | Return From Keyword If   ${status} == ${False} | 
|  | 633 |  | 
|  | 634 | # Get the Redfish resources and properties. | 
|  | 635 | ${json_data}=  redfish_utils.Enumerate Request  ${OEM_REDFISH_PATH} | 
|  | 636 |  | 
|  | 637 | @{ffdc_file_list}=  Create List | 
|  | 638 | ${logpath}=  Catenate  SEPARATOR=  ${log_prefix_path} | 
|  | 639 | ...  redfish_oem_resource_properties.txt | 
|  | 640 | Create File  ${logpath} | 
|  | 641 | Write Data To File  "${\n}${json_data}${\n}"  ${logpath} | 
|  | 642 |  | 
|  | 643 | Append To List  ${ffdc_file_list}  ${logpath} | 
|  | 644 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 645 | RETURN  ${ffdc_file_list} | 
| George Keishing | 985659a | 2021-06-23 02:52:13 -0500 | [diff] [blame] | 646 |  | 
|  | 647 |  | 
| George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 648 | Collect eSEL Log | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 649 | [Documentation]  Create raw and formatted eSEL files. | 
| Sridevi Ramesh | b180c9f | 2017-08-06 10:27:41 -0500 | [diff] [blame] | 650 | [Arguments]  ${log_prefix_path}=${LOG_PREFIX} | 
|  | 651 |  | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 652 | # NOTE: If no eSEL.pl program can be located, then no formatted eSEL file | 
|  | 653 | # will be generated. | 
|  | 654 |  | 
|  | 655 | # Description of argument(s): | 
|  | 656 | # log_prefix_path               The path prefix to be used in creating | 
|  | 657 | #                               eSEL file path names.  For example, if | 
|  | 658 | #                               log_prefix_path is | 
|  | 659 | #                               "/tmp/user1/dummy.181001.120000.", then | 
|  | 660 | #                               this keyword will create | 
|  | 661 | #                               /tmp/user1/dummy.181001.120000.esel (raw) | 
|  | 662 | #                               and | 
|  | 663 | #                               /tmp/user1/dummy.181001.120000.esel.txt | 
|  | 664 | #                               (formatted). | 
|  | 665 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 666 | @{ffdc_file_list}=  Create List | 
|  | 667 |  | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 668 | ${esels}=  Get Esels | 
|  | 669 | ${num_esels}=  Evaluate  len(${esels}) | 
|  | 670 | Rprint Vars  num_esels | 
|  | 671 | Return From Keyword If  ${num_esels} == ${0}  ${ffdc_file_list} | 
| George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 672 |  | 
| Sridevi Ramesh | b180c9f | 2017-08-06 10:27:41 -0500 | [diff] [blame] | 673 | ${logpath}=  Catenate  SEPARATOR=  ${log_prefix_path}  esel | 
| George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 674 | Create File  ${logpath} | 
| George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 675 |  | 
| Sushil Singh | 1988855 | 2020-06-08 02:14:52 -0500 | [diff] [blame] | 676 | FOR  ${esel}  IN  @{esels} | 
|  | 677 | Write Data To File  "${esel}"${\n}  ${logpath} | 
|  | 678 | END | 
| George Keishing | b1ca69b | 2017-03-31 14:36:42 -0500 | [diff] [blame] | 679 |  | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 680 | Append To List  ${ffdc_file_list}  ${logpath} | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 681 |  | 
|  | 682 | ${rc}  ${output}=  Shell Cmd  which eSEL.pl  show_err=0 | 
|  | 683 | Return From Keyword If  ${rc} != ${0}  ${ffdc_file_list} | 
|  | 684 |  | 
|  | 685 | Convert eSEL To Elog Format  ${logpath} | 
| Michael Walsh | 0192e9b | 2017-11-14 15:14:15 -0600 | [diff] [blame] | 686 | Append To List  ${ffdc_file_list}  ${logpath}.txt | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 687 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 688 | RETURN  ${ffdc_file_list} | 
| Michael Walsh | 63b70c0 | 2017-10-30 15:02:09 -0500 | [diff] [blame] | 689 |  | 
| George Keishing | b1ca69b | 2017-03-31 14:36:42 -0500 | [diff] [blame] | 690 |  | 
| George Keishing | b1ca69b | 2017-03-31 14:36:42 -0500 | [diff] [blame] | 691 | Convert eSEL To Elog Format | 
|  | 692 | [Documentation]  Execute parser tool on the eSEL data file to generate | 
| Michael Walsh | a30dac7 | 2017-04-04 17:56:23 -0500 | [diff] [blame] | 693 | ...              formatted error log. | 
| George Keishing | b1ca69b | 2017-03-31 14:36:42 -0500 | [diff] [blame] | 694 | [Arguments]  ${esel_file_path} | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 695 | # Description of argument(s): | 
| George Keishing | 7c6342b | 2018-11-02 14:27:13 -0500 | [diff] [blame] | 696 | # esel_file_path                The path to the file containing raw eSEL | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 697 | #                               data (e.g. | 
|  | 698 | #                               "/tmp/user1/dummy.181001.120000.esel"). | 
| George Keishing | b1ca69b | 2017-03-31 14:36:42 -0500 | [diff] [blame] | 699 |  | 
| Michael Walsh | a30dac7 | 2017-04-04 17:56:23 -0500 | [diff] [blame] | 700 | # Note: The only way to get eSEL.pl to put the output in a particular | 
|  | 701 | # directory is to cd to that directory. | 
|  | 702 | ${cmd_buf}=  Catenate  cd $(dirname ${esel_file_path}) ; eSEL.pl -l | 
|  | 703 | ...  ${esel_file_path} -p decode_obmc_data | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 704 | Qprint Issuing  ${cmd_buf} | 
| Michael Walsh | a30dac7 | 2017-04-04 17:56:23 -0500 | [diff] [blame] | 705 | Run  ${cmd_buf} | 
| Michael Walsh | 02c7060 | 2018-10-04 15:24:30 -0500 | [diff] [blame] | 706 | # The .binary file, which is generated by eSEL.pl, is of no use to us. | 
|  | 707 | Remove File  ${esel_file_path}.binary | 
| George Keishing | 671dd66 | 2021-05-28 03:26:30 -0500 | [diff] [blame] | 708 |  | 
|  | 709 |  | 
|  | 710 | OS Distro Type | 
|  | 711 | [Documentation]  Determine the host partition distro type | 
|  | 712 |  | 
|  | 713 | ${stdout}  ${stderr}  ${rc}=  OS Execute Command | 
|  | 714 | ...  . /etc/os-release; echo $ID  ignore_err=${1} | 
|  | 715 |  | 
|  | 716 | Return From Keyword If  ${rc} == ${0}  ${stdout} | 
|  | 717 |  | 
| George Keishing | 33d1503 | 2021-06-07 00:49:56 -0500 | [diff] [blame] | 718 | # If linux distro doesn't have os-release, check for uname. | 
| George Keishing | 671dd66 | 2021-05-28 03:26:30 -0500 | [diff] [blame] | 719 | ${stdout}  ${stderr}  ${rc}=  OS Execute Command  uname  ignore_err=${0} | 
|  | 720 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 721 | RETURN  ${stdout} | 
| Sridevi Ramesh | 886f34a | 2022-10-10 05:21:52 -0500 | [diff] [blame] | 722 |  | 
|  | 723 |  | 
|  | 724 | Get OS Distro Release Info | 
|  | 725 | [Documentation]  Get the host partition release info. | 
|  | 726 | ${stdout}  ${stderr}  ${rc}=  OS Execute Command | 
|  | 727 | ...  cat /etc/os-release  ignore_err=${1} | 
|  | 728 |  | 
|  | 729 | Return From Keyword If  ${rc} == ${0}  ${stdout} | 
|  | 730 |  | 
|  | 731 | # If linux distro doesn't have os-release, check for uname. | 
|  | 732 | ${stdout}  ${stderr}  ${rc}=  OS Execute Command  uname  ignore_err=${0} | 
|  | 733 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 734 | RETURN  ${stdout} |