blob: 17ed80ad1bc44cfec840bf030179e0815f91ba95 [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
Sushil Singh19888552020-06-08 02:14:52 -050052 FOR ${index} IN @{entries}
53 ${ffdc_file_sub_list}= Method Call Keyword List ${index} ${ffdc_function_list}
54 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
55 END
Michael Walsh63b70c02017-10-30 15:02:09 -050056
Michael Walsh6bad8412017-06-27 14:09:36 -050057 Run Key U SSHLibrary.Close All Connections
George Keishing69e6f712016-09-12 06:30:09 -050058
Michael Walsh63b70c02017-10-30 15:02:09 -050059 [Return] ${ffdc_file_list}
60
Steven Sombar2da175f2019-02-04 10:32:58 -060061
George Keishing69e6f712016-09-12 06:30:09 -050062Method Call Keyword List
Michael Walsh63b70c02017-10-30 15:02:09 -050063 [Documentation] Process FFDC request and return a list of generated files.
Michael Walshe844e9a2017-04-20 16:51:10 -050064 [Arguments] ${index} ${ffdc_function_list}=${EMPTY}
George Keishing69e6f712016-09-12 06:30:09 -050065
Michael Walshe844e9a2017-04-20 16:51:10 -050066 # Description of argument(s):
67 # index The index into the FFDC_METHOD_CALL dictionary (e.g.
68 # 'BMC LOGS').
69 # ffdc_function_list See ffdc_function_list description in
70 # "Call FFDC Methods" (above).
71
Michael Walsh63b70c02017-10-30 15:02:09 -050072 @{method_list}= Get FFDC Method Call ${index}
73 # Example method_list:
74 # method_list:
75 # method_list[0]:
76 # method_list[0][0]: FFDC Generic Report
77 # method_list[0][1]: BMC FFDC Manifest
78 # method_list[1]:
79 # method_list[1][0]: Get Request FFDC
80 # method_list[1][1]: BMC FFDC Get Requests
81 # (etc.)
Michael Walshe844e9a2017-04-20 16:51:10 -050082
83 # If function list is empty assign default (i.e. a list of all allowable
84 # values). In either case, convert ffdc_function_list from a string to
85 # a list.
86 @{ffdc_function_list}=
87 ... Run Keyword If '${ffdc_function_list}' == '${EMPTY}'
88 ... Get FFDC Method Desc ${index}
89 ... ELSE
90 ... Split String ${ffdc_function_list} separator=:
91
Michael Walsh63b70c02017-10-30 15:02:09 -050092 @{ffdc_file_list}= Create List
Sushil Singh19888552020-06-08 02:14:52 -050093 FOR ${method} IN @{method_list}
94 ${ffdc_file_sub_list}= Execute Keyword Method ${method[0]} ${method[1]} @{ffdc_function_list}
95 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
96 END
Michael Walsh63b70c02017-10-30 15:02:09 -050097
98 [Return] ${ffdc_file_list}
99
George Keishing69e6f712016-09-12 06:30:09 -0500100
101Execute Keyword Method
Michael Walshe844e9a2017-04-20 16:51:10 -0500102 [Documentation] Call into BMC method keywords. Don't let one
103 ... failure skip the remaining. Get whatever data
104 ... it could gather at worse case scenario.
105 [Arguments] ${description} ${keyword_name} @{ffdc_function_list}
George Keishing69e6f712016-09-12 06:30:09 -0500106
Michael Walshe844e9a2017-04-20 16:51:10 -0500107 # Description of argument(s):
108 # description The description of the FFDC to be collected. This
109 # would be any value returned by
110 # 'Get FFDC Method Desc' (e.g. "FFDC Generic Report").
111 # keyword_name The name of the keyword to call to collect the FFDC
112 # data (again, see FFDC_METHOD_CALL).
113 # ffdc_function_list See ffdc_function_list description in
114 # "Call FFDC Methods" (above). The only difference is
115 # in this case, it should be a list rather than a
116 # colon-delimited value.
George Keishing69e6f712016-09-12 06:30:09 -0500117
Michael Walsh63b70c02017-10-30 15:02:09 -0500118 @{ffdc_file_list}= Create List
Michael Walshe844e9a2017-04-20 16:51:10 -0500119
Michael Walsh63b70c02017-10-30 15:02:09 -0500120 ${index}= Get Index From List ${ffdc_function_list} ${description}
121 Run Keyword If '${index}' == '${-1}' Return from Keyword
122 ... ${ffdc_file_list}
123
124 ${status} ${ffdc_file_list}= Run Key ${keyword_name} ignore=1
125 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500126
George Keishing69e6f712016-09-12 06:30:09 -0500127# Method : BMC FFDC Manifest #
128# Execute command on BMC and write to ffdc_report.txt #
George Keishing69e6f712016-09-12 06:30:09 -0500129
130BMC FFDC Manifest
Michael Walsh63b70c02017-10-30 15:02:09 -0500131 [Documentation] Run the ssh commands from FFDC_BMC_CMD and return a list
132 ... of generated files.
George Keishing69e6f712016-09-12 06:30:09 -0500133
Michael Walsh63b70c02017-10-30 15:02:09 -0500134 @{ffdc_file_list}= Create List ${FFDC_FILE_PATH}
135 @{entries}= Get FFDC Cmd Index
Sushil Singh19888552020-06-08 02:14:52 -0500136
137 FOR ${index} IN @{entries}
138 Iterate BMC Command List Pairs ${index}
139 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500140
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}
George Keishing69e6f712016-09-12 06:30:09 -0500150
Sushil Singh19888552020-06-08 02:14:52 -0500151 FOR ${cmd} IN @{cmd_list}
152 Execute Command and Write FFDC ${cmd[0]} ${cmd[1]}
153 END
George Keishing69e6f712016-09-12 06:30:09 -0500154
155Execute Command and Write FFDC
Michael Walsh63b70c02017-10-30 15:02:09 -0500156 [Documentation] Run a command on the BMC or OS, write the output to the
157 ... specified file and return a list of generated files.
158 [Arguments] ${key_index} ${cmd} ${logpath}=${FFDC_FILE_PATH}
159 ... ${target}=BMC
George Keishing69e6f712016-09-12 06:30:09 -0500160
Michael Walsh63b70c02017-10-30 15:02:09 -0500161 Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}'
162 ... Write Cmd Output to FFDC File ${key_index} ${cmd}
163
164 @{ffdc_file_list}= Create List ${log_path}
George Keishing69e6f712016-09-12 06:30:09 -0500165
Michael Walshe53e47a2017-06-30 17:03:24 -0500166 ${cmd_buf}= Catenate ${target} Execute Command \ ${cmd} \ ignore_err=${1}
Michael Walsh265ae412018-11-16 15:32:03 -0600167 ... \ time_out=${FFDC_CMD_TIMEOUT}
Michael Walshe53e47a2017-06-30 17:03:24 -0500168 ${status} ${ret_values}= Run Key ${cmd_buf} ignore=${1}
Michael Walshde5e9372018-11-15 11:28:23 -0600169 # If the command times out, status will be 'FAIL'.
170 Return From Keyword If '${status}' == 'FAIL' ${ffdc_file_list}
Michael Walshe53e47a2017-06-30 17:03:24 -0500171
Sushil Singh19888552020-06-08 02:14:52 -0500172 ${stdout}= Set Variable ${ret_values}[0]
173 ${stderr}= Set Variable ${ret_values}[1]
George Keishing69e6f712016-09-12 06:30:09 -0500174
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600175 # Write stdout on success and stderr/stdout to the file on failure.
176 Run Keyword If $stderr == '${EMPTY}'
Sweta Potthuri15e6d2f2017-02-28 03:10:02 -0600177 ... Write Data To File ${stdout}${\n} ${logpath}
178 ... ELSE Write Data To File
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600179 ... ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n}
180 ... ${logpath}
George Keishing69e6f712016-09-12 06:30:09 -0500181
Michael Walsh63b70c02017-10-30 15:02:09 -0500182 [Return] ${ffdc_file_list}
183
George Keishing69e6f712016-09-12 06:30:09 -0500184
George Keishing69e6f712016-09-12 06:30:09 -0500185# Method : BMC FFDC Files #
186# Execute command on BMC and write to individual file #
187# based on the file name pre-defined in the list #
George Keishing69e6f712016-09-12 06:30:09 -0500188
189BMC FFDC Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500190 [Documentation] Run the commands from FFDC_BMC_FILE and return a list of
191 ... generated files.
192
193 @{entries}= Get FFDC File Index
194 # Example of entries:
195 # entries:
196 # entries[0]: BMC FILES
197
Steven Sombara31f4c82019-08-01 16:00:23 -0500198 scp.Open Connection
vinaybs6b8110942020-01-29 23:15:29 -0600199 ... ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} port=${SSH_PORT}
Steven Sombara31f4c82019-08-01 16:00:23 -0500200
Michael Walsh63b70c02017-10-30 15:02:09 -0500201 @{ffdc_file_list}= Create List
Sushil Singh19888552020-06-08 02:14:52 -0500202
203 FOR ${index} IN @{entries}
204 ${ffdc_file_sub_list}= Create File and Write Data ${index}
205 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
206 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500207
Michael Walsh17eaafe2019-08-22 11:05:20 -0500208 BMC Execute Command rm -rf /tmp/BMC_*
Steven Sombara31f4c82019-08-01 16:00:23 -0500209 scp.Close Connection
210
Michael Walsh63b70c02017-10-30 15:02:09 -0500211 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500212
213
214Create File and Write Data
Michael Walsh63b70c02017-10-30 15:02:09 -0500215 [Documentation] Run commands from FFDC_BMC_FILE to create FFDC files and
216 ... return a list of generated files.
217 [Arguments] ${key_index}
George Keishing69e6f712016-09-12 06:30:09 -0500218
Michael Walsh63b70c02017-10-30 15:02:09 -0500219 # Description of argument(s):
220 # key_index The index into the FFDC_BMC_FILE dictionary.
221
222 @{ffdc_file_list}= Create List
223 @{cmd_list}= Get FFDC BMC File ${key_index}
Sushil Singh19888552020-06-08 02:14:52 -0500224
225 FOR ${cmd} IN @{cmd_list}
226 ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
227 ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
228 Run Key U scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}
229 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
230 END
Sivas SRR0d657e82017-03-13 01:00:34 -0500231
Michael Walsh63b70c02017-10-30 15:02:09 -0500232 [Return] ${ffdc_file_list}
George Keishing69e6f712016-09-12 06:30:09 -0500233
234
George Keishing69e6f712016-09-12 06:30:09 -0500235# Method : Log Test Case Status #
236# Creates test result history footprint for reference #
George Keishing69e6f712016-09-12 06:30:09 -0500237
238Log Test Case Status
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600239 [Documentation] Test case execution result history.
240 ... Create once and append to this file
241 ... logs/test_history.txt
242 ... Format Date:Test suite:Test case:Status
243 ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL
Michael Walshfa9f70f2017-04-21 16:00:18 -0500244
245 ${FFDC_DIR_PATH_STYLE}= Get Variable Value ${FFDC_DIR_PATH_STYLE}
246 ... ${EMPTY}
247 ${FFDC_DIR_PATH}= Get Variable Value ${FFDC_DIR_PATH} ${EMPTY}
248
249 Run Keyword If '${FFDC_DIR_PATH}' == '${EMPTY}' Set FFDC Defaults
250
251 Run Keyword If '${FFDC_DIR_PATH_STYLE}' == '${1}' Run Keywords
252 ... Set Global Variable ${FFDC_LOG_PATH} ${FFDC_DIR_PATH} AND
253 ... Set Global Variable ${TEST_HISTORY} ${FFDC_DIR_PATH}test_history.txt
254
George Keishing69e6f712016-09-12 06:30:09 -0500255 Create Directory ${FFDC_LOG_PATH}
256
257 ${exist}= Run Keyword and Return Status
258 ... OperatingSystem.File Should Exist ${TEST_HISTORY}
259
260 Run Keyword If '${exist}' == '${False}'
261 ... Create File ${TEST_HISTORY}
262
Michael Walshfa9f70f2017-04-21 16:00:18 -0500263 Rpvars TEST_HISTORY
264
George Keishing69e6f712016-09-12 06:30:09 -0500265 ${cur_time}= Get Current Time Stamp
266
267 Append To File ${TEST_HISTORY}
268 ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
269
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500270
271Log FFDC Get Requests
Michael Walsh63b70c02017-10-30 15:02:09 -0500272 [Documentation] Run the get requests associated with the key and return a
273 ... list of generated files.
274 [Arguments] ${key_index}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500275
Michael Walsh63b70c02017-10-30 15:02:09 -0500276 # Note: Output will be in JSON pretty_print format.
277
278 # Description of argument(s):
279 # key_index The key to the FFDC_GET_REQUEST dictionary that contains the
280 # get requests that are to be run.
281
282 @{ffdc_file_list}= Create List
283 @{cmd_list}= Get FFDC Get Request ${key_index}
Sushil Singh19888552020-06-08 02:14:52 -0500284
285 FOR ${cmd} IN @{cmd_list}
286 ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
George Keishingccd20e12020-07-29 11:14:26 -0500287 ${resp}= OpenBMC Get Request ${cmd[1]} quiet=${1} timeout=${30}
Sushil Singh19888552020-06-08 02:14:52 -0500288 ${status}= Run Keyword and Return Status Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
289 Run Keyword If '${status}' == '${False}' Continue For Loop
290 ${jsondata}= to json ${resp.content} pretty_print=True
291 Write Data To File ${\n}${jsondata}${\n} ${logpath}
292 Append To List ${ffdc_file_list} ${logpath}
293 END
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500294
Michael Walsh63b70c02017-10-30 15:02:09 -0500295 [Return] ${ffdc_file_list}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500296
297BMC FFDC Get Requests
Michael Walsh63b70c02017-10-30 15:02:09 -0500298 [Documentation] Iterate over get request list and return a list of
299 ... generated files.
300
301 @{ffdc_file_list}= Create List
302
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500303 @{entries}= Get ffdc get request index
Michael Walsh63b70c02017-10-30 15:02:09 -0500304 # Example of entries:
305 # entries:
306 # entries[0]: GET REQUESTS
Sushil Singh19888552020-06-08 02:14:52 -0500307
308 FOR ${index} IN @{entries}
309 ${ffdc_file_sub_list}= Log FFDC Get Requests ${index}
310 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
311 END
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500312
Michael Walsh63b70c02017-10-30 15:02:09 -0500313 [Return] ${ffdc_file_list}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500314
Michael Walsh63b70c02017-10-30 15:02:09 -0500315Log OS All distros FFDC
316 [Documentation] Run commands from FFDC_OS_ALL_DISTROS_FILE to create FFDC
317 ... files and return a list of generated files.
318 [Arguments] ${key_index}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500319
Michael Walsh63b70c02017-10-30 15:02:09 -0500320 # Description of argument(s):
321 # key_index The index into the FFDC_OS_ALL_DISTROS_FILE dictionary.
322
323 @{ffdc_file_list}= Create List
324
325 @{cmd_list}= Get FFDC OS All Distros Call ${key_index}
Sushil Singh19888552020-06-08 02:14:52 -0500326
327 FOR ${cmd} IN @{cmd_list}
328 ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
329 ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} target=OS
330 # scp it to the LOG_PREFIX ffdc directory.
331 Run Key U scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}
332 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
333 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500334
335 [Return] ${ffdc_file_list}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500336
337
Gunnar Millscce185d2016-10-17 17:04:15 -0500338Log OS SPECIFIC DISTRO FFDC
Michael Walsh63b70c02017-10-30 15:02:09 -0500339 [Documentation] Run commands from the FFDC_OS_<distro>_FILE to create FFDC
340 ... files and return a list of generated files.
341 [Arguments] ${key_index} ${linux_distro}
Gunnar Millscce185d2016-10-17 17:04:15 -0500342
Michael Walsh63b70c02017-10-30 15:02:09 -0500343 # Description of argument(s):
344 # key_index The index into the FFDC_OS_<distro>_FILE dictionary.
345 # linux_distro Your OS's linux distro (e.g. "UBUNTU", "RHEL", etc).
346
George Keishing671dd662021-05-28 03:26:30 -0500347 Log To Console Collecting log for ${linux_distro}
348
Michael Walsh63b70c02017-10-30 15:02:09 -0500349 @{ffdc_file_list}= Create List
350
351 @{cmd_list}= Get FFDC OS Distro Call ${key_index} ${linux_distro}
Sushil Singh19888552020-06-08 02:14:52 -0500352
353 FOR ${cmd} IN @{cmd_list}
354 ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
355 ${ffdc_file_sub_list}= Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath} target=OS
356 Run Key U scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}
357 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
George Keishing4609d2f2021-05-28 04:40:58 -0500358 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500359
Steven Sombare70acbe2019-08-20 14:37:47 -0500360 # Get the name of the sosreport file.
361 ${sosreport_file_path} ${stderr} ${rc}= OS Execute Command
362 ... ls /tmp/sosreport*FFDC*tar.xz ignore_err=${True}
363 # Example: sosreport_file_path="/tmp/sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
364
365 # Return if there is no sosreport file.
366 Return From Keyword If ${rc} != ${0} ${ffdc_file_list}
367
368 ${sosreport_dir_path} ${sosreport_file_name}= Split Path ${sosreport_file_path}
369 # Example: sosreport_dir_path="/tmp",
370 # sosreport_file_name="sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
371
372 # Location where the sosreport file will be copied to.
373 ${local_sosreport_file_path}= Set Variable ${LOG_PREFIX}OS_${sosreport_file_name}
374
375 # Change file permissions otherwise scp will not see the file.
376 OS Execute Command chmod 644 ${sosreport_file_path}
377
378 # SCP the sosreport file from the OS.
379 Run Key U scp.Get File \ ${sosreport_file_path} \ ${local_sosreport_file_path}
380
381 # Add the file location to the ffdc_file_list.
382 Append To List ${ffdc_file_list} ${local_sosreport_file_path}
383
Michael Walsh63b70c02017-10-30 15:02:09 -0500384 [Return] ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500385
386
George Keishingca8c4c62016-10-14 10:08:40 -0500387OS FFDC Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500388 [Documentation] Run the commands from FFDC_OS_ALL_DISTROS_FILE to create
389 ... FFDC files and return a list of generated files.
Gunnar Millsaca140d2016-10-26 13:05:10 -0500390 [Arguments] ${OS_HOST}=${OS_HOST} ${OS_USERNAME}=${OS_USERNAME}
Michael Walsh63b70c02017-10-30 15:02:09 -0500391 ... ${OS_PASSWORD}=${OS_PASSWORD}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500392
Michael Walsh63b70c02017-10-30 15:02:09 -0500393 @{ffdc_file_list}= Create List
Gunnar Millsaca140d2016-10-26 13:05:10 -0500394
Michael Walsh63b70c02017-10-30 15:02:09 -0500395 Run Keyword If '${OS_HOST}' == '${EMPTY}' Run Keywords
396 ... Print Timen No OS Host provided so no OS FFDC will be done. AND
397 ... Return From Keyword ${ffdc_file_list}
Gunnar Millsaca140d2016-10-26 13:05:10 -0500398
Michael Walsh63b70c02017-10-30 15:02:09 -0500399 ${match_state}= Create Dictionary os_ping=^1$ os_login=^1$
400 ... os_run_cmd=^1$
401 ${status} ${ret_values}= Run Keyword and Ignore Error Check State
402 ... ${match_state} quiet=0
403
404 Run Keyword If '${status}' == 'FAIL' Run Keywords
Michael Walshc3b28d72017-11-16 10:43:14 -0600405 ... Print Timen The OS is not communicating so no OS FFDC will be done.\n
Michael Walsh63b70c02017-10-30 15:02:09 -0500406 ... AND
407 ... Return From Keyword ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500408
George Keishing671dd662021-05-28 03:26:30 -0500409 ${stdout}= OS Distro Type
410
Michael Walshe53e47a2017-06-30 17:03:24 -0500411 Set Global Variable ${linux_distro} ${stdout}
Gunnar Millsaca140d2016-10-26 13:05:10 -0500412
Michael Walshe53e47a2017-06-30 17:03:24 -0500413 Rpvars linux_distro
Gunnar Millsaca140d2016-10-26 13:05:10 -0500414
Steven Sombarfc024cb2019-04-22 11:16:16 -0500415 scp.Open Connection
416 ... ${OS_HOST} username=${OS_USERNAME} password=${OS_PASSWORD}
417
Michael Walsh63b70c02017-10-30 15:02:09 -0500418 @{entries}= Get FFDC OS All Distros Index
Sushil Singh19888552020-06-08 02:14:52 -0500419
420 FOR ${index} IN @{entries}
421 ${ffdc_file_sub_list}= Log OS All distros FFDC ${index}
422 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
423 END
Gunnar Millscce185d2016-10-17 17:04:15 -0500424
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600425 Return From Keyword If
426 ... '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
Michael Walsh63b70c02017-10-30 15:02:09 -0500427 ... ${ffdc_file_list}
Gunnar Millscce185d2016-10-17 17:04:15 -0500428
429 @{entries}= Get ffdc os distro index ${linux_distro}
Sushil Singh19888552020-06-08 02:14:52 -0500430
431 FOR ${index} IN @{entries}
432 ${ffdc_file_sub_list}= Log OS SPECIFIC DISTRO FFDC ${index} ${linux_distro}
433 ${ffdc_file_list}= Smart Combine Lists ${ffdc_file_list} ${ffdc_file_sub_list}
434 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500435
Steven Sombarfc024cb2019-04-22 11:16:16 -0500436 # Delete ffdc files still on OS and close scp.
Steven Sombare70acbe2019-08-20 14:37:47 -0500437 OS Execute Command rm -rf /tmp/OS_* /tmp/sosreport*FFDC* ignore_err=${True}
Steven Sombarfc024cb2019-04-22 11:16:16 -0500438 scp.Close Connection
439
Michael Walsh63b70c02017-10-30 15:02:09 -0500440 [Return] ${ffdc_file_list}
George Keishing7a520222017-02-27 09:44:30 -0600441
442
Steven Sombar96de5732017-08-17 09:04:52 -0500443System Inventory Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500444 [Documentation] Copy systest os_inventory files and return a list of
445 ... generated files..
Steven Sombar96de5732017-08-17 09:04:52 -0500446 # The os_inventory files are the result of running
447 # systest/htx_hardbootme_test. If these files exist
448 # they are copied to the FFDC directory.
449 # Global variable ffdc_dir_path is the path name of the
450 # directory they are copied to.
Michael Walsh63b70c02017-10-30 15:02:09 -0500451
452 @{ffdc_file_list}= Create List
453
454 ${globex}= Set Variable os_inventory_*.json
455
456 @{file_list}= OperatingSystem.List Files In Directory . ${globex}
457
458 Copy Files ${globex} ${ffdc_dir_path}
459
Sushil Singh19888552020-06-08 02:14:52 -0500460 FOR ${file_name} IN @{file_list}
461 Append To List ${ffdc_file_list} ${ffdc_dir_path}${file_name}
462 END
Michael Walsh63b70c02017-10-30 15:02:09 -0500463
464 Run Keyword and Ignore Error Remove Files ${globex}
465
466 [Return] ${ffdc_file_list}
Steven Sombar96de5732017-08-17 09:04:52 -0500467
468
George Keishing7a520222017-02-27 09:44:30 -0600469SCP Coredump Files
Michael Walsh63b70c02017-10-30 15:02:09 -0500470 [Documentation] Copy core dump files from BMC to local system and return a
471 ... list of generated file names.
472
473 @{ffdc_file_list}= Create List
Michael Walshe53e47a2017-06-30 17:03:24 -0500474
George Keishing7a520222017-02-27 09:44:30 -0600475 # Check if core dump exist in the /tmp
Michael Walshe53e47a2017-06-30 17:03:24 -0500476 ${core_files} ${stderr} ${rc}= BMC Execute Command ls /tmp/core_*
Michael Walsh63b70c02017-10-30 15:02:09 -0500477 ... ignore_err=${1}
478 Run Keyword If '${rc}' != '${0}' Return From Keyword ${ffdc_file_list}
479
480 @{core_list}= Split String ${core_files}
George Keishing7a520222017-02-27 09:44:30 -0600481 # Copy the core files
Michael Walsh6bad8412017-06-27 14:09:36 -0500482 Run Key U Open Connection for SCP
Sushil Singh19888552020-06-08 02:14:52 -0500483
484 FOR ${index} IN @{core_list}
485 ${ffdc_file_path}= Catenate ${LOG_PREFIX}${index.lstrip("/tmp/")}
486 ${status}= Run Keyword and Return Status scp.Get File ${index} ${ffdc_file_path}
487 Run Keyword If '${status}' == '${False}' Continue For Loop
488 Append To List ${ffdc_file_list} ${ffdc_file_path}
489
490 # Remove the file from remote to avoid re-copying on next FFDC call
491
492 BMC Execute Command rm ${index} ignore_err=${1}
493 # I can't find a way to do this: scp.Close Connection
494
495 END
George Keishing7a520222017-02-27 09:44:30 -0600496
Michael Walsh63b70c02017-10-30 15:02:09 -0500497 [Return] ${ffdc_file_list}
498
Steven Sombar2da175f2019-02-04 10:32:58 -0600499
Sweta Potthuria82efd62017-10-18 05:34:59 -0500500SCP Dump Files
501 [Documentation] Copy all dump files from BMC to local system.
502
503 # Check if dumps exist
504 ${ffdc_file_list}= Scp Dumps ${FFDC_DIR_PATH} ${FFDC_PREFIX}
505
506 [Return] ${ffdc_file_list}
507
Steven Sombar2da175f2019-02-04 10:32:58 -0600508
George Keishing1165a022021-05-19 06:23:13 -0500509SCP Dump HB Files
510 [Documentation] Copy all HB dump files from BMC to local system.
511
512 # Check if dumps exist
513 ${ffdc_file_list}= Scp Dumps HB ${FFDC_DIR_PATH} ${FFDC_PREFIX}
514
515 [Return] ${ffdc_file_list}
516
517
Sweta Potthuria82efd62017-10-18 05:34:59 -0500518Collect Dump Log
519 [Documentation] Collect dumps from dump entry.
520 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
521
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500522 ${resp}= OpenBMC Get Request ${DUMP_URI}
523 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
524 ... Set Test Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
525
George Keishingccd20e12020-07-29 11:14:26 -0500526 ${data}= Read Properties ${DUMP_ENTRY_URI}enumerate quiet=${1} timeout=${30}
Sweta Potthuria82efd62017-10-18 05:34:59 -0500527
528 # Grab the list of entries from dump/entry/
529 # The data shown below is the result of the "Get Dictionary Keys".
530 # Example:
531 # /xyz/openbmc_project/dump/entry/1
532 # /xyz/openbmc_project/dump/entry/2
533
534 ${dump_list}= Get Dictionary Keys ${data}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500535
Michael Walsh02c70602018-10-04 15:24:30 -0500536
George Keishingbe396b82020-03-23 10:23:58 -0500537Collect PEL Log
538 [Documentation] Collect PEL files from from BMC.
539
540 Create Directory ${FFDC_DIR_PATH}${/}pel_files/
541 scp.Get File /var/lib/phosphor-logging/extensions/pels/logs/
542 ... ${FFDC_DIR_PATH}${/}pel_files recursive=True
543
544
Steven Sombar2da175f2019-02-04 10:32:58 -0600545Enumerate Redfish Resources
546 [Documentation] Enumerate /redfish/v1 resources and properties to
547 ... a file. Return a list which contains the file name.
548 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
549
550 # Description of argument(s):
551 # log_prefix_path The location specifying where to create FFDC file(s).
552
553 # Login is needed to fetch Redfish information.
554 # If login fails, return from keyword.
George Keishing97c93942019-03-04 12:45:07 -0600555 ${status}= Run Keyword And Return Status Redfish.Login
Steven Sombar2da175f2019-02-04 10:32:58 -0600556 Return From Keyword If ${status} == ${False}
557
558 # Get the Redfish resources and properties.
George Keishingf2613b72019-02-13 12:45:59 -0600559 ${json_data}= redfish_utils.Enumerate Request /redfish/v1
Steven Sombar2da175f2019-02-04 10:32:58 -0600560 # Typical output:
561 # {
562 # "@odata.id": "/redfish/v1",
563 # "@odata.type": "#ServiceRoot.v1_1_1.ServiceRoot",
564 # "AccountService": {
565 # "@odata.id": "/redfish/v1/AccountService"
566 # },
567 # "Chassis": {
568 # "@odata.id": "/redfish/v1/Chassis"
569 # },
570 # "Id": "RootService",
571 # "JsonSchemas": {
572 # "@odata.id": "/redfish/v1/JsonSchemas"
573 # },
574 # ..etc...
575 # }
576
577 @{ffdc_file_list}= Create List
578 ${logpath}= Catenate SEPARATOR= ${log_prefix_path}
579 ... redfish_resource_properties.txt
580 Create File ${logpath}
581 Write Data To File "${\n}${json_data}${\n}" ${logpath}
582
583 Append To List ${ffdc_file_list} ${logpath}
584
585 [Return] ${ffdc_file_list}
586
587
George Keishingeb7b4bc2017-03-13 12:04:28 -0500588Collect eSEL Log
Michael Walsh02c70602018-10-04 15:24:30 -0500589 [Documentation] Create raw and formatted eSEL files.
Sridevi Rameshb180c9f2017-08-06 10:27:41 -0500590 [Arguments] ${log_prefix_path}=${LOG_PREFIX}
591
Michael Walsh02c70602018-10-04 15:24:30 -0500592 # NOTE: If no eSEL.pl program can be located, then no formatted eSEL file
593 # will be generated.
594
595 # Description of argument(s):
596 # log_prefix_path The path prefix to be used in creating
597 # eSEL file path names. For example, if
598 # log_prefix_path is
599 # "/tmp/user1/dummy.181001.120000.", then
600 # this keyword will create
601 # /tmp/user1/dummy.181001.120000.esel (raw)
602 # and
603 # /tmp/user1/dummy.181001.120000.esel.txt
604 # (formatted).
605
Michael Walsh63b70c02017-10-30 15:02:09 -0500606 @{ffdc_file_list}= Create List
607
Michael Walsh02c70602018-10-04 15:24:30 -0500608 ${esels}= Get Esels
609 ${num_esels}= Evaluate len(${esels})
610 Rprint Vars num_esels
611 Return From Keyword If ${num_esels} == ${0} ${ffdc_file_list}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500612
Sridevi Rameshb180c9f2017-08-06 10:27:41 -0500613 ${logpath}= Catenate SEPARATOR= ${log_prefix_path} esel
George Keishingeb7b4bc2017-03-13 12:04:28 -0500614 Create File ${logpath}
George Keishingeb7b4bc2017-03-13 12:04:28 -0500615
Sushil Singh19888552020-06-08 02:14:52 -0500616 FOR ${esel} IN @{esels}
617 Write Data To File "${esel}"${\n} ${logpath}
618 END
George Keishingb1ca69b2017-03-31 14:36:42 -0500619
Michael Walsh63b70c02017-10-30 15:02:09 -0500620 Append To List ${ffdc_file_list} ${logpath}
Michael Walsh02c70602018-10-04 15:24:30 -0500621
622 ${rc} ${output}= Shell Cmd which eSEL.pl show_err=0
623 Return From Keyword If ${rc} != ${0} ${ffdc_file_list}
624
625 Convert eSEL To Elog Format ${logpath}
Michael Walsh0192e9b2017-11-14 15:14:15 -0600626 Append To List ${ffdc_file_list} ${logpath}.txt
Michael Walsh63b70c02017-10-30 15:02:09 -0500627
628 [Return] ${ffdc_file_list}
629
George Keishingb1ca69b2017-03-31 14:36:42 -0500630
George Keishingb1ca69b2017-03-31 14:36:42 -0500631Convert eSEL To Elog Format
632 [Documentation] Execute parser tool on the eSEL data file to generate
Michael Walsha30dac72017-04-04 17:56:23 -0500633 ... formatted error log.
George Keishingb1ca69b2017-03-31 14:36:42 -0500634 [Arguments] ${esel_file_path}
Michael Walsh02c70602018-10-04 15:24:30 -0500635 # Description of argument(s):
George Keishing7c6342b2018-11-02 14:27:13 -0500636 # esel_file_path The path to the file containing raw eSEL
Michael Walsh02c70602018-10-04 15:24:30 -0500637 # data (e.g.
638 # "/tmp/user1/dummy.181001.120000.esel").
George Keishingb1ca69b2017-03-31 14:36:42 -0500639
Michael Walsha30dac72017-04-04 17:56:23 -0500640 # Note: The only way to get eSEL.pl to put the output in a particular
641 # directory is to cd to that directory.
642 ${cmd_buf}= Catenate cd $(dirname ${esel_file_path}) ; eSEL.pl -l
643 ... ${esel_file_path} -p decode_obmc_data
Michael Walsh02c70602018-10-04 15:24:30 -0500644 Qprint Issuing ${cmd_buf}
Michael Walsha30dac72017-04-04 17:56:23 -0500645 Run ${cmd_buf}
Michael Walsh02c70602018-10-04 15:24:30 -0500646 # The .binary file, which is generated by eSEL.pl, is of no use to us.
647 Remove File ${esel_file_path}.binary
George Keishing671dd662021-05-28 03:26:30 -0500648
649
650OS Distro Type
651 [Documentation] Determine the host partition distro type
652
653 ${stdout} ${stderr} ${rc}= OS Execute Command
654 ... . /etc/os-release; echo $ID ignore_err=${1}
655
656 Return From Keyword If ${rc} == ${0} ${stdout}
657
George Keishing33d15032021-06-07 00:49:56 -0500658 # If linux distro doesn't have os-release, check for uname.
George Keishing671dd662021-05-28 03:26:30 -0500659 ${stdout} ${stderr} ${rc}= OS Execute Command uname ignore_err=${0}
660
661 [Return] ${stdout}