blob: 915fd4a706a0c8794edd0dfdd749ea9505428365 [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 {
34 'BMC state': '/usr/sbin/obmcutil state',
35 },
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',
Gunnar Millsaca140d2016-10-26 13:05:10 -050044 'BMC_journalctl': 'journalctl --no-pager',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050045 'BMC_dmesg': 'dmesg',
Gunnar Millsaca140d2016-10-26 13:05:10 -050046 'BMC_procinfo': 'cat /proc/cpuinfo',
47 'BMC_meminfo': 'cat /proc/meminfo',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050048 },
49}
50
Gunnar Mills7e2cda22016-10-11 15:37:34 -050051# Add file name and correcponding command needed for all Linux distributions
52FFDC_OS_ALL_DISTROS_FILE = {
53 'OS FILES':
54 {
55 # File Name Command
56 'OS_msglog': 'cat /sys/firmware/opal/msglog',
57 'OS_cpufrequency': 'ppc64_cpu --frequency',
58 'OS_dmesg': 'dmesg',
59 'OS_boot': 'cat /var/log/boot.log',
Gunnar Millsaca140d2016-10-26 13:05:10 -050060 'OS_procinfo': 'cat /proc/cpuinfo',
61 'OS_meminfo': 'cat /proc/meminfo',
62 'OS_netstat': 'netstat -a',
Gunnar Mills7e2cda22016-10-11 15:37:34 -050063 },
64}
65
Gunnar Millscce185d2016-10-17 17:04:15 -050066# Add file name and correcponding command needed for Ubuntu Linux
67FFDC_OS_UBUNTU_FILE = {
68 'OS FILES':
69 {
70 # File Name Command
71 'OS_isusb': 'lsusb -t ; lsusb -v',
72 'OS_kern': 'tail -n 50000 /var/log/kern.log',
73 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
74 'OS_syslog': 'tail -n 200000 /var/log/syslog',
75 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
76 },
77}
78
79# Add file name and correcponding command needed for RHEL Linux
80FFDC_OS_RHEL_FILE = {
81 'OS FILES':
82 {
83 # File Name Command
84 'OS_rsct': '/usr/bin/ctversion -bv',
85 'OS_secure': 'cat /var/log/secure',
86 'OS_syslog': 'tail -n 200000 /var/log/messages',
87 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
88 },
89}
90
91# Add file name and correcponding command needed for RHEL Linux
92FFDC_OS_IBM_POWERKVM_FILE = {
93 'OS FILES':
94 {
95 # File Name Command
96 'OS_secure': 'cat /var/log/secure',
97 'OS_syslog': 'tail -n 200000 /var/log/messages',
98 'OS_info': 'lsb_release -a; uname -a; rpm -qa',
99 },
100}
101
George Keishing136bcc62016-11-23 08:34:16 -0600102# Enable when ready with openbmc/openbmc-test-automation#203
103# replace with new path /xyz/openbmc_project
104OPENBMC_BASE = '/org/openbmc/'
George Keishingfe5724d2016-11-23 09:25:36 -0600105ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate'
George Keishing7f7040c2017-02-20 10:23:56 -0600106# TODO: Use the xyz enums once moved to xyz completely
107# ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/enumerate'
George Keishingc06fc992017-02-22 09:01:08 -0600108ENUMERATE_SYSTEMS = '/xyz/openbmc_project/inventory/enumerate'
109ENUMERATE_ELOG = '/xyz/openbmc_project/logging/entry/enumerate'
George Keishingfe5724d2016-11-23 09:25:36 -0600110ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate'
111ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate'
112
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500113# Add file name and correcponding Get Request
114FFDC_GET_REQUEST = {
115 'GET REQUESTS':
116 {
117 # File Name Command
George Keishingfe5724d2016-11-23 09:25:36 -0600118 'BMC_sensor_list': ENUMERATE_SENSORS,
119 'BMC_inventory': ENUMERATE_SYSTEMS,
George Keishingc06fc992017-02-22 09:01:08 -0600120 'BMC_elog': ENUMERATE_ELOG,
George Keishingfe5724d2016-11-23 09:25:36 -0600121 'BMC_led': ENUMERATE_EVENTS,
122 'BMC_record_log': ENUMERATE_LED,
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500123 },
124}
125
George Keishing69e6f712016-09-12 06:30:09 -0500126
127# Define your keywords in method/utils and call here
128FFDC_METHOD_CALL = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500129 'BMC LOGS':
130 {
131 # Description Keyword name
132 'FFDC Generic Report': 'BMC FFDC Manifest',
133 'BMC Specific Files': 'BMC FFDC Files',
134 'Get Request FFDC': 'BMC FFDC Get Requests',
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500135 'OS FFDC': 'OS FFDC Files',
George Keishing7a520222017-02-27 09:44:30 -0600136 'Core Files': 'SCP Coredump Files',
George Keishingeb7b4bc2017-03-13 12:04:28 -0500137 'SEL Log': 'Collect eSEL Log',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500138 },
139}
George Keishing4346a412016-07-19 11:26:49 -0500140
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500141# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500142
143
144# base class for FFDC default list
145class openbmc_ffdc_list():
146
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500147 def get_ffdc_bmc_cmd(self, i_type):
148 r"""
149 ########################################################################
150 # @brief This method returns the list from the dictionary for cmds
151 # @param i_type: @type string: string index lookup
152 # @return List of key pair from the dictionary
153 ########################################################################
154 """
George Keishing69e6f712016-09-12 06:30:09 -0500155 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500156
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500157 def get_ffdc_bmc_file(self, i_type):
158 r"""
159 ########################################################################
160 # @brief This method returns the list from the dictionary for scp
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_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500166
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500167 def get_ffdc_get_request(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 """
175 return FFDC_GET_REQUEST[i_type].items()
176
George Keishing69e6f712016-09-12 06:30:09 -0500177 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500178 r"""
179 ########################################################################
180 # @brief This method returns the list index from dictionary
181 # @return List of index to the dictionary
182 ########################################################################
183 """
George Keishing69e6f712016-09-12 06:30:09 -0500184 return FFDC_BMC_CMD.keys()
185
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500186 def get_ffdc_get_request_index(self):
187 r"""
188 ########################################################################
189 # @brief This method returns the list index from dictionary
190 # @return List of index to the dictionary
191 ########################################################################
192 """
193 return FFDC_GET_REQUEST.keys()
194
George Keishing69e6f712016-09-12 06:30:09 -0500195 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500196 r"""
197 ########################################################################
198 # @brief This method returns the list index from dictionary
199 # @return List of index to the dictionary
200 ########################################################################
201 """
George Keishing69e6f712016-09-12 06:30:09 -0500202 return FFDC_BMC_FILE.keys()
203
George Keishing69e6f712016-09-12 06:30:09 -0500204 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500205 r"""
206 ########################################################################
207 # @brief This method returns the key pair from the dictionary
208 # @return Index of the method dictionary
209 ########################################################################
210 """
George Keishing69e6f712016-09-12 06:30:09 -0500211 return FFDC_METHOD_CALL.keys()
212
Michael Walshe844e9a2017-04-20 16:51:10 -0500213 def get_ffdc_method_desc(self,
214 index):
215 r"""
216 ########################################################################
217 # @brief This method returns the just the keys from the dictionary.
218 # @return List of ffdc descriptions.
219 ########################################################################
220 """
221 return FFDC_METHOD_CALL[index].keys()
222
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500223 def get_ffdc_method_call(self, i_type):
224 r"""
225 ########################################################################
226 # @brief This method returns the key pair from the dictionary
227 # @return List of key pair keywords
228 ########################################################################
229 """
George Keishing69e6f712016-09-12 06:30:09 -0500230 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500231
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500232 def get_ffdc_os_all_distros_index(self):
233 r"""
234 ########################################################################
235 # @brief This method returns the key pair from the dictionary
236 # @return Index of the method dictionary
237 ########################################################################
238 """
239 return FFDC_OS_ALL_DISTROS_FILE.keys()
240
241 def get_ffdc_os_all_distros_call(self, i_type):
242 r"""
243 ########################################################################
244 # @brief This method returns the key pair from the dictionary
245 # @return List of key pair keywords
246 ########################################################################
247 """
248 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
249
Gunnar Millscce185d2016-10-17 17:04:15 -0500250 def get_ffdc_os_distro_index(self, distro):
251 r"""
252 ########################################################################
253 # @brief This method returns the key pair from the dictionary
254 # @return Index of the method dictionary
255 ########################################################################
256 """
257 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
258 return eval(distro_file).keys()
259
260 def get_ffdc_os_distro_call(self, i_type, distro):
261 r"""
262 ########################################################################
263 # @brief This method returns the key pair from the dictionary
264 # @return List of key pair keywords
265 ########################################################################
266 """
267 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
268 return eval(distro_file)[i_type].items()
269
George Keishing4346a412016-07-19 11:26:49 -0500270 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500271 r"""
272 ########################################################################
273 # @brief Returns the stripped strings
274 # @param i_str: @type string: string name
275 # @return Remove all special chars and return the string
276 ########################################################################
277 """
George Keishing4346a412016-07-19 11:26:49 -0500278 return ''.join(e for e in i_str if e.isalnum())