1*** Settings ***
2Documentation      Methods to execute commands on BMC and collect
3...                data to a list of FFDC files
4
5Resource               openbmc_ffdc_utils.robot
6Resource               rest_client.robot
7Resource               utils.robot
8Resource               list_utils.robot
9Resource               logging_utils.robot
10Resource               bmc_redfish_resource.robot
11Library                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
20
21*** Variables ***
22
23${FFDC_CMD_TIMEOUT}    240
24
25*** Keywords ***
26
27# 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 #
31
32Call FFDC Methods
33    [Documentation]   Call into FFDC Keyword index list.
34    [Arguments]  ${ffdc_function_list}=${EMPTY}
35
36    # Description of argument(s):
37    # ffdc_function_list  A colon-delimited list naming the kinds of FFDC that
38    #                     are to be collected
39    #                     (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
47    # Example entries:
48    # entries:
49    #   entries[0]:  BMC LOGS
50
51    @{ffdc_file_list}=  Create List
52    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
56
57    Run Key U  SSHLibrary.Close All Connections
58
59    [Return]  ${ffdc_file_list}
60
61
62Method Call Keyword List
63    [Documentation]  Process FFDC request and return a list of generated files.
64    [Arguments]  ${index}  ${ffdc_function_list}=${EMPTY}
65
66    # 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
72    @{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.)
82
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
92    @{ffdc_file_list}=  Create List
93    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
97
98    [Return]  ${ffdc_file_list}
99
100
101Execute Keyword Method
102    [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}
106
107    # 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.
117
118    @{ffdc_file_list}=  Create List
119
120    ${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}
126
127# Method : BMC FFDC Manifest                                   #
128#          Execute command on BMC and write to ffdc_report.txt #
129
130BMC FFDC Manifest
131    [Documentation]  Run the ssh commands from FFDC_BMC_CMD and return a list
132    ...              of generated files.
133
134    @{ffdc_file_list}=  Create List  ${FFDC_FILE_PATH}
135    @{entries}=  Get FFDC Cmd Index
136
137    FOR  ${index}  IN  @{entries}
138      Iterate BMC Command List Pairs  ${index}
139    END
140
141    [Return]  ${ffdc_file_list}
142
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
151    FOR  ${cmd}  IN  @{cmd_list}
152      Execute Command and Write FFDC    ${cmd[0]}  ${cmd[1]}
153    END
154
155Execute Command and Write FFDC
156    [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
160
161    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}
165
166    ${cmd_buf}=  Catenate  ${target} Execute Command \ ${cmd} \ ignore_err=${1}
167    ...  \ time_out=${FFDC_CMD_TIMEOUT}
168    ${status}  ${ret_values}=  Run Key  ${cmd_buf}  ignore=${1}
169    # If the command times out, status will be 'FAIL'.
170    Return From Keyword If  '${status}' == 'FAIL'  ${ffdc_file_list}
171
172    ${stdout}=  Set Variable  ${ret_values}[0]
173    ${stderr}=  Set Variable  ${ret_values}[1]
174
175    # Write stdout on success and stderr/stdout to the file on failure.
176    Run Keyword If  $stderr == '${EMPTY}'
177    ...    Write Data To File  ${stdout}${\n}  ${logpath}
178    ...  ELSE  Write Data To File
179    ...    ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n}
180    ...    ${logpath}
181
182    [Return]  ${ffdc_file_list}
183
184
185# 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      #
188
189BMC FFDC Files
190    [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
198    scp.Open Connection
199    ...  ${OPENBMC_HOST}  username=${OPENBMC_USERNAME}  password=${OPENBMC_PASSWORD}  port=${SSH_PORT}
200
201    @{ffdc_file_list}=  Create List
202
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
207
208    BMC Execute Command  rm -rf /tmp/BMC_*
209    scp.Close Connection
210
211    [Return]  ${ffdc_file_list}
212
213
214Create File and Write Data
215    [Documentation]  Run commands from FFDC_BMC_FILE to create FFDC files and
216    ...              return a list of generated files.
217    [Arguments]  ${key_index}
218
219    # 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}
224
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
231
232    [Return]  ${ffdc_file_list}
233
234
235# Method : Log Test Case Status                                #
236#          Creates test result history footprint for reference #
237
238Log Test Case Status
239    [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
244
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
255    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
263    Rpvars  TEST_HISTORY
264
265    ${cur_time}=      Get Current Time Stamp
266
267    Append To File    ${TEST_HISTORY}
268    ...   ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
269
270
271Log FFDC Get Requests
272    [Documentation]  Run the get requests associated with the key and return a
273    ...              list of generated files.
274    [Arguments]  ${key_index}
275
276    # 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}
284
285    FOR  ${cmd}  IN  @{cmd_list}
286      ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}
287      ${resp}=  OpenBMC Get Request  ${cmd[1]}  quiet=${1}
288      ${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
294
295    [Return]  ${ffdc_file_list}
296
297BMC FFDC Get Requests
298    [Documentation]  Iterate over get request list and return a list of
299    ...              generated files.
300
301    @{ffdc_file_list}=  Create List
302
303    @{entries}=  Get ffdc get request index
304    # Example of entries:
305    # entries:
306    #  entries[0]:  GET REQUESTS
307
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
312
313    [Return]  ${ffdc_file_list}
314
315Log 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}
319
320    # 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}
326
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
334
335    [Return]  ${ffdc_file_list}
336
337
338Log OS SPECIFIC DISTRO FFDC
339    [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}
342
343    # 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
347    @{ffdc_file_list}=  Create List
348
349    @{cmd_list}=  Get FFDC OS Distro Call  ${key_index}  ${linux_distro}
350
351    FOR  ${cmd}  IN  @{cmd_list}
352      ${logpath}=  Catenate  SEPARATOR=  ${LOG_PREFIX}  ${cmd[0]}
353      ${ffdc_file_sub_list}=  Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}  ${logpath}  target=OS
354      Run Key U  scp.Get File \ /tmp/${cmd[0]} \ ${LOG_PREFIX}${cmd[0]}
355      ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list}
356
357    # Get the name of the sosreport file.
358    ${sosreport_file_path}  ${stderr}  ${rc}=  OS Execute Command
359    ...  ls /tmp/sosreport*FFDC*tar.xz  ignore_err=${True}
360    # Example:  sosreport_file_path="/tmp/sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
361
362    # Return if there is no sosreport file.
363    Return From Keyword If  ${rc} != ${0}  ${ffdc_file_list}
364
365    ${sosreport_dir_path}  ${sosreport_file_name}=  Split Path  ${sosreport_file_path}
366    # Example:  sosreport_dir_path="/tmp",
367    #           sosreport_file_name="sosreport-myhost-FFDC-2019-08-20-pbuaqtk.tar.xz".
368
369    # Location where the sosreport file will be copied to.
370    ${local_sosreport_file_path}=  Set Variable  ${LOG_PREFIX}OS_${sosreport_file_name}
371
372    # Change file permissions otherwise scp will not see the file.
373    OS Execute Command  chmod 644 ${sosreport_file_path}
374
375    # SCP the sosreport file from the OS.
376    Run Key U  scp.Get File \ ${sosreport_file_path} \ ${local_sosreport_file_path}
377
378    # Add the file location to the ffdc_file_list.
379    Append To List  ${ffdc_file_list}  ${local_sosreport_file_path}
380
381    [Return]  ${ffdc_file_list}
382
383
384OS FFDC Files
385    [Documentation]  Run the commands from FFDC_OS_ALL_DISTROS_FILE to create
386    ...              FFDC files and return a list of generated files.
387    [Arguments]  ${OS_HOST}=${OS_HOST}  ${OS_USERNAME}=${OS_USERNAME}
388    ...  ${OS_PASSWORD}=${OS_PASSWORD}
389
390    @{ffdc_file_list}=  Create List
391
392    Run Keyword If  '${OS_HOST}' == '${EMPTY}'  Run Keywords
393    ...  Print Timen  No OS Host provided so no OS FFDC will be done.  AND
394    ...  Return From Keyword  ${ffdc_file_list}
395
396    ${match_state}=  Create Dictionary  os_ping=^1$  os_login=^1$
397    ...  os_run_cmd=^1$
398    ${status}  ${ret_values}=  Run Keyword and Ignore Error  Check State
399    ...  ${match_state}  quiet=0
400
401    Run Keyword If  '${status}' == 'FAIL'  Run Keywords
402    ...  Print Timen  The OS is not communicating so no OS FFDC will be done.\n
403    ...  AND
404    ...  Return From Keyword  ${ffdc_file_list}
405
406    ${stdout}  ${stderr}  ${rc}=  OS Execute Command
407    ...  . /etc/os-release; echo $ID  ignore_err=${0}
408    Set Global Variable  ${linux_distro}  ${stdout}
409
410    Rpvars  linux_distro
411
412    scp.Open Connection
413    ...  ${OS_HOST}  username=${OS_USERNAME}  password=${OS_PASSWORD}
414
415    @{entries}=  Get FFDC OS All Distros Index
416
417    FOR  ${index}  IN  @{entries}
418      ${ffdc_file_sub_list}=  Log OS All distros FFDC  ${index}
419      ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list}
420    END
421
422    Return From Keyword If
423    ...  '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
424    ...  ${ffdc_file_list}
425
426    @{entries}=  Get ffdc os distro index  ${linux_distro}
427
428    FOR  ${index}  IN  @{entries}
429      ${ffdc_file_sub_list}=  Log OS SPECIFIC DISTRO FFDC  ${index}  ${linux_distro}
430      ${ffdc_file_list}=  Smart Combine Lists  ${ffdc_file_list}  ${ffdc_file_sub_list}
431    END
432
433    # Delete ffdc files still on OS and close scp.
434    OS Execute Command  rm -rf /tmp/OS_* /tmp/sosreport*FFDC*  ignore_err=${True}
435    scp.Close Connection
436
437    [Return]  ${ffdc_file_list}
438
439
440System Inventory Files
441    [Documentation]  Copy systest os_inventory files and return a list of
442    ...              generated files..
443    # The os_inventory files are the result of running
444    # systest/htx_hardbootme_test.  If these files exist
445    # they are copied to the FFDC directory.
446    # Global variable ffdc_dir_path is the path name of the
447    # directory they are copied to.
448
449    @{ffdc_file_list}=  Create List
450
451    ${globex}=  Set Variable  os_inventory_*.json
452
453    @{file_list}=  OperatingSystem.List Files In Directory  .  ${globex}
454
455    Copy Files  ${globex}  ${ffdc_dir_path}
456
457    FOR  ${file_name}  IN  @{file_list}
458      Append To List  ${ffdc_file_list}  ${ffdc_dir_path}${file_name}
459    END
460
461    Run Keyword and Ignore Error  Remove Files  ${globex}
462
463    [Return]  ${ffdc_file_list}
464
465
466SCP Coredump Files
467    [Documentation]  Copy core dump files from BMC to local system and return a
468    ...              list of generated file names.
469
470    @{ffdc_file_list}=  Create List
471
472    # Check if core dump exist in the /tmp
473    ${core_files}  ${stderr}  ${rc}=  BMC Execute Command  ls /tmp/core_*
474    ...  ignore_err=${1}
475    Run Keyword If  '${rc}' != '${0}'  Return From Keyword  ${ffdc_file_list}
476
477    @{core_list}=  Split String  ${core_files}
478    # Copy the core files
479    Run Key U  Open Connection for SCP
480
481    FOR  ${index}  IN  @{core_list}
482      ${ffdc_file_path}=  Catenate  ${LOG_PREFIX}${index.lstrip("/tmp/")}
483      ${status}=  Run Keyword and Return Status  scp.Get File  ${index}  ${ffdc_file_path}
484      Run Keyword If  '${status}' == '${False}'  Continue For Loop
485      Append To List  ${ffdc_file_list}  ${ffdc_file_path}
486
487      # Remove the file from remote to avoid re-copying on next FFDC call
488
489      BMC Execute Command  rm ${index}  ignore_err=${1}
490      # I can't find a way to do this: scp.Close Connection
491
492    END
493
494    [Return]  ${ffdc_file_list}
495
496
497SCP Dump Files
498    [Documentation]  Copy all dump files from BMC to local system.
499
500    # Check if dumps exist
501    ${ffdc_file_list}=  Scp Dumps  ${FFDC_DIR_PATH}  ${FFDC_PREFIX}
502
503    [Return]  ${ffdc_file_list}
504
505
506Collect Dump Log
507    [Documentation]  Collect dumps from dump entry.
508    [Arguments]  ${log_prefix_path}=${LOG_PREFIX}
509
510    ${data}=  Read Properties  ${DUMP_ENTRY_URI}enumerate  quiet=${1}
511
512    # Grab the list of entries from dump/entry/
513    # The data shown below is the result of the "Get Dictionary Keys".
514    # Example:
515    # /xyz/openbmc_project/dump/entry/1
516    # /xyz/openbmc_project/dump/entry/2
517
518    ${dump_list}=  Get Dictionary Keys  ${data}
519
520
521Collect PEL Log
522    [Documentation]  Collect PEL files from from BMC.
523
524    Create Directory  ${FFDC_DIR_PATH}${/}pel_files/
525    scp.Get File  /var/lib/phosphor-logging/extensions/pels/logs/
526    ...  ${FFDC_DIR_PATH}${/}pel_files  recursive=True
527
528
529Enumerate Redfish Resources
530    [Documentation]  Enumerate /redfish/v1 resources and properties to
531    ...              a file. Return a list which contains the file name.
532    [Arguments]  ${log_prefix_path}=${LOG_PREFIX}
533
534    # Description of argument(s):
535    # log_prefix_path    The location specifying where to create FFDC file(s).
536
537    # Login is needed to fetch Redfish information.
538    # If login fails, return from keyword.
539    ${status}=  Run Keyword And Return Status  Redfish.Login
540    Return From Keyword If   ${status} == ${False}
541
542    # Get the Redfish resources and properties.
543    ${json_data}=  redfish_utils.Enumerate Request  /redfish/v1
544    # Typical output:
545    # {
546    #  "@odata.id": "/redfish/v1",
547    #  "@odata.type": "#ServiceRoot.v1_1_1.ServiceRoot",
548    #  "AccountService": {
549    #    "@odata.id": "/redfish/v1/AccountService"
550    #  },
551    #  "Chassis": {
552    #    "@odata.id": "/redfish/v1/Chassis"
553    #  },
554    #  "Id": "RootService",
555    #  "JsonSchemas": {
556    #    "@odata.id": "/redfish/v1/JsonSchemas"
557    #  },
558    # ..etc...
559    # }
560
561    @{ffdc_file_list}=  Create List
562    ${logpath}=  Catenate  SEPARATOR=  ${log_prefix_path}
563    ...  redfish_resource_properties.txt
564    Create File  ${logpath}
565    Write Data To File  "${\n}${json_data}${\n}"  ${logpath}
566
567    Append To List  ${ffdc_file_list}  ${logpath}
568
569    [Return]  ${ffdc_file_list}
570
571
572Collect eSEL Log
573    [Documentation]  Create raw and formatted eSEL files.
574    [Arguments]  ${log_prefix_path}=${LOG_PREFIX}
575
576    # NOTE: If no eSEL.pl program can be located, then no formatted eSEL file
577    # will be generated.
578
579    # Description of argument(s):
580    # log_prefix_path               The path prefix to be used in creating
581    #                               eSEL file path names.  For example, if
582    #                               log_prefix_path is
583    #                               "/tmp/user1/dummy.181001.120000.", then
584    #                               this keyword will create
585    #                               /tmp/user1/dummy.181001.120000.esel (raw)
586    #                               and
587    #                               /tmp/user1/dummy.181001.120000.esel.txt
588    #                               (formatted).
589
590    @{ffdc_file_list}=  Create List
591
592    ${esels}=  Get Esels
593    ${num_esels}=  Evaluate  len(${esels})
594    Rprint Vars  num_esels
595    Return From Keyword If  ${num_esels} == ${0}  ${ffdc_file_list}
596
597    ${logpath}=  Catenate  SEPARATOR=  ${log_prefix_path}  esel
598    Create File  ${logpath}
599
600    FOR  ${esel}  IN  @{esels}
601      Write Data To File  "${esel}"${\n}  ${logpath}
602    END
603
604    Append To List  ${ffdc_file_list}  ${logpath}
605
606    ${rc}  ${output}=  Shell Cmd  which eSEL.pl  show_err=0
607    Return From Keyword If  ${rc} != ${0}  ${ffdc_file_list}
608
609    Convert eSEL To Elog Format  ${logpath}
610    Append To List  ${ffdc_file_list}  ${logpath}.txt
611
612    [Return]  ${ffdc_file_list}
613
614
615Convert eSEL To Elog Format
616    [Documentation]  Execute parser tool on the eSEL data file to generate
617    ...              formatted error log.
618    [Arguments]  ${esel_file_path}
619    # Description of argument(s):
620    # esel_file_path                The path to the file containing raw eSEL
621    #                               data (e.g.
622    #                               "/tmp/user1/dummy.181001.120000.esel").
623
624    # Note: The only way to get eSEL.pl to put the output in a particular
625    # directory is to cd to that directory.
626    ${cmd_buf}=  Catenate  cd $(dirname ${esel_file_path}) ; eSEL.pl -l
627    ...  ${esel_file_path} -p decode_obmc_data
628    Qprint Issuing  ${cmd_buf}
629    Run  ${cmd_buf}
630    # The .binary file, which is generated by eSEL.pl, is of no use to us.
631    Remove File  ${esel_file_path}.binary
632