xref: /openbmc/openbmc-test-automation/lib/openbmc_ffdc_list.py (revision c4d3dc0b5cd44a68a8e2d99f7c06be1f02157640)
1#!/usr/bin/python
2'''
3#############################################################
4#    @file     openbmc_ffdc_list.py
5#
6#    @brief    List for FFDC ( First failure data capture )
7#              commands and files to be collected as a part
8#              of the test case failure.
9#############################################################
10'''
11
12#-------------------
13# FFDC default list
14#-------------------
15
16#-----------------------------------------------------------------
17#Dict Name {  Index string : { Key String :  Comand string} }
18#-----------------------------------------------------------------
19# Add cmd's needed to be part of the ffdc report manifest file
20FFDC_BMC_CMD = {
21             'DRIVER INFO' :
22                     {
23                        #String Name         Command
24                        'Build Info' : 'cat /etc/version',
25                        'FW Level'   : 'cat /etc/os-release',
26                     },
27             'BMC DATA' :
28                     {
29                        'BMC OS'     : 'uname -a',
30                        'BMC Uptime' : 'uptime',
31                        'BMC Proc Info' : 'cat /proc/cpuinfo',
32                        'BMC File System Disk Space Usage' : 'df -hT',
33                     },
34             'APPLICATION DATA' :
35                     {
36                        'BMC state' : '/usr/sbin/obmcutil  state',
37                     },
38           }
39
40# Add file name and correcponding command needed for BMC
41FFDC_BMC_FILE = {
42             'BMC FILES' :
43                     {
44                        #File Name         Command
45                        'BMC_proc_list' : 'top -n 1 -b',
46                        'BMC_journalctl.log' : 'journalctl --no-pager',
47                     },
48           }
49
50# Define your keywords in method/utils and call here
51FFDC_METHOD_CALL = {
52             'BMC LOGS' :
53                     {
54                        #Description             Keyword name
55                        'FFDC Generic Report' : 'BMC FFDC Manifest',
56                        'BMC Specific Files'  : 'BMC FFDC Files',
57                     },
58           }
59
60#-----------------------------------------------------------------
61
62
63# base class for FFDC default list
64class openbmc_ffdc_list():
65
66    ########################################################################
67    #   @brief    This method returns the list from the dictionary for cmds
68    #   @param    i_type: @type string: string index lookup
69    #   @return   List of key pair from the dictionary
70    ########################################################################
71    def get_ffdc_bmc_cmd(self,i_type):
72        return FFDC_BMC_CMD[i_type].items()
73
74    ########################################################################
75    #   @brief    This method returns the list from the dictionary for scp
76    #   @param    i_type: @type string: string index lookup
77    #   @return   List of key pair from the dictionary
78    ########################################################################
79    def get_ffdc_bmc_file(self,i_type):
80        return FFDC_BMC_FILE[i_type].items()
81
82    ########################################################################
83    #   @brief    This method returns the list index from dictionary
84    #   @return   List of index to the dictionary
85    ########################################################################
86    def get_ffdc_cmd_index(self):
87        return FFDC_BMC_CMD.keys()
88
89    ########################################################################
90    #   @brief    This method returns the list index from dictionary
91    #   @return   List of index to the dictionary
92    ########################################################################
93    def get_ffdc_file_index(self):
94        return FFDC_BMC_FILE.keys()
95
96    ########################################################################
97    #   @brief    This method returns the key pair from the dictionary
98    #   @return   Index of the method dictionary
99    ########################################################################
100    def get_ffdc_method_index(self):
101        return FFDC_METHOD_CALL.keys()
102
103    ########################################################################
104    #   @brief    This method returns the key pair from the dictionary
105    #   @return   List of key pair keywords
106    ########################################################################
107    def get_ffdc_method_call(self,i_type):
108        return FFDC_METHOD_CALL[i_type].items()
109
110    ########################################################################
111    #   @brief    Returns the stripped strings
112    #   @param    i_str: @type string: string name
113    #   @return   Remove all special chars and return the string
114    ########################################################################
115    def get_strip_string(self, i_str):
116        return ''.join(e for e in i_str if e.isalnum())
117