blob: d2e6c7e1f3d318423abaa44c65aa66baa1310c15 [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
Gunnar Millsa812e0f2016-09-29 20:30:03 -050024 'FW Level': 'cat /etc/os-release',
25 },
26 'BMC DATA':
27 {
28 'BMC OS': 'uname -a',
29 'BMC Uptime': 'uptime',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050030 'BMC File System Disk Space Usage': 'df -hT',
31 },
32 'APPLICATION DATA':
33 {
Michael Walshe53e47a2017-06-30 17:03:24 -050034 'BMC state': '/usr/sbin/obmcutil state',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050035 },
36}
George Keishing4346a412016-07-19 11:26:49 -050037
George Keishing69e6f712016-09-12 06:30:09 -050038# Add file name and correcponding command needed for BMC
39FFDC_BMC_FILE = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050040 'BMC FILES':
41 {
42 # File Name Command
43 'BMC_proc_list': 'top -n 1 -b',
George Keishing158a76c2017-07-18 00:53:37 -050044 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/',
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'
George Keishing7f7040c2017-02-20 10:23:56 -0600107# TODO: Use the xyz enums once moved to xyz completely
108# ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/enumerate'
George Keishingc06fc992017-02-22 09:01:08 -0600109ENUMERATE_SYSTEMS = '/xyz/openbmc_project/inventory/enumerate'
110ENUMERATE_ELOG = '/xyz/openbmc_project/logging/entry/enumerate'
George Keishingfe5724d2016-11-23 09:25:36 -0600111ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate'
112ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate'
113
George Keishing49e24a72017-08-09 11:37:42 -0500114# Sensors/control data.
115ENUMERATE_SENSOR = '/xyz/openbmc_project/sensors/enumerate'
116ENUMERATE_CONTROL = '/xyz/openbmc_project/control/enumerate'
117
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500118# Add file name and correcponding Get Request
119FFDC_GET_REQUEST = {
120 'GET REQUESTS':
121 {
122 # File Name Command
George Keishingfe5724d2016-11-23 09:25:36 -0600123 'BMC_sensor_list': ENUMERATE_SENSORS,
George Keishing49e24a72017-08-09 11:37:42 -0500124 'BMC_sensor_xyz_list': ENUMERATE_SENSOR,
125 'BMC_control_list': ENUMERATE_CONTROL,
George Keishingfe5724d2016-11-23 09:25:36 -0600126 'BMC_inventory': ENUMERATE_SYSTEMS,
George Keishingc06fc992017-02-22 09:01:08 -0600127 'BMC_elog': ENUMERATE_ELOG,
George Keishingfe5724d2016-11-23 09:25:36 -0600128 'BMC_led': ENUMERATE_EVENTS,
129 'BMC_record_log': ENUMERATE_LED,
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500130 },
131}
132
George Keishing69e6f712016-09-12 06:30:09 -0500133
134# Define your keywords in method/utils and call here
135FFDC_METHOD_CALL = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500136 'BMC LOGS':
137 {
138 # Description Keyword name
139 'FFDC Generic Report': 'BMC FFDC Manifest',
140 'BMC Specific Files': 'BMC FFDC Files',
141 'Get Request FFDC': 'BMC FFDC Get Requests',
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500142 'OS FFDC': 'OS FFDC Files',
George Keishing7a520222017-02-27 09:44:30 -0600143 'Core Files': 'SCP Coredump Files',
George Keishingeb7b4bc2017-03-13 12:04:28 -0500144 'SEL Log': 'Collect eSEL Log',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500145 },
146}
George Keishing4346a412016-07-19 11:26:49 -0500147
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500148# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500149
150
151# base class for FFDC default list
152class openbmc_ffdc_list():
153
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500154 def get_ffdc_bmc_cmd(self, i_type):
155 r"""
156 ########################################################################
157 # @brief This method returns the list from the dictionary for cmds
158 # @param i_type: @type string: string index lookup
159 # @return List of key pair from the dictionary
160 ########################################################################
161 """
George Keishing69e6f712016-09-12 06:30:09 -0500162 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500163
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500164 def get_ffdc_bmc_file(self, i_type):
165 r"""
166 ########################################################################
167 # @brief This method returns the list from the dictionary for scp
168 # @param i_type: @type string: string index lookup
169 # @return List of key pair from the dictionary
170 ########################################################################
171 """
George Keishing69e6f712016-09-12 06:30:09 -0500172 return FFDC_BMC_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500173
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500174 def get_ffdc_get_request(self, i_type):
175 r"""
176 ########################################################################
177 # @brief This method returns the list from the dictionary for scp
178 # @param i_type: @type string: string index lookup
179 # @return List of key pair from the dictionary
180 ########################################################################
181 """
182 return FFDC_GET_REQUEST[i_type].items()
183
George Keishing69e6f712016-09-12 06:30:09 -0500184 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500185 r"""
186 ########################################################################
187 # @brief This method returns the list index from dictionary
188 # @return List of index to the dictionary
189 ########################################################################
190 """
George Keishing69e6f712016-09-12 06:30:09 -0500191 return FFDC_BMC_CMD.keys()
192
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500193 def get_ffdc_get_request_index(self):
194 r"""
195 ########################################################################
196 # @brief This method returns the list index from dictionary
197 # @return List of index to the dictionary
198 ########################################################################
199 """
200 return FFDC_GET_REQUEST.keys()
201
George Keishing69e6f712016-09-12 06:30:09 -0500202 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500203 r"""
204 ########################################################################
205 # @brief This method returns the list index from dictionary
206 # @return List of index to the dictionary
207 ########################################################################
208 """
George Keishing69e6f712016-09-12 06:30:09 -0500209 return FFDC_BMC_FILE.keys()
210
George Keishing69e6f712016-09-12 06:30:09 -0500211 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500212 r"""
213 ########################################################################
214 # @brief This method returns the key pair from the dictionary
215 # @return Index of the method dictionary
216 ########################################################################
217 """
George Keishing69e6f712016-09-12 06:30:09 -0500218 return FFDC_METHOD_CALL.keys()
219
Michael Walshe844e9a2017-04-20 16:51:10 -0500220 def get_ffdc_method_desc(self,
221 index):
222 r"""
223 ########################################################################
224 # @brief This method returns the just the keys from the dictionary.
225 # @return List of ffdc descriptions.
226 ########################################################################
227 """
228 return FFDC_METHOD_CALL[index].keys()
229
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500230 def get_ffdc_method_call(self, i_type):
231 r"""
232 ########################################################################
233 # @brief This method returns the key pair from the dictionary
234 # @return List of key pair keywords
235 ########################################################################
236 """
George Keishing69e6f712016-09-12 06:30:09 -0500237 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500238
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500239 def get_ffdc_os_all_distros_index(self):
240 r"""
241 ########################################################################
242 # @brief This method returns the key pair from the dictionary
243 # @return Index of the method dictionary
244 ########################################################################
245 """
246 return FFDC_OS_ALL_DISTROS_FILE.keys()
247
248 def get_ffdc_os_all_distros_call(self, i_type):
249 r"""
250 ########################################################################
251 # @brief This method returns the key pair from the dictionary
252 # @return List of key pair keywords
253 ########################################################################
254 """
255 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
256
Gunnar Millscce185d2016-10-17 17:04:15 -0500257 def get_ffdc_os_distro_index(self, distro):
258 r"""
259 ########################################################################
260 # @brief This method returns the key pair from the dictionary
261 # @return Index of the method dictionary
262 ########################################################################
263 """
264 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
265 return eval(distro_file).keys()
266
267 def get_ffdc_os_distro_call(self, i_type, distro):
268 r"""
269 ########################################################################
270 # @brief This method returns the key pair from the dictionary
271 # @return List of key pair keywords
272 ########################################################################
273 """
274 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
275 return eval(distro_file)[i_type].items()
276
George Keishing4346a412016-07-19 11:26:49 -0500277 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500278 r"""
279 ########################################################################
280 # @brief Returns the stripped strings
281 # @param i_str: @type string: string name
282 # @return Remove all special chars and return the string
283 ########################################################################
284 """
George Keishing4346a412016-07-19 11:26:49 -0500285 return ''.join(e for e in i_str if e.isalnum())
George Keishing28da9482017-07-27 13:38:54 -0500286
287 def get_esel_index(self, esel_list):
288 r"""
289 #######################################################################
290 # @brief Returns the eSEL binary index.
291 # @param esel_ist: @type list: eSEL list.
292 # @return Index of "ESEL=" in the list.
293 #######################################################################
294 """
295 index = [i for i, str in enumerate(esel_list) if 'ESEL=' in str]
296 return index[0]