blob: 5707281b70ee6c6dfddd5cb16ad45848dc3a2d00 [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# -----------------------------------------------------------------
Gunnar Mills28e403b2017-10-25 16:16:38 -050017# Dict Name { Index string : { Key String : Command string} }
Gunnar Millsa812e0f2016-09-29 20:30:03 -050018# -----------------------------------------------------------------
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',
George Keishing342bcea2017-11-11 03:08:54 -060032 'BMC Date Time': 'date;/sbin/hwclock --show;/usr/bin/timedatectl'
Gunnar Millsa812e0f2016-09-29 20:30:03 -050033 },
34 'APPLICATION DATA':
35 {
Michael Walshe53e47a2017-06-30 17:03:24 -050036 'BMC state': '/usr/sbin/obmcutil state',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050037 },
38}
George Keishing4346a412016-07-19 11:26:49 -050039
George Keishing69e6f712016-09-12 06:30:09 -050040# Add file name and correcponding command needed for BMC
41FFDC_BMC_FILE = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050042 'BMC FILES':
43 {
44 # File Name Command
45 'BMC_proc_list': 'top -n 1 -b',
George Keishing158a76c2017-07-18 00:53:37 -050046 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/',
George Keishingf6cc55e2017-08-30 04:16:21 -050047 'BMC_journalctl_nopager': 'journalctl --no-pager',
48 'BMC_journalctl_pretty': 'journalctl -o json-pretty',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050049 'BMC_dmesg': 'dmesg',
Gunnar Millsaca140d2016-10-26 13:05:10 -050050 'BMC_procinfo': 'cat /proc/cpuinfo',
51 'BMC_meminfo': 'cat /proc/meminfo',
George Keishing6ce48132017-11-13 10:46:02 -060052 'BMC_systemd': 'systemctl status --all',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050053 },
54}
55
Gunnar Mills7e2cda22016-10-11 15:37:34 -050056# Add file name and correcponding command needed for all Linux distributions
57FFDC_OS_ALL_DISTROS_FILE = {
58 'OS FILES':
59 {
60 # File Name Command
61 'OS_msglog': 'cat /sys/firmware/opal/msglog',
62 'OS_cpufrequency': 'ppc64_cpu --frequency',
63 'OS_dmesg': 'dmesg',
64 'OS_boot': 'cat /var/log/boot.log',
Gunnar Millsaca140d2016-10-26 13:05:10 -050065 'OS_procinfo': 'cat /proc/cpuinfo',
66 'OS_meminfo': 'cat /proc/meminfo',
67 'OS_netstat': 'netstat -a',
Steven Sombar60ade082017-08-16 11:27:26 -050068 'OS_lspci': 'lspci',
69 'OS_lscpu': 'lscpu',
70 'OS_lscfg': 'lscfg',
Gunnar Mills7e2cda22016-10-11 15:37:34 -050071 },
72}
73
Gunnar Millscce185d2016-10-17 17:04:15 -050074# Add file name and correcponding command needed for Ubuntu Linux
75FFDC_OS_UBUNTU_FILE = {
76 'OS FILES':
77 {
78 # File Name Command
79 'OS_isusb': 'lsusb -t ; lsusb -v',
80 'OS_kern': 'tail -n 50000 /var/log/kern.log',
81 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
82 'OS_syslog': 'tail -n 200000 /var/log/syslog',
83 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
84 },
85}
86
87# Add file name and correcponding command needed for RHEL Linux
88FFDC_OS_RHEL_FILE = {
89 'OS FILES':
90 {
91 # File Name Command
92 'OS_rsct': '/usr/bin/ctversion -bv',
93 'OS_secure': 'cat /var/log/secure',
94 'OS_syslog': 'tail -n 200000 /var/log/messages',
95 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
96 },
97}
98
99# Add file name and correcponding command needed for RHEL Linux
100FFDC_OS_IBM_POWERKVM_FILE = {
101 'OS FILES':
102 {
103 # File Name Command
104 'OS_secure': 'cat /var/log/secure',
105 'OS_syslog': 'tail -n 200000 /var/log/messages',
106 'OS_info': 'lsb_release -a; uname -a; rpm -qa',
107 },
108}
109
George Keishingf77ea872017-09-01 08:02:21 -0500110OPENBMC_BASE = '/xyz/openbmc_project/'
George Keishingba000382017-09-19 13:25:29 -0500111OPENPOWER_BASE = '/org/open_power/'
George Keishingfe5724d2016-11-23 09:25:36 -0600112ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate'
George Keishingf77ea872017-09-01 08:02:21 -0500113ENUMERATE_INVENTORY = OPENBMC_BASE + 'inventory/enumerate'
114ENUMERATE_ELOG = OPENBMC_BASE + 'logging/entry/enumerate'
115ENUMERATE_LED = OPENBMC_BASE + 'led/enumerate'
116ENUMERATE_SW = OPENBMC_BASE + 'software/enumerate'
117ENUMERATE_CONTROL = OPENBMC_BASE + 'control/enumerate'
George Keishingba000382017-09-19 13:25:29 -0500118ENUMERATE_OCC = OPENPOWER_BASE + 'control/enumerate'
George Keishing49e24a72017-08-09 11:37:42 -0500119
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500120# Add file name and correcponding Get Request
121FFDC_GET_REQUEST = {
122 'GET REQUESTS':
123 {
124 # File Name Command
George Keishingf77ea872017-09-01 08:02:21 -0500125 'FIRMWARE_list': ENUMERATE_SW,
George Keishingfe5724d2016-11-23 09:25:36 -0600126 'BMC_sensor_list': ENUMERATE_SENSORS,
George Keishing49e24a72017-08-09 11:37:42 -0500127 'BMC_control_list': ENUMERATE_CONTROL,
George Keishingf77ea872017-09-01 08:02:21 -0500128 'BMC_inventory': ENUMERATE_INVENTORY,
George Keishingc06fc992017-02-22 09:01:08 -0600129 'BMC_elog': ENUMERATE_ELOG,
George Keishingf77ea872017-09-01 08:02:21 -0500130 'BMC_led': ENUMERATE_LED,
George Keishingba000382017-09-19 13:25:29 -0500131 'OCC_state': ENUMERATE_OCC,
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500132 },
133}
134
George Keishing69e6f712016-09-12 06:30:09 -0500135
136# Define your keywords in method/utils and call here
137FFDC_METHOD_CALL = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500138 'BMC LOGS':
139 {
140 # Description Keyword name
141 'FFDC Generic Report': 'BMC FFDC Manifest',
142 'BMC Specific Files': 'BMC FFDC Files',
143 'Get Request FFDC': 'BMC FFDC Get Requests',
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500144 'OS FFDC': 'OS FFDC Files',
George Keishing7a520222017-02-27 09:44:30 -0600145 'Core Files': 'SCP Coredump Files',
George Keishingeb7b4bc2017-03-13 12:04:28 -0500146 'SEL Log': 'Collect eSEL Log',
Steven Sombar96de5732017-08-17 09:04:52 -0500147 'Sys Inventory Files': 'System Inventory Files',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500148 },
149}
George Keishing4346a412016-07-19 11:26:49 -0500150
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500151# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500152
153
154# base class for FFDC default list
155class openbmc_ffdc_list():
156
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500157 def get_ffdc_bmc_cmd(self, i_type):
158 r"""
159 ########################################################################
160 # @brief This method returns the list from the dictionary for cmds
161 # @param i_type: @type string: string index lookup
162 # @return List of key pair from the dictionary
163 ########################################################################
164 """
George Keishing69e6f712016-09-12 06:30:09 -0500165 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500166
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500167 def get_ffdc_bmc_file(self, i_type):
168 r"""
169 ########################################################################
170 # @brief This method returns the list from the dictionary for scp
171 # @param i_type: @type string: string index lookup
172 # @return List of key pair from the dictionary
173 ########################################################################
174 """
George Keishing69e6f712016-09-12 06:30:09 -0500175 return FFDC_BMC_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500176
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500177 def get_ffdc_get_request(self, i_type):
178 r"""
179 ########################################################################
180 # @brief This method returns the list from the dictionary for scp
181 # @param i_type: @type string: string index lookup
182 # @return List of key pair from the dictionary
183 ########################################################################
184 """
185 return FFDC_GET_REQUEST[i_type].items()
186
George Keishing69e6f712016-09-12 06:30:09 -0500187 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500188 r"""
189 ########################################################################
190 # @brief This method returns the list index from dictionary
191 # @return List of index to the dictionary
192 ########################################################################
193 """
George Keishing69e6f712016-09-12 06:30:09 -0500194 return FFDC_BMC_CMD.keys()
195
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500196 def get_ffdc_get_request_index(self):
197 r"""
198 ########################################################################
199 # @brief This method returns the list index from dictionary
200 # @return List of index to the dictionary
201 ########################################################################
202 """
203 return FFDC_GET_REQUEST.keys()
204
George Keishing69e6f712016-09-12 06:30:09 -0500205 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500206 r"""
207 ########################################################################
208 # @brief This method returns the list index from dictionary
209 # @return List of index to the dictionary
210 ########################################################################
211 """
George Keishing69e6f712016-09-12 06:30:09 -0500212 return FFDC_BMC_FILE.keys()
213
George Keishing69e6f712016-09-12 06:30:09 -0500214 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500215 r"""
216 ########################################################################
217 # @brief This method returns the key pair from the dictionary
218 # @return Index of the method dictionary
219 ########################################################################
220 """
George Keishing69e6f712016-09-12 06:30:09 -0500221 return FFDC_METHOD_CALL.keys()
222
Michael Walshe844e9a2017-04-20 16:51:10 -0500223 def get_ffdc_method_desc(self,
224 index):
225 r"""
226 ########################################################################
227 # @brief This method returns the just the keys from the dictionary.
228 # @return List of ffdc descriptions.
229 ########################################################################
230 """
231 return FFDC_METHOD_CALL[index].keys()
232
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500233 def get_ffdc_method_call(self, i_type):
234 r"""
235 ########################################################################
236 # @brief This method returns the key pair from the dictionary
237 # @return List of key pair keywords
238 ########################################################################
239 """
George Keishing69e6f712016-09-12 06:30:09 -0500240 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500241
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500242 def get_ffdc_os_all_distros_index(self):
243 r"""
244 ########################################################################
245 # @brief This method returns the key pair from the dictionary
246 # @return Index of the method dictionary
247 ########################################################################
248 """
249 return FFDC_OS_ALL_DISTROS_FILE.keys()
250
251 def get_ffdc_os_all_distros_call(self, i_type):
252 r"""
253 ########################################################################
254 # @brief This method returns the key pair from the dictionary
255 # @return List of key pair keywords
256 ########################################################################
257 """
258 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
259
Gunnar Millscce185d2016-10-17 17:04:15 -0500260 def get_ffdc_os_distro_index(self, distro):
261 r"""
262 ########################################################################
263 # @brief This method returns the key pair from the dictionary
264 # @return Index of the method dictionary
265 ########################################################################
266 """
267 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
268 return eval(distro_file).keys()
269
270 def get_ffdc_os_distro_call(self, i_type, distro):
271 r"""
272 ########################################################################
273 # @brief This method returns the key pair from the dictionary
274 # @return List of key pair keywords
275 ########################################################################
276 """
277 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
278 return eval(distro_file)[i_type].items()
279
George Keishing4346a412016-07-19 11:26:49 -0500280 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500281 r"""
282 ########################################################################
283 # @brief Returns the stripped strings
284 # @param i_str: @type string: string name
285 # @return Remove all special chars and return the string
286 ########################################################################
287 """
George Keishing4346a412016-07-19 11:26:49 -0500288 return ''.join(e for e in i_str if e.isalnum())
George Keishing28da9482017-07-27 13:38:54 -0500289
290 def get_esel_index(self, esel_list):
291 r"""
292 #######################################################################
293 # @brief Returns the eSEL binary index.
294 # @param esel_ist: @type list: eSEL list.
295 # @return Index of "ESEL=" in the list.
296 #######################################################################
297 """
298 index = [i for i, str in enumerate(esel_list) if 'ESEL=' in str]
299 return index[0]