blob: 5759ab715c6aa282c969203a58dcc5ec21f142b0 [file] [log] [blame]
George Keishing69e6f712016-09-12 06:30:09 -05001*** Settings ***
2Documentation Methods to execute commands on BMC and collect
3... data to a list of FFDC files
4
Michael Walsh265ae412018-11-16 15:32:03 -06005Resource openbmc_ffdc_utils.robot
6Resource rest_client.robot
7Resource utils.robot
8Resource list_utils.robot
9Resource logging_utils.robot
Steven Sombar2da175f2019-02-04 10:32:58 -060010Resource bmc_redfish_resource.robot
Michael Walsh265ae412018-11-16 15:32:03 -060011Library SSHLibrary
12Library OperatingSystem
13Library Collections
14Library String
15Library gen_print.py
16Library gen_cmd.py
17Library gen_robot_keyword.py
18Library dump_utils.py
19Library logging_utils.py
Gunnar Mills7e2cda22016-10-11 15:37:34 -050020
Michael Walshde5e9372018-11-15 11:28:23 -060021*** Variables ***
22
Michael Walsh265ae412018-11-16 15:32:03 -060023${FFDC_CMD_TIMEOUT} 240
Michael Walshde5e9372018-11-15 11:28:23 -060024
George Keishing69e6f712016-09-12 06:30:09 -050025*** Keywords ***
26
George Keishing69e6f712016-09-12 06:30:09 -050027# Method : Call FFDC Methods #
28# Execute the user define keywords from the FFDC List #
29# Unlike any other keywords this will call into the #
30# list of keywords defined in the FFDC list at one go #
George Keishing69e6f712016-09-12 06:30:09 -050031
32Call FFDC Methods
Michael Walshe844e9a2017-04-20 16:51:10 -050033 [Documentation] Call into FFDC Keyword index list.
34 [Arguments] ${ffdc_function_list}=${EMPTY}
George Keishing69e6f712016-09-12 06:30:09 -050035
Michael Walshe844e9a2017-04-20 16:51:10 -050036 # Description of argument(s):
37 # ffdc_function_list A colon-delimited list naming the kinds of FFDC that
Michael Walsh63b70c02017-10-30 15:02:09 -050038 # are to be collected
Michael Walshe844e9a2017-04-20 16:51:10 -050039 # (e.g. "FFDC Generic Report:BMC Specific Files").
40 # Acceptable values can be found in the description
41 # field of FFDC_METHOD_CALL in
42 # lib/openbmc_ffdc_list.py. Those values can be
43 # obtained via a call to 'Get FFDC Method Desc' (also
44 # from lib/openbmc_ffdc_list.py).
45
46 @{entries}= Get FFDC Method Index
Michael Walsh63b70c02017-10-30 15:02:09 -050047 # Example entries:
48 # entries:
49 # entries[0]: BMC LOGS
50
51 @{ffdc_file_list}= Create List
Michael Walshe844e9a2017-04-20 16:51:10 -050052 :FOR ${index} IN @{entries}
Michael Walsh63b70c02017-10-30 15:02:09 -050053 \ ${ffdc_file_sub_list}= Method Call Keyword List ${index}
54 ... ${ffdc_function_list}
55 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
56 ... ${ffdc_file_sub_list}
57
Michael Walsh6bad8412017-06-27 14:09:36 -050058 Run Key U SSHLibrary.Close All Connections
George Keishing69e6f712016-09-12 06:30:09 -050059
Michael Walsh63b70c02017-10-30 15:02:09 -050060 [Return] ${ffdc_file_list}
61
Steven Sombar2da175f2019-02-04 10:32:58 -060062
George Keishing69e6f712016-09-12 06:30:09 -050063Method Call Keyword List
Michael Walsh63b70c02017-10-30 15:02:09 -050064 [Documentation] Process FFDC request and return a list of generated files.
Michael Walshe844e9a2017-04-20 16:51:10 -050065 [Arguments] ${index} ${ffdc_function_list}=${EMPTY}
George Keishing69e6f712016-09-12 06:30:09 -050066
Michael Walshe844e9a2017-04-20 16:51:10 -050067 # Description of argument(s):
68 # index The index into the FFDC_METHOD_CALL dictionary (e.g.
69 # 'BMC LOGS').
70 # ffdc_function_list See ffdc_function_list description in
71 # "Call FFDC Methods" (above).
72
Michael Walsh63b70c02017-10-30 15:02:09 -050073 @{method_list}= Get FFDC Method Call ${index}
74 # Example method_list:
75 # method_list:
76 # method_list[0]:
77 # method_list[0][0]: FFDC Generic Report
78 # method_list[0][1]: BMC FFDC Manifest
79 # method_list[1]:
80 # method_list[1][0]: Get Request FFDC
81 # method_list[1][1]: BMC FFDC Get Requests
82 # (etc.)
Michael Walshe844e9a2017-04-20 16:51:10 -050083
84 # If function list is empty assign default (i.e. a list of all allowable
85 # values). In either case, convert ffdc_function_list from a string to
86 # a list.
87 @{ffdc_function_list}=
88 ... Run Keyword If '${ffdc_function_list}' == '${EMPTY}'
89 ... Get FFDC Method Desc ${index}
90 ... ELSE
91 ... Split String ${ffdc_function_list} separator=:
92
Michael Walsh63b70c02017-10-30 15:02:09 -050093 @{ffdc_file_list}= Create List
George Keishing69e6f712016-09-12 06:30:09 -050094 :FOR ${method} IN @{method_list}
Michael Walsh63b70c02017-10-30 15:02:09 -050095 \ ${ffdc_file_sub_list}= Execute Keyword Method ${method[0]}
96 ... ${method[1]} @{ffdc_function_list}
97 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
98 ... ${ffdc_file_sub_list}
99
100 [Return] ${ffdc_file_list}
101
George Keishing69e6f712016-09-12 06:30:09 -0500102
103Execute Keyword Method
Michael Walshe844e9a2017-04-20 16:51:10 -0500104 [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 Keishing69e6f712016-09-12 06:30:09 -0500108
Michael Walshe844e9a2017-04-20 16:51:10 -0500109 # 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 Keishing69e6f712016-09-12 06:30:09 -0500119
Michael Walsh63b70c02017-10-30 15:02:09 -0500120 @{ffdc_file_list}= Create List
Michael Walshe844e9a2017-04-20 16:51:10 -0500121
Michael Walsh63b70c02017-10-30 15:02:09 -0500122 ${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
127 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500128
George Keishing69e6f712016-09-12 06:30:09 -0500129# Method : BMC FFDC Manifest #
130# Execute command on BMC and write to ffdc_report.txt #
George Keishing69e6f712016-09-12 06:30:09 -0500131
132BMC FFDC Manifest
Michael Walsh63b70c02017-10-30 15:02:09 -0500133 [Documentation] Run the ssh commands from FFDC_BMC_CMD and return a list
134 ... of generated files.
George Keishing69e6f712016-09-12 06:30:09 -0500135
Michael Walsh63b70c02017-10-30 15:02:09 -0500136 @{ffdc_file_list}= Create List ${FFDC_FILE_PATH}
137 @{entries}= Get FFDC Cmd Index
138 :FOR ${index} IN @{entries}
139 \ Iterate BMC Command List Pairs ${index}
140
141 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500142
143
144Iterate BMC Command List Pairs
145 [Documentation] Feed in key pair list from dictionary to execute
146 [Arguments] ${key_index}
147
148 @{cmd_list}= Get ffdc bmc cmd ${key_index}
149 Set Suite Variable ${ENTRY_INDEX} ${key_index}
150 :FOR ${cmd} IN @{cmd_list}
151 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]}
152
153
154Execute Command and Write FFDC
Michael Walsh63b70c02017-10-30 15:02:09 -0500155 [Documentation] Run a command on the BMC or OS, write the output to the
156 ... specified file and return a list of generated files.
157 [Arguments] ${key_index} ${cmd} ${logpath}=${FFDC_FILE_PATH}
158 ... ${target}=BMC
George Keishing69e6f712016-09-12 06:30:09 -0500159
Michael Walsh63b70c02017-10-30 15:02:09 -0500160 Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}'
161 ... Write Cmd Output to FFDC File ${key_index} ${cmd}
162
163 @{ffdc_file_list}= Create List ${log_path}
George Keishing69e6f712016-09-12 06:30:09 -0500164
Michael Walshe53e47a2017-06-30 17:03:24 -0500165 ${cmd_buf}= Catenate ${target} Execute Command \ ${cmd} \ ignore_err=${1}
Michael Walsh265ae412018-11-16 15:32:03 -0600166 ... \ time_out=${FFDC_CMD_TIMEOUT}
Michael Walshe53e47a2017-06-30 17:03:24 -0500167 ${status} ${ret_values}= Run Key ${cmd_buf} ignore=${1}
Michael Walshde5e9372018-11-15 11:28:23 -0600168 # If the command times out, status will be 'FAIL'.
169 Return From Keyword If '${status}' == 'FAIL' ${ffdc_file_list}
Michael Walshe53e47a2017-06-30 17:03:24 -0500170
171 ${stdout}= Set Variable @{ret_values}[0]
172 ${stderr}= Set Variable @{ret_values}[1]
George Keishing69e6f712016-09-12 06:30:09 -0500173
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600174 # Write stdout on success and stderr/stdout to the file on failure.
175 Run Keyword If $stderr == '${EMPTY}'
Sweta Potthuri15e6d2f2017-02-28 03:10:02 -0600176 ... Write Data To File ${stdout}${\n} ${logpath}
177 ... ELSE Write Data To File
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600178 ... ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n}
179 ... ${logpath}
George Keishing69e6f712016-09-12 06:30:09 -0500180
Michael Walsh63b70c02017-10-30 15:02:09 -0500181 [Return] ${ffdc_file_list}
182
George Keishing69e6f712016-09-12 06:30:09 -0500183
George Keishing69e6f712016-09-12 06:30:09 -0500184# Method : BMC FFDC Files #
185# Execute command on BMC and write to individual file #
186# based on the file name pre-defined in the list #
George Keishing69e6f712016-09-12 06:30:09 -0500187
188BMC FFDC Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500189 [Documentation] Run the commands from FFDC_BMC_FILE and return a list of
190 ... generated files.
191
192 @{entries}= Get FFDC File Index
193 # Example of entries:
194 # entries:
195 # entries[0]: BMC FILES
196
197 @{ffdc_file_list}= Create List
198 :FOR ${index} IN @{entries}
199 \ ${ffdc_file_sub_list}= Create File and Write Data ${index}
200 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
201 ... ${ffdc_file_sub_list}
202
203 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500204
205
206Create File and Write Data
Michael Walsh63b70c02017-10-30 15:02:09 -0500207 [Documentation] Run commands from FFDC_BMC_FILE to create FFDC files and
208 ... return a list of generated files.
209 [Arguments] ${key_index}
George Keishing69e6f712016-09-12 06:30:09 -0500210
Michael Walsh63b70c02017-10-30 15:02:09 -0500211 # Description of argument(s):
212 # key_index The index into the FFDC_BMC_FILE dictionary.
213
214 @{ffdc_file_list}= Create List
215 @{cmd_list}= Get FFDC BMC File ${key_index}
George Keishing69e6f712016-09-12 06:30:09 -0500216 :FOR ${cmd} IN @{cmd_list}
Michael Walsh63b70c02017-10-30 15:02:09 -0500217 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
218 \ ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]}
219 ... ${cmd[1]} ${logpath}
220 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
221 ... ${ffdc_file_sub_list}
Sivas SRR0d657e82017-03-13 01:00:34 -0500222
Michael Walsh63b70c02017-10-30 15:02:09 -0500223 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500224
225
George Keishing69e6f712016-09-12 06:30:09 -0500226# Method : Log Test Case Status #
227# Creates test result history footprint for reference #
George Keishing69e6f712016-09-12 06:30:09 -0500228
229Log Test Case Status
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600230 [Documentation] Test case execution result history.
231 ... Create once and append to this file
232 ... logs/test_history.txt
233 ... Format Date:Test suite:Test case:Status
234 ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL
Michael Walshfa9f70f2017-04-21 16:00:18 -0500235
236 ${FFDC_DIR_PATH_STYLE}= Get Variable Value ${FFDC_DIR_PATH_STYLE}
237 ... ${EMPTY}
238 ${FFDC_DIR_PATH}= Get Variable Value ${FFDC_DIR_PATH} ${EMPTY}
239
240 Run Keyword If '${FFDC_DIR_PATH}' == '${EMPTY}' Set FFDC Defaults
241
242 Run Keyword If '${FFDC_DIR_PATH_STYLE}' == '${1}' Run Keywords
243 ... Set Global Variable ${FFDC_LOG_PATH} ${FFDC_DIR_PATH} AND
244 ... Set Global Variable ${TEST_HISTORY} ${FFDC_DIR_PATH}test_history.txt
245
George Keishing69e6f712016-09-12 06:30:09 -0500246 Create Directory ${FFDC_LOG_PATH}
247
248 ${exist}= Run Keyword and Return Status
249 ... OperatingSystem.File Should Exist ${TEST_HISTORY}
250
251 Run Keyword If '${exist}' == '${False}'
252 ... Create File ${TEST_HISTORY}
253
Michael Walshfa9f70f2017-04-21 16:00:18 -0500254 Rpvars TEST_HISTORY
255
George Keishing69e6f712016-09-12 06:30:09 -0500256 ${cur_time}= Get Current Time Stamp
257
258 Append To File ${TEST_HISTORY}
259 ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
260
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500261
262Log FFDC Get Requests
Michael Walsh63b70c02017-10-30 15:02:09 -0500263 [Documentation] Run the get requests associated with the key and return a
264 ... list of generated files.
265 [Arguments] ${key_index}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500266
Michael Walsh63b70c02017-10-30 15:02:09 -0500267 # Note: Output will be in JSON pretty_print format.
268
269 # Description of argument(s):
270 # key_index The key to the FFDC_GET_REQUEST dictionary that contains the
271 # get requests that are to be run.
272
273 @{ffdc_file_list}= Create List
274 @{cmd_list}= Get FFDC Get Request ${key_index}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500275 :FOR ${cmd} IN @{cmd_list}
Michael Walsh63b70c02017-10-30 15:02:09 -0500276 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
277 \ ${resp}= OpenBMC Get Request ${cmd[1]} quiet=${1}
278 \ ${status}= Run Keyword and Return Status
279 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
280 \ Run Keyword If '${status}' == '${False}' Continue For Loop
281 \ ${jsondata}= to json ${resp.content} pretty_print=True
282 \ Write Data To File ${\n}${jsondata}${\n} ${logpath}
283 \ Append To List ${ffdc_file_list} ${logpath}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500284
Michael Walsh63b70c02017-10-30 15:02:09 -0500285 [Return] ${ffdc_file_list}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500286
287BMC FFDC Get Requests
Michael Walsh63b70c02017-10-30 15:02:09 -0500288 [Documentation] Iterate over get request list and return a list of
289 ... generated files.
290
291 @{ffdc_file_list}= Create List
292
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500293 @{entries}= Get ffdc get request index
Michael Walsh63b70c02017-10-30 15:02:09 -0500294 # Example of entries:
295 # entries:
296 # entries[0]: GET REQUESTS
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500297 :FOR ${index} IN @{entries}
Michael Walsh63b70c02017-10-30 15:02:09 -0500298 \ ${ffdc_file_sub_list}= Log FFDC Get Requests ${index}
299 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
300 ... ${ffdc_file_sub_list}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500301
Michael Walsh63b70c02017-10-30 15:02:09 -0500302 [Return] ${ffdc_file_list}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500303
Michael Walsh63b70c02017-10-30 15:02:09 -0500304Log OS All distros FFDC
305 [Documentation] Run commands from FFDC_OS_ALL_DISTROS_FILE to create FFDC
306 ... files and return a list of generated files.
307 [Arguments] ${key_index}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500308
Michael Walsh63b70c02017-10-30 15:02:09 -0500309 # Description of argument(s):
310 # key_index The index into the FFDC_OS_ALL_DISTROS_FILE dictionary.
311
312 @{ffdc_file_list}= Create List
313
314 @{cmd_list}= Get FFDC OS All Distros Call ${key_index}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500315 :FOR ${cmd} IN @{cmd_list}
Michael Walsh63b70c02017-10-30 15:02:09 -0500316 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
317 \ ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]}
Steven Sombarfc024cb2019-04-22 11:16:16 -0500318 ... ${cmd[1]} ${logpath} target=OS
319 \ # scp it to the LOG_PREFIX ffdc directory.
320 \ Log To Console scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
321 \ scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
Michael Walsh63b70c02017-10-30 15:02:09 -0500322 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
323 ... ${ffdc_file_sub_list}
324
325 [Return] ${ffdc_file_list}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500326
327
Gunnar Millscce185d2016-10-17 17:04:15 -0500328Log OS SPECIFIC DISTRO FFDC
Michael Walsh63b70c02017-10-30 15:02:09 -0500329 [Documentation] Run commands from the FFDC_OS_<distro>_FILE to create FFDC
330 ... files and return a list of generated files.
331 [Arguments] ${key_index} ${linux_distro}
Gunnar Millscce185d2016-10-17 17:04:15 -0500332
Michael Walsh63b70c02017-10-30 15:02:09 -0500333 # Description of argument(s):
334 # key_index The index into the FFDC_OS_<distro>_FILE dictionary.
335 # linux_distro Your OS's linux distro (e.g. "UBUNTU", "RHEL", etc).
336
337 @{ffdc_file_list}= Create List
338
339 @{cmd_list}= Get FFDC OS Distro Call ${key_index} ${linux_distro}
Gunnar Millscce185d2016-10-17 17:04:15 -0500340 :FOR ${cmd} IN @{cmd_list}
Michael Walsh63b70c02017-10-30 15:02:09 -0500341 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
342 \ ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]}
343 ... ${cmd[1]} ${logpath} target=OS
Steven Sombarfc024cb2019-04-22 11:16:16 -0500344 \ Log To Console scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
345 \ scp.Get File /tmp/${cmd[0]}.txt ${LOG_PREFIX}${cmd[0]}.txt
Michael Walsh63b70c02017-10-30 15:02:09 -0500346 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
347 ... ${ffdc_file_sub_list}
348
349 [Return] ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500350
351
George Keishingca8c4c62016-10-14 10:08:40 -0500352OS FFDC Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500353 [Documentation] Run the commands from FFDC_OS_ALL_DISTROS_FILE to create
354 ... FFDC files and return a list of generated files.
Gunnar Millsaca140d2016-10-26 13:05:10 -0500355 [Arguments] ${OS_HOST}=${OS_HOST} ${OS_USERNAME}=${OS_USERNAME}
Michael Walsh63b70c02017-10-30 15:02:09 -0500356 ... ${OS_PASSWORD}=${OS_PASSWORD}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500357
Michael Walsh63b70c02017-10-30 15:02:09 -0500358 @{ffdc_file_list}= Create List
Gunnar Millsaca140d2016-10-26 13:05:10 -0500359
Michael Walsh63b70c02017-10-30 15:02:09 -0500360 Run Keyword If '${OS_HOST}' == '${EMPTY}' Run Keywords
361 ... Print Timen No OS Host provided so no OS FFDC will be done. AND
362 ... Return From Keyword ${ffdc_file_list}
Gunnar Millsaca140d2016-10-26 13:05:10 -0500363
Michael Walsh63b70c02017-10-30 15:02:09 -0500364 ${match_state}= Create Dictionary os_ping=^1$ os_login=^1$
365 ... os_run_cmd=^1$
366 ${status} ${ret_values}= Run Keyword and Ignore Error Check State
367 ... ${match_state} quiet=0
368
369 Run Keyword If '${status}' == 'FAIL' Run Keywords
Michael Walshc3b28d72017-11-16 10:43:14 -0600370 ... Print Timen The OS is not communicating so no OS FFDC will be done.\n
Michael Walsh63b70c02017-10-30 15:02:09 -0500371 ... AND
372 ... Return From Keyword ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500373
Michael Walshe53e47a2017-06-30 17:03:24 -0500374 ${stdout} ${stderr} ${rc}= OS Execute Command
375 ... . /etc/os-release; echo $ID ignore_err=${0}
376 Set Global Variable ${linux_distro} ${stdout}
Gunnar Millsaca140d2016-10-26 13:05:10 -0500377
Michael Walshe53e47a2017-06-30 17:03:24 -0500378 Rpvars linux_distro
Gunnar Millsaca140d2016-10-26 13:05:10 -0500379
Steven Sombarfc024cb2019-04-22 11:16:16 -0500380 scp.Open Connection
381 ... ${OS_HOST} username=${OS_USERNAME} password=${OS_PASSWORD}
382
Michael Walsh63b70c02017-10-30 15:02:09 -0500383 @{entries}= Get FFDC OS All Distros Index
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500384 :FOR ${index} IN @{entries}
Michael Walsh63b70c02017-10-30 15:02:09 -0500385 \ ${ffdc_file_sub_list}= Log OS All distros FFDC ${index}
386 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
387 ... ${ffdc_file_sub_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500388
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600389 Return From Keyword If
390 ... '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
Michael Walsh63b70c02017-10-30 15:02:09 -0500391 ... ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500392
393 @{entries}= Get ffdc os distro index ${linux_distro}
394 :FOR ${index} IN @{entries}
Michael Walsh63b70c02017-10-30 15:02:09 -0500395 \ ${ffdc_file_sub_list}= Log OS SPECIFIC DISTRO FFDC ${index}
396 ... ${linux_distro}
397 \ ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list}
398 ... ${ffdc_file_sub_list}
399
Steven Sombarfc024cb2019-04-22 11:16:16 -0500400 # Delete ffdc files still on OS and close scp.
401 OS Execute Command rm -rf /tmp/OS_*
402 scp.Close Connection
403
Michael Walsh63b70c02017-10-30 15:02:09 -0500404 [Return] ${ffdc_file_list}
George Keishing7a520222017-02-27 09:44:30 -0600405
406
Steven Sombar96de5732017-08-17 09:04:52 -0500407System Inventory Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500408 [Documentation] Copy systest os_inventory files and return a list of
409 ... generated files..
Steven Sombar96de5732017-08-17 09:04:52 -0500410 # The os_inventory files are the result of running
411 # systest/htx_hardbootme_test. If these files exist
412 # they are copied to the FFDC directory.
413 # Global variable ffdc_dir_path is the path name of the
414 # directory they are copied to.
Michael Walsh63b70c02017-10-30 15:02:09 -0500415
416 @{ffdc_file_list}= Create List
417
418 ${globex}= Set Variable os_inventory_*.json
419
420 @{file_list}= OperatingSystem.List Files In Directory . ${globex}
421
422 Copy Files ${globex} ${ffdc_dir_path}
423
424 : FOR ${file_name} IN @{file_list}
425 \ Append To List ${ffdc_file_list} ${ffdc_dir_path}${file_name}
426
427 Run Keyword and Ignore Error Remove Files ${globex}
428
429 [Return] ${ffdc_file_list}
Steven Sombar96de5732017-08-17 09:04:52 -0500430
431
George Keishing7a520222017-02-27 09:44:30 -0600432SCP Coredump Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500433 [Documentation] Copy core dump files from BMC to local system and return a
434 ... list of generated file names.
435
436 @{ffdc_file_list}= Create List
Michael Walshe53e47a2017-06-30 17:03:24 -0500437
George Keishing7a520222017-02-27 09:44:30 -0600438 # Check if core dump exist in the /tmp
Michael Walshe53e47a2017-06-30 17:03:24 -0500439 ${core_files} ${stderr} ${rc}= BMC Execute Command ls /tmp/core_*
Michael Walsh63b70c02017-10-30 15:02:09 -0500440 ... ignore_err=${1}
441 Run Keyword If '${rc}' != '${0}' Return From Keyword ${ffdc_file_list}
442
443 @{core_list}= Split String ${core_files}
George Keishing7a520222017-02-27 09:44:30 -0600444 # Copy the core files
Michael Walsh6bad8412017-06-27 14:09:36 -0500445 Run Key U Open Connection for SCP
George Keishing7a520222017-02-27 09:44:30 -0600446 :FOR ${index} IN @{core_list}
Michael Walsh63b70c02017-10-30 15:02:09 -0500447 \ ${ffdc_file_path}= Catenate ${LOG_PREFIX}${index.lstrip("/tmp/")}
448 \ ${status}= Run Keyword and Return Status
449 ... scp.Get File ${index} ${ffdc_file_path}
450 \ Run Keyword If '${status}' == '${False}' Continue For Loop
451 \ Append To List ${ffdc_file_list} ${ffdc_file_path}
George Keishing7a520222017-02-27 09:44:30 -0600452 # Remove the file from remote to avoid re-copying on next FFDC call
Michael Walsh63b70c02017-10-30 15:02:09 -0500453 \ BMC Execute Command rm ${index} ignore_err=${1}
Michael Walshe53e47a2017-06-30 17:03:24 -0500454 # I can't find a way to do this: scp.Close Connection
George Keishing7a520222017-02-27 09:44:30 -0600455
Michael Walsh63b70c02017-10-30 15:02:09 -0500456 [Return] ${ffdc_file_list}
457
Steven Sombar2da175f2019-02-04 10:32:58 -0600458
Sweta Potthuria82efd62017-10-18 05:34:59 -0500459SCP Dump Files
460 [Documentation] Copy all dump files from BMC to local system.
461
462 # Check if dumps exist
463 ${ffdc_file_list}= Scp Dumps ${FFDC_DIR_PATH} ${FFDC_PREFIX}
464
465 [Return] ${ffdc_file_list}
466
Steven Sombar2da175f2019-02-04 10:32:58 -0600467
Sweta Potthuria82efd62017-10-18 05:34:59 -0500468Collect Dump Log
469 [Documentation] Collect dumps from dump entry.
470 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
471
Steven Sombaraaaab222018-12-19 13:16:23 -0600472 ${data}= Read Properties ${DUMP_ENTRY_URI}enumerate quiet=${1}
Sweta Potthuria82efd62017-10-18 05:34:59 -0500473
474 # Grab the list of entries from dump/entry/
475 # The data shown below is the result of the "Get Dictionary Keys".
476 # Example:
477 # /xyz/openbmc_project/dump/entry/1
478 # /xyz/openbmc_project/dump/entry/2
479
480 ${dump_list}= Get Dictionary Keys ${data}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500481
Michael Walsh02c70602018-10-04 15:24:30 -0500482
Steven Sombar2da175f2019-02-04 10:32:58 -0600483Enumerate Redfish Resources
484 [Documentation] Enumerate /redfish/v1 resources and properties to
485 ... a file. Return a list which contains the file name.
486 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
487
488 # Description of argument(s):
489 # log_prefix_path The location specifying where to create FFDC file(s).
490
491 # Login is needed to fetch Redfish information.
492 # If login fails, return from keyword.
George Keishing97c93942019-03-04 12:45:07 -0600493 ${status}= Run Keyword And Return Status Redfish.Login
Steven Sombar2da175f2019-02-04 10:32:58 -0600494 Return From Keyword If ${status} == ${False}
495
496 # Get the Redfish resources and properties.
George Keishingf2613b72019-02-13 12:45:59 -0600497 ${json_data}= redfish_utils.Enumerate Request /redfish/v1
Steven Sombar2da175f2019-02-04 10:32:58 -0600498 # Typical output:
499 # {
500 # "@odata.id": "/redfish/v1",
501 # "@odata.type": "#ServiceRoot.v1_1_1.ServiceRoot",
502 # "AccountService": {
503 # "@odata.id": "/redfish/v1/AccountService"
504 # },
505 # "Chassis": {
506 # "@odata.id": "/redfish/v1/Chassis"
507 # },
508 # "Id": "RootService",
509 # "JsonSchemas": {
510 # "@odata.id": "/redfish/v1/JsonSchemas"
511 # },
512 # ..etc...
513 # }
514
515 @{ffdc_file_list}= Create List
516 ${logpath}= Catenate SEPARATOR= ${log_prefix_path}
517 ... redfish_resource_properties.txt
518 Create File ${logpath}
519 Write Data To File "${\n}${json_data}${\n}" ${logpath}
520
521 Append To List ${ffdc_file_list} ${logpath}
522
523 [Return] ${ffdc_file_list}
524
525
George Keishingeb7b4bc2017-03-13 12:04:28 -0500526Collect eSEL Log
Michael Walsh02c70602018-10-04 15:24:30 -0500527 [Documentation] Create raw and formatted eSEL files.
Sridevi Rameshb180c9f2017-08-06 10:27:41 -0500528 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
529
Michael Walsh02c70602018-10-04 15:24:30 -0500530 # NOTE: If no eSEL.pl program can be located, then no formatted eSEL file
531 # will be generated.
532
533 # Description of argument(s):
534 # log_prefix_path The path prefix to be used in creating
535 # eSEL file path names. For example, if
536 # log_prefix_path is
537 # "/tmp/user1/dummy.181001.120000.", then
538 # this keyword will create
539 # /tmp/user1/dummy.181001.120000.esel (raw)
540 # and
541 # /tmp/user1/dummy.181001.120000.esel.txt
542 # (formatted).
543
Michael Walsh63b70c02017-10-30 15:02:09 -0500544 @{ffdc_file_list}= Create List
545
Michael Walsh02c70602018-10-04 15:24:30 -0500546 ${esels}= Get Esels
547 ${num_esels}= Evaluate len(${esels})
548 Rprint Vars num_esels
549 Return From Keyword If ${num_esels} == ${0} ${ffdc_file_list}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500550
Sridevi Rameshb180c9f2017-08-06 10:27:41 -0500551 ${logpath}= Catenate SEPARATOR= ${log_prefix_path} esel
George Keishingeb7b4bc2017-03-13 12:04:28 -0500552 Create File ${logpath}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500553
Michael Walsh02c70602018-10-04 15:24:30 -0500554 :FOR ${esel} IN @{esels}
555 \ Write Data To File "${esel}"${\n} ${logpath}
George Keishingb1ca69b2017-03-31 14:36:42 -0500556
Michael Walsh63b70c02017-10-30 15:02:09 -0500557 Append To List ${ffdc_file_list} ${logpath}
Michael Walsh02c70602018-10-04 15:24:30 -0500558
559 ${rc} ${output}= Shell Cmd which eSEL.pl show_err=0
560 Return From Keyword If ${rc} != ${0} ${ffdc_file_list}
561
562 Convert eSEL To Elog Format ${logpath}
Michael Walsh0192e9b2017-11-14 15:14:15 -0600563 Append To List ${ffdc_file_list} ${logpath}.txt
Michael Walsh63b70c02017-10-30 15:02:09 -0500564
565 [Return] ${ffdc_file_list}
566
George Keishingb1ca69b2017-03-31 14:36:42 -0500567
George Keishingb1ca69b2017-03-31 14:36:42 -0500568Convert eSEL To Elog Format
569 [Documentation] Execute parser tool on the eSEL data file to generate
Michael Walsha30dac72017-04-04 17:56:23 -0500570 ... formatted error log.
George Keishingb1ca69b2017-03-31 14:36:42 -0500571 [Arguments] ${esel_file_path}
Michael Walsh02c70602018-10-04 15:24:30 -0500572 # Description of argument(s):
George Keishing7c6342b2018-11-02 14:27:13 -0500573 # esel_file_path The path to the file containing raw eSEL
Michael Walsh02c70602018-10-04 15:24:30 -0500574 # data (e.g.
575 # "/tmp/user1/dummy.181001.120000.esel").
George Keishingb1ca69b2017-03-31 14:36:42 -0500576
Michael Walsha30dac72017-04-04 17:56:23 -0500577 # Note: The only way to get eSEL.pl to put the output in a particular
578 # directory is to cd to that directory.
579 ${cmd_buf}= Catenate cd $(dirname ${esel_file_path}) ; eSEL.pl -l
580 ... ${esel_file_path} -p decode_obmc_data
Michael Walsh02c70602018-10-04 15:24:30 -0500581 Qprint Issuing ${cmd_buf}
Michael Walsha30dac72017-04-04 17:56:23 -0500582 Run ${cmd_buf}
Michael Walsh02c70602018-10-04 15:24:30 -0500583 # The .binary file, which is generated by eSEL.pl, is of no use to us.
584 Remove File ${esel_file_path}.binary