blob: e71f0c4e925dfc2606e41a76d92bbc346781e3f6 [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
George Keishingfe5724d2016-11-23 09:25:36 -060012from robot.libraries.BuiltIn import BuiltIn
13
Gunnar Millsa812e0f2016-09-29 20:30:03 -050014# -------------------
George Keishing4346a412016-07-19 11:26:49 -050015# FFDC default list
Gunnar Millsa812e0f2016-09-29 20:30:03 -050016# -------------------
George Keishing4346a412016-07-19 11:26:49 -050017
Gunnar Millsa812e0f2016-09-29 20:30:03 -050018# -----------------------------------------------------------------
19# Dict Name { Index string : { Key String : Comand string} }
20# -----------------------------------------------------------------
George Keishing69e6f712016-09-12 06:30:09 -050021# Add cmd's needed to be part of the ffdc report manifest file
22FFDC_BMC_CMD = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050023 'DRIVER INFO':
24 {
25 # String Name Command
26 'Build Info': 'cat /etc/version',
27 'FW Level': 'cat /etc/os-release',
28 },
29 'BMC DATA':
30 {
31 'BMC OS': 'uname -a',
32 'BMC Uptime': 'uptime',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050033 'BMC File System Disk Space Usage': 'df -hT',
34 },
35 'APPLICATION DATA':
36 {
37 'BMC state': '/usr/sbin/obmcutil state',
38 },
39}
George Keishing4346a412016-07-19 11:26:49 -050040
George Keishing69e6f712016-09-12 06:30:09 -050041# Add file name and correcponding command needed for BMC
42FFDC_BMC_FILE = {
Gunnar Millsa812e0f2016-09-29 20:30:03 -050043 'BMC FILES':
44 {
45 # File Name Command
46 'BMC_proc_list': 'top -n 1 -b',
Gunnar Millsaca140d2016-10-26 13:05:10 -050047 'BMC_journalctl': 'journalctl --no-pager',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050048 'BMC_dmesg': 'dmesg',
Gunnar Millsaca140d2016-10-26 13:05:10 -050049 'BMC_procinfo': 'cat /proc/cpuinfo',
50 'BMC_meminfo': 'cat /proc/meminfo',
Gunnar Millsa812e0f2016-09-29 20:30:03 -050051 },
52}
53
Gunnar Mills7e2cda22016-10-11 15:37:34 -050054# Add file name and correcponding command needed for all Linux distributions
55FFDC_OS_ALL_DISTROS_FILE = {
56 'OS FILES':
57 {
58 # File Name Command
59 'OS_msglog': 'cat /sys/firmware/opal/msglog',
60 'OS_cpufrequency': 'ppc64_cpu --frequency',
61 'OS_dmesg': 'dmesg',
62 'OS_boot': 'cat /var/log/boot.log',
Gunnar Millsaca140d2016-10-26 13:05:10 -050063 'OS_procinfo': 'cat /proc/cpuinfo',
64 'OS_meminfo': 'cat /proc/meminfo',
65 'OS_netstat': 'netstat -a',
Gunnar Mills7e2cda22016-10-11 15:37:34 -050066 },
67}
68
Gunnar Millscce185d2016-10-17 17:04:15 -050069# Add file name and correcponding command needed for Ubuntu Linux
70FFDC_OS_UBUNTU_FILE = {
71 'OS FILES':
72 {
73 # File Name Command
74 'OS_isusb': 'lsusb -t ; lsusb -v',
75 'OS_kern': 'tail -n 50000 /var/log/kern.log',
76 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1',
77 'OS_syslog': 'tail -n 200000 /var/log/syslog',
78 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool',
79 },
80}
81
82# Add file name and correcponding command needed for RHEL Linux
83FFDC_OS_RHEL_FILE = {
84 'OS FILES':
85 {
86 # File Name Command
87 'OS_rsct': '/usr/bin/ctversion -bv',
88 'OS_secure': 'cat /var/log/secure',
89 'OS_syslog': 'tail -n 200000 /var/log/messages',
90 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa',
91 },
92}
93
94# Add file name and correcponding command needed for RHEL Linux
95FFDC_OS_IBM_POWERKVM_FILE = {
96 'OS FILES':
97 {
98 # File Name Command
99 'OS_secure': 'cat /var/log/secure',
100 'OS_syslog': 'tail -n 200000 /var/log/messages',
101 'OS_info': 'lsb_release -a; uname -a; rpm -qa',
102 },
103}
104
George Keishingfe5724d2016-11-23 09:25:36 -0600105# import variables from resource.txt file
106BuiltIn().import_resource('resource.txt')
107OPENBMC_BASE = BuiltIn().get_variable_value('${OPENBMC_BASE_URI}')
108
109ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate'
110ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/system/enumerate'
111ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate'
112ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate'
113
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500114# Add file name and correcponding Get Request
115FFDC_GET_REQUEST = {
116 'GET REQUESTS':
117 {
118 # File Name Command
George Keishingfe5724d2016-11-23 09:25:36 -0600119 'BMC_sensor_list': ENUMERATE_SENSORS,
120 'BMC_inventory': ENUMERATE_SYSTEMS,
121 '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',
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500136 },
137}
George Keishing4346a412016-07-19 11:26:49 -0500138
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500139# -----------------------------------------------------------------
George Keishing4346a412016-07-19 11:26:49 -0500140
141
142# base class for FFDC default list
143class openbmc_ffdc_list():
144
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500145 def get_ffdc_bmc_cmd(self, i_type):
146 r"""
147 ########################################################################
148 # @brief This method returns the list from the dictionary for cmds
149 # @param i_type: @type string: string index lookup
150 # @return List of key pair from the dictionary
151 ########################################################################
152 """
George Keishing69e6f712016-09-12 06:30:09 -0500153 return FFDC_BMC_CMD[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500154
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500155 def get_ffdc_bmc_file(self, i_type):
156 r"""
157 ########################################################################
158 # @brief This method returns the list from the dictionary for scp
159 # @param i_type: @type string: string index lookup
160 # @return List of key pair from the dictionary
161 ########################################################################
162 """
George Keishing69e6f712016-09-12 06:30:09 -0500163 return FFDC_BMC_FILE[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500164
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500165 def get_ffdc_get_request(self, i_type):
166 r"""
167 ########################################################################
168 # @brief This method returns the list from the dictionary for scp
169 # @param i_type: @type string: string index lookup
170 # @return List of key pair from the dictionary
171 ########################################################################
172 """
173 return FFDC_GET_REQUEST[i_type].items()
174
George Keishing69e6f712016-09-12 06:30:09 -0500175 def get_ffdc_cmd_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500176 r"""
177 ########################################################################
178 # @brief This method returns the list index from dictionary
179 # @return List of index to the dictionary
180 ########################################################################
181 """
George Keishing69e6f712016-09-12 06:30:09 -0500182 return FFDC_BMC_CMD.keys()
183
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500184 def get_ffdc_get_request_index(self):
185 r"""
186 ########################################################################
187 # @brief This method returns the list index from dictionary
188 # @return List of index to the dictionary
189 ########################################################################
190 """
191 return FFDC_GET_REQUEST.keys()
192
George Keishing69e6f712016-09-12 06:30:09 -0500193 def get_ffdc_file_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500194 r"""
195 ########################################################################
196 # @brief This method returns the list index from dictionary
197 # @return List of index to the dictionary
198 ########################################################################
199 """
George Keishing69e6f712016-09-12 06:30:09 -0500200 return FFDC_BMC_FILE.keys()
201
George Keishing69e6f712016-09-12 06:30:09 -0500202 def get_ffdc_method_index(self):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500203 r"""
204 ########################################################################
205 # @brief This method returns the key pair from the dictionary
206 # @return Index of the method dictionary
207 ########################################################################
208 """
George Keishing69e6f712016-09-12 06:30:09 -0500209 return FFDC_METHOD_CALL.keys()
210
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500211 def get_ffdc_method_call(self, i_type):
212 r"""
213 ########################################################################
214 # @brief This method returns the key pair from the dictionary
215 # @return List of key pair keywords
216 ########################################################################
217 """
George Keishing69e6f712016-09-12 06:30:09 -0500218 return FFDC_METHOD_CALL[i_type].items()
George Keishing4346a412016-07-19 11:26:49 -0500219
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500220 def get_ffdc_os_all_distros_index(self):
221 r"""
222 ########################################################################
223 # @brief This method returns the key pair from the dictionary
224 # @return Index of the method dictionary
225 ########################################################################
226 """
227 return FFDC_OS_ALL_DISTROS_FILE.keys()
228
229 def get_ffdc_os_all_distros_call(self, i_type):
230 r"""
231 ########################################################################
232 # @brief This method returns the key pair from the dictionary
233 # @return List of key pair keywords
234 ########################################################################
235 """
236 return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
237
Gunnar Millscce185d2016-10-17 17:04:15 -0500238 def get_ffdc_os_distro_index(self, distro):
239 r"""
240 ########################################################################
241 # @brief This method returns the key pair from the dictionary
242 # @return Index of the method dictionary
243 ########################################################################
244 """
245 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
246 return eval(distro_file).keys()
247
248 def get_ffdc_os_distro_call(self, i_type, distro):
249 r"""
250 ########################################################################
251 # @brief This method returns the key pair from the dictionary
252 # @return List of key pair keywords
253 ########################################################################
254 """
255 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
256 return eval(distro_file)[i_type].items()
257
George Keishing4346a412016-07-19 11:26:49 -0500258 def get_strip_string(self, i_str):
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500259 r"""
260 ########################################################################
261 # @brief Returns the stripped strings
262 # @param i_str: @type string: string name
263 # @return Remove all special chars and return the string
264 ########################################################################
265 """
George Keishing4346a412016-07-19 11:26:49 -0500266 return ''.join(e for e in i_str if e.isalnum())