blob: a1feb0b92956aa36b82c03ed19d7b28d434231c2 [file] [log] [blame]
George Keishing4346a412016-07-19 11:26:49 -05001#!/usr/bin/python
Gunnar Millsa812e0f2016-09-29 20:30:03 -05002r"""
George Keishing4346a412016-07-19 11:26:49 -05003#############################################################
4# @file openbmc_ffdc_list.py
George Keishing4346a412016-07-19 11:26:49 -05005#
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#############################################################
Gunnar Millsa812e0f2016-09-29 20:30:03 -050010"""
George Keishing4346a412016-07-19 11:26:49 -050011
Gunnar Millsa812e0f2016-09-29 20:30:03 -050012# -------------------
George Keishing4346a412016-07-19 11:26:49 -050013# FFDC default list
Gunnar Millsa812e0f2016-09-29 20:30:03 -050014# -------------------
George Keishing4346a412016-07-19 11:26:49 -050015
Gunnar Millsa812e0f2016-09-29 20:30:03 -050016# -----------------------------------------------------------------
17# Dict Name { Index string : { Key String : Comand string} }
18# -----------------------------------------------------------------
George Keishing69e6f712016-09-12 06:30:09 -050019# Add cmd's needed to be part of the ffdc report manifest file
20FFDC_BMC_CMD = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050021 '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',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050031 'BMC File System Disk Space Usage': 'df -hT',
32 },
33 'APPLICATION DATA':
34 {
35 'BMC state': '/usr/sbin/obmcutil state',
36 },
37}
George Keishing4346a412016-07-19 11:26:49 -050038
George Keishing69e6f712016-09-12 06:30:09 -050039# Add file name and correcponding command needed for BMC
40FFDC_BMC_FILE = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050041 'BMC FILES':
42 {
43 # File Name Command
44 'BMC_proc_list': 'top -n 1 -b',
Gunnar Millsaca140d2016-10-26 13:05:10 -050045 'BMC_journalctl': 'journalctl --no-pager',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050046 'BMC_dmesg': 'dmesg',
Gunnar Millsaca140d2016-10-26 13:05:10 -050047 'BMC_procinfo': 'cat /proc/cpuinfo',
48 'BMC_meminfo': 'cat /proc/meminfo',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050049 },
50}
51
Gunnar Mills7e2cda22016-10-11 15:37:34 -050052# Add file name and correcponding command needed for all Linux distributions
53FFDC_OS_ALL_DISTROS_FILE = {
54 'OS FILES':
55 {
56 # File Name Command
57 'OS_msglog': 'cat /sys/firmware/opal/msglog',
58 'OS_cpufrequency': 'ppc64_cpu --frequency',
59 'OS_dmesg': 'dmesg',
60 'OS_boot': 'cat /var/log/boot.log',
Gunnar Millsaca140d2016-10-26 13:05:10 -050061 'OS_procinfo': 'cat /proc/cpuinfo',
62 'OS_meminfo': 'cat /proc/meminfo',
63 'OS_netstat': 'netstat -a',
Gunnar Mills7e2cda22016-10-11 15:37:34 -050064 },
65}
66
Gunnar Millscce185d2016-10-17 17:04:15 -050067# Add file name and correcponding command needed for Ubuntu Linux
68FFDC_OS_UBUNTU_FILE = {
69 'OS FILES':
70 {
71 # File Name Command
72 'OS_isusb': 'lsusb -t ; lsusb -v',
73 'OS_kern': 'tail -n 50000 /var/log/kern.log',
74 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
75 'OS_syslog': 'tail -n 200000 /var/log/syslog',
76 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
77 },
78}
79
80# Add file name and correcponding command needed for RHEL Linux
81FFDC_OS_RHEL_FILE = {
82 'OS FILES':
83 {
84 # File Name Command
85 'OS_rsct': '/usr/bin/ctversion -bv',
86 'OS_secure': 'cat /var/log/secure',
87 'OS_syslog': 'tail -n 200000 /var/log/messages',
88 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
89 },
90}
91
92# Add file name and correcponding command needed for RHEL Linux
93FFDC_OS_IBM_POWERKVM_FILE = {
94 'OS FILES':
95 {
96 # File Name Command
97 'OS_secure': 'cat /var/log/secure',
98 'OS_syslog': 'tail -n 200000 /var/log/messages',
99 'OS_info': 'lsb_release -a; uname -a; rpm -qa',
100 },
101}
102
George Keishing136bcc62016-11-23 08:34:16 -0600103# Enable when ready with openbmc/openbmc-test-automation#203
104# replace with new path /xyz/openbmc_project
105OPENBMC_BASE = '/org/openbmc/'
George Keishingfe5724d2016-11-23 09:25:36 -0600106ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate'
107ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/system/enumerate'
108ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate'
109ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate'
110
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500111# Add file name and correcponding Get Request
112FFDC_GET_REQUEST = {
113 'GET REQUESTS':
114 {
115 # File Name Command
George Keishingfe5724d2016-11-23 09:25:36 -0600116 'BMC_sensor_list': ENUMERATE_SENSORS,
117 'BMC_inventory': ENUMERATE_SYSTEMS,
118 'BMC_led': ENUMERATE_EVENTS,
119 'BMC_record_log': ENUMERATE_LED,
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500120 },
121}
122
George Keishing69e6f712016-09-12 06:30:09 -0500123
124# Define your keywords in method/utils and call here
125FFDC_METHOD_CALL = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500126 'BMC LOGS':
127 {
128 # Description Keyword name
129 'FFDC Generic Report': 'BMC FFDC Manifest',
130 'BMC Specific Files': 'BMC FFDC Files',
131 'Get Request FFDC': 'BMC FFDC Get Requests',
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500132 'OS FFDC': 'OS FFDC Files',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500133 },
134}
George Keishing4346a412016-07-19 11:26:49 -0500135
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500136# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500137
138
139# base class for FFDC default list
140class openbmc_ffdc_list():
141
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500142 def get_ffdc_bmc_cmd(self, i_type):
143 r"""
144 ########################################################################
145 # @brief This method returns the list from the dictionary for cmds
146 # @param i_type: @type string: string index lookup
147 # @return List of key pair from the dictionary
148 ########################################################################
149 """
George Keishing69e6f712016-09-12 06:30:09 -0500150 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500151
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500152 def get_ffdc_bmc_file(self, i_type):
153 r"""
154 ########################################################################
155 # @brief This method returns the list from the dictionary for scp
156 # @param i_type: @type string: string index lookup
157 # @return List of key pair from the dictionary
158 ########################################################################
159 """
George Keishing69e6f712016-09-12 06:30:09 -0500160 return FFDC_BMC_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500161
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500162 def get_ffdc_get_request(self, i_type):
163 r"""
164 ########################################################################
165 # @brief This method returns the list from the dictionary for scp
166 # @param i_type: @type string: string index lookup
167 # @return List of key pair from the dictionary
168 ########################################################################
169 """
170 return FFDC_GET_REQUEST[i_type].items()
171
George Keishing69e6f712016-09-12 06:30:09 -0500172 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500173 r"""
174 ########################################################################
175 # @brief This method returns the list index from dictionary
176 # @return List of index to the dictionary
177 ########################################################################
178 """
George Keishing69e6f712016-09-12 06:30:09 -0500179 return FFDC_BMC_CMD.keys()
180
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500181 def get_ffdc_get_request_index(self):
182 r"""
183 ########################################################################
184 # @brief This method returns the list index from dictionary
185 # @return List of index to the dictionary
186 ########################################################################
187 """
188 return FFDC_GET_REQUEST.keys()
189
George Keishing69e6f712016-09-12 06:30:09 -0500190 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500191 r"""
192 ########################################################################
193 # @brief This method returns the list index from dictionary
194 # @return List of index to the dictionary
195 ########################################################################
196 """
George Keishing69e6f712016-09-12 06:30:09 -0500197 return FFDC_BMC_FILE.keys()
198
George Keishing69e6f712016-09-12 06:30:09 -0500199 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500200 r"""
201 ########################################################################
202 # @brief This method returns the key pair from the dictionary
203 # @return Index of the method dictionary
204 ########################################################################
205 """
George Keishing69e6f712016-09-12 06:30:09 -0500206 return FFDC_METHOD_CALL.keys()
207
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500208 def get_ffdc_method_call(self, i_type):
209 r"""
210 ########################################################################
211 # @brief This method returns the key pair from the dictionary
212 # @return List of key pair keywords
213 ########################################################################
214 """
George Keishing69e6f712016-09-12 06:30:09 -0500215 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500216
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500217 def get_ffdc_os_all_distros_index(self):
218 r"""
219 ########################################################################
220 # @brief This method returns the key pair from the dictionary
221 # @return Index of the method dictionary
222 ########################################################################
223 """
224 return FFDC_OS_ALL_DISTROS_FILE.keys()
225
226 def get_ffdc_os_all_distros_call(self, i_type):
227 r"""
228 ########################################################################
229 # @brief This method returns the key pair from the dictionary
230 # @return List of key pair keywords
231 ########################################################################
232 """
233 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
234
Gunnar Millscce185d2016-10-17 17:04:15 -0500235 def get_ffdc_os_distro_index(self, distro):
236 r"""
237 ########################################################################
238 # @brief This method returns the key pair from the dictionary
239 # @return Index of the method dictionary
240 ########################################################################
241 """
242 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
243 return eval(distro_file).keys()
244
245 def get_ffdc_os_distro_call(self, i_type, distro):
246 r"""
247 ########################################################################
248 # @brief This method returns the key pair from the dictionary
249 # @return List of key pair keywords
250 ########################################################################
251 """
252 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
253 return eval(distro_file)[i_type].items()
254
George Keishing4346a412016-07-19 11:26:49 -0500255 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500256 r"""
257 ########################################################################
258 # @brief Returns the stripped strings
259 # @param i_str: @type string: string name
260 # @return Remove all special chars and return the string
261 ########################################################################
262 """
George Keishing4346a412016-07-19 11:26:49 -0500263 return ''.join(e for e in i_str if e.isalnum())