blob: a26af40bf1eb63db45d8e04b42493cf14821365a [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',
George Keishingc5ab1b62017-08-16 13:51:14 -050025 'FW Timestamp': 'cat /etc/timestamp',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050026 },
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 {
Michael Walshe53e47a2017-06-30 17:03:24 -050035 'BMC state': '/usr/sbin/obmcutil state',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050036 },
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',
George Keishing158a76c2017-07-18 00:53:37 -050045 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/',
Gunnar Millsaca140d2016-10-26 13:05:10 -050046 'BMC_journalctl': 'journalctl --no-pager',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050047 'BMC_dmesg': 'dmesg',
Gunnar Millsaca140d2016-10-26 13:05:10 -050048 'BMC_procinfo': 'cat /proc/cpuinfo',
49 'BMC_meminfo': 'cat /proc/meminfo',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050050 },
51}
52
Gunnar Mills7e2cda22016-10-11 15:37:34 -050053# Add file name and correcponding command needed for all Linux distributions
54FFDC_OS_ALL_DISTROS_FILE = {
55 'OS FILES':
56 {
57 # File Name Command
58 'OS_msglog': 'cat /sys/firmware/opal/msglog',
59 'OS_cpufrequency': 'ppc64_cpu --frequency',
60 'OS_dmesg': 'dmesg',
61 'OS_boot': 'cat /var/log/boot.log',
Gunnar Millsaca140d2016-10-26 13:05:10 -050062 'OS_procinfo': 'cat /proc/cpuinfo',
63 'OS_meminfo': 'cat /proc/meminfo',
64 'OS_netstat': 'netstat -a',
Steven Sombar60ade082017-08-16 11:27:26 -050065 'OS_lspci': 'lspci',
66 'OS_lscpu': 'lscpu',
67 'OS_lscfg': 'lscfg',
Gunnar Mills7e2cda22016-10-11 15:37:34 -050068 },
69}
70
Gunnar Millscce185d2016-10-17 17:04:15 -050071# Add file name and correcponding command needed for Ubuntu Linux
72FFDC_OS_UBUNTU_FILE = {
73 'OS FILES':
74 {
75 # File Name Command
76 'OS_isusb': 'lsusb -t ; lsusb -v',
77 'OS_kern': 'tail -n 50000 /var/log/kern.log',
78 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
79 'OS_syslog': 'tail -n 200000 /var/log/syslog',
80 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
81 },
82}
83
84# Add file name and correcponding command needed for RHEL Linux
85FFDC_OS_RHEL_FILE = {
86 'OS FILES':
87 {
88 # File Name Command
89 'OS_rsct': '/usr/bin/ctversion -bv',
90 'OS_secure': 'cat /var/log/secure',
91 'OS_syslog': 'tail -n 200000 /var/log/messages',
92 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
93 },
94}
95
96# Add file name and correcponding command needed for RHEL Linux
97FFDC_OS_IBM_POWERKVM_FILE = {
98 'OS FILES':
99 {
100 # File Name Command
101 'OS_secure': 'cat /var/log/secure',
102 'OS_syslog': 'tail -n 200000 /var/log/messages',
103 'OS_info': 'lsb_release -a; uname -a; rpm -qa',
104 },
105}
106
George Keishing136bcc62016-11-23 08:34:16 -0600107# Enable when ready with openbmc/openbmc-test-automation#203
108# replace with new path /xyz/openbmc_project
109OPENBMC_BASE = '/org/openbmc/'
George Keishingfe5724d2016-11-23 09:25:36 -0600110ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate'
George Keishing7f7040c2017-02-20 10:23:56 -0600111# TODO: Use the xyz enums once moved to xyz completely
112# ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/enumerate'
George Keishingc06fc992017-02-22 09:01:08 -0600113ENUMERATE_SYSTEMS = '/xyz/openbmc_project/inventory/enumerate'
114ENUMERATE_ELOG = '/xyz/openbmc_project/logging/entry/enumerate'
George Keishingfe5724d2016-11-23 09:25:36 -0600115ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate'
116ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate'
117
George Keishing49e24a72017-08-09 11:37:42 -0500118# Sensors/control data.
119ENUMERATE_SENSOR = '/xyz/openbmc_project/sensors/enumerate'
120ENUMERATE_CONTROL = '/xyz/openbmc_project/control/enumerate'
121
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500122# Add file name and correcponding Get Request
123FFDC_GET_REQUEST = {
124 'GET REQUESTS':
125 {
126 # File Name Command
George Keishingfe5724d2016-11-23 09:25:36 -0600127 'BMC_sensor_list': ENUMERATE_SENSORS,
George Keishing49e24a72017-08-09 11:37:42 -0500128 'BMC_sensor_xyz_list': ENUMERATE_SENSOR,
129 'BMC_control_list': ENUMERATE_CONTROL,
George Keishingfe5724d2016-11-23 09:25:36 -0600130 'BMC_inventory': ENUMERATE_SYSTEMS,
George Keishingc06fc992017-02-22 09:01:08 -0600131 'BMC_elog': ENUMERATE_ELOG,
George Keishingfe5724d2016-11-23 09:25:36 -0600132 'BMC_led': ENUMERATE_EVENTS,
133 'BMC_record_log': ENUMERATE_LED,
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500134 },
135}
136
George Keishing69e6f712016-09-12 06:30:09 -0500137
138# Define your keywords in method/utils and call here
139FFDC_METHOD_CALL = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500140 'BMC LOGS':
141 {
142 # Description Keyword name
143 'FFDC Generic Report': 'BMC FFDC Manifest',
144 'BMC Specific Files': 'BMC FFDC Files',
145 'Get Request FFDC': 'BMC FFDC Get Requests',
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500146 'OS FFDC': 'OS FFDC Files',
George Keishing7a520222017-02-27 09:44:30 -0600147 'Core Files': 'SCP Coredump Files',
George Keishingeb7b4bc2017-03-13 12:04:28 -0500148 'SEL Log': 'Collect eSEL Log',
Steven Sombar96de5732017-08-17 09:04:52 -0500149 'Sys Inventory Files': 'System Inventory Files',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500150 },
151}
George Keishing4346a412016-07-19 11:26:49 -0500152
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500153# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500154
155
156# base class for FFDC default list
157class openbmc_ffdc_list():
158
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500159 def get_ffdc_bmc_cmd(self, i_type):
160 r"""
161 ########################################################################
162 # @brief This method returns the list from the dictionary for cmds
163 # @param i_type: @type string: string index lookup
164 # @return List of key pair from the dictionary
165 ########################################################################
166 """
George Keishing69e6f712016-09-12 06:30:09 -0500167 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500168
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500169 def get_ffdc_bmc_file(self, i_type):
170 r"""
171 ########################################################################
172 # @brief This method returns the list from the dictionary for scp
173 # @param i_type: @type string: string index lookup
174 # @return List of key pair from the dictionary
175 ########################################################################
176 """
George Keishing69e6f712016-09-12 06:30:09 -0500177 return FFDC_BMC_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500178
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500179 def get_ffdc_get_request(self, i_type):
180 r"""
181 ########################################################################
182 # @brief This method returns the list from the dictionary for scp
183 # @param i_type: @type string: string index lookup
184 # @return List of key pair from the dictionary
185 ########################################################################
186 """
187 return FFDC_GET_REQUEST[i_type].items()
188
George Keishing69e6f712016-09-12 06:30:09 -0500189 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500190 r"""
191 ########################################################################
192 # @brief This method returns the list index from dictionary
193 # @return List of index to the dictionary
194 ########################################################################
195 """
George Keishing69e6f712016-09-12 06:30:09 -0500196 return FFDC_BMC_CMD.keys()
197
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500198 def get_ffdc_get_request_index(self):
199 r"""
200 ########################################################################
201 # @brief This method returns the list index from dictionary
202 # @return List of index to the dictionary
203 ########################################################################
204 """
205 return FFDC_GET_REQUEST.keys()
206
George Keishing69e6f712016-09-12 06:30:09 -0500207 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500208 r"""
209 ########################################################################
210 # @brief This method returns the list index from dictionary
211 # @return List of index to the dictionary
212 ########################################################################
213 """
George Keishing69e6f712016-09-12 06:30:09 -0500214 return FFDC_BMC_FILE.keys()
215
George Keishing69e6f712016-09-12 06:30:09 -0500216 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500217 r"""
218 ########################################################################
219 # @brief This method returns the key pair from the dictionary
220 # @return Index of the method dictionary
221 ########################################################################
222 """
George Keishing69e6f712016-09-12 06:30:09 -0500223 return FFDC_METHOD_CALL.keys()
224
Michael Walshe844e9a2017-04-20 16:51:10 -0500225 def get_ffdc_method_desc(self,
226 index):
227 r"""
228 ########################################################################
229 # @brief This method returns the just the keys from the dictionary.
230 # @return List of ffdc descriptions.
231 ########################################################################
232 """
233 return FFDC_METHOD_CALL[index].keys()
234
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500235 def get_ffdc_method_call(self, i_type):
236 r"""
237 ########################################################################
238 # @brief This method returns the key pair from the dictionary
239 # @return List of key pair keywords
240 ########################################################################
241 """
George Keishing69e6f712016-09-12 06:30:09 -0500242 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500243
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500244 def get_ffdc_os_all_distros_index(self):
245 r"""
246 ########################################################################
247 # @brief This method returns the key pair from the dictionary
248 # @return Index of the method dictionary
249 ########################################################################
250 """
251 return FFDC_OS_ALL_DISTROS_FILE.keys()
252
253 def get_ffdc_os_all_distros_call(self, i_type):
254 r"""
255 ########################################################################
256 # @brief This method returns the key pair from the dictionary
257 # @return List of key pair keywords
258 ########################################################################
259 """
260 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
261
Gunnar Millscce185d2016-10-17 17:04:15 -0500262 def get_ffdc_os_distro_index(self, distro):
263 r"""
264 ########################################################################
265 # @brief This method returns the key pair from the dictionary
266 # @return Index of the method dictionary
267 ########################################################################
268 """
269 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
270 return eval(distro_file).keys()
271
272 def get_ffdc_os_distro_call(self, i_type, distro):
273 r"""
274 ########################################################################
275 # @brief This method returns the key pair from the dictionary
276 # @return List of key pair keywords
277 ########################################################################
278 """
279 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
280 return eval(distro_file)[i_type].items()
281
George Keishing4346a412016-07-19 11:26:49 -0500282 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500283 r"""
284 ########################################################################
285 # @brief Returns the stripped strings
286 # @param i_str: @type string: string name
287 # @return Remove all special chars and return the string
288 ########################################################################
289 """
George Keishing4346a412016-07-19 11:26:49 -0500290 return ''.join(e for e in i_str if e.isalnum())
George Keishing28da9482017-07-27 13:38:54 -0500291
292 def get_esel_index(self, esel_list):
293 r"""
294 #######################################################################
295 # @brief Returns the eSEL binary index.
296 # @param esel_ist: @type list: eSEL list.
297 # @return Index of "ESEL=" in the list.
298 #######################################################################
299 """
300 index = [i for i, str in enumerate(esel_list) if 'ESEL=' in str]
301 return index[0]