George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 2 | r""" |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 3 | ############################################################# |
| 4 | # @file openbmc_ffdc_list.py |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 5 | # |
| 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 Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 10 | """ |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 11 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 12 | # ------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 13 | # FFDC default list |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 14 | # ------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 15 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------- |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 17 | # Dict Name { Index string : { Key String : Command string} } |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 18 | # ----------------------------------------------------------------- |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 19 | # Add cmd's needed to be part of the ffdc report manifest file |
| 20 | FFDC_BMC_CMD = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 21 | 'DRIVER INFO': |
| 22 | { |
| 23 | # String Name Command |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 24 | 'FW Level': 'cat /etc/os-release', |
George Keishing | c5ab1b6 | 2017-08-16 13:51:14 -0500 | [diff] [blame] | 25 | 'FW Timestamp': 'cat /etc/timestamp', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 26 | }, |
| 27 | 'BMC DATA': |
| 28 | { |
| 29 | 'BMC OS': 'uname -a', |
| 30 | 'BMC Uptime': 'uptime', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 31 | 'BMC File System Disk Space Usage': 'df -hT', |
George Keishing | 342bcea | 2017-11-11 03:08:54 -0600 | [diff] [blame] | 32 | 'BMC Date Time': 'date;/sbin/hwclock --show;/usr/bin/timedatectl' |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 33 | }, |
| 34 | 'APPLICATION DATA': |
| 35 | { |
Michael Walsh | e53e47a | 2017-06-30 17:03:24 -0500 | [diff] [blame] | 36 | 'BMC state': '/usr/sbin/obmcutil state', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 37 | }, |
| 38 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 39 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 40 | # Add file name and correcponding command needed for BMC |
| 41 | FFDC_BMC_FILE = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 42 | 'BMC FILES': |
| 43 | { |
| 44 | # File Name Command |
| 45 | 'BMC_proc_list': 'top -n 1 -b', |
George Keishing | 158a76c | 2017-07-18 00:53:37 -0500 | [diff] [blame] | 46 | 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/', |
George Keishing | f6cc55e | 2017-08-30 04:16:21 -0500 | [diff] [blame] | 47 | 'BMC_journalctl_nopager': 'journalctl --no-pager', |
| 48 | 'BMC_journalctl_pretty': 'journalctl -o json-pretty', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 49 | 'BMC_dmesg': 'dmesg', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 50 | 'BMC_procinfo': 'cat /proc/cpuinfo', |
| 51 | 'BMC_meminfo': 'cat /proc/meminfo', |
George Keishing | 6ce4813 | 2017-11-13 10:46:02 -0600 | [diff] [blame] | 52 | 'BMC_systemd': 'systemctl status --all', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 53 | }, |
| 54 | } |
| 55 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 56 | # Add file name and correcponding command needed for all Linux distributions |
| 57 | FFDC_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 Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 65 | 'OS_procinfo': 'cat /proc/cpuinfo', |
| 66 | 'OS_meminfo': 'cat /proc/meminfo', |
| 67 | 'OS_netstat': 'netstat -a', |
Steven Sombar | 60ade08 | 2017-08-16 11:27:26 -0500 | [diff] [blame] | 68 | 'OS_lspci': 'lspci', |
| 69 | 'OS_lscpu': 'lscpu', |
| 70 | 'OS_lscfg': 'lscfg', |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 71 | }, |
| 72 | } |
| 73 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 74 | # Add file name and correcponding command needed for Ubuntu Linux |
| 75 | FFDC_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 |
| 88 | FFDC_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 |
| 100 | FFDC_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 Keishing | f77ea87 | 2017-09-01 08:02:21 -0500 | [diff] [blame] | 110 | OPENBMC_BASE = '/xyz/openbmc_project/' |
George Keishing | ba00038 | 2017-09-19 13:25:29 -0500 | [diff] [blame] | 111 | OPENPOWER_BASE = '/org/open_power/' |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 112 | ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' |
George Keishing | f77ea87 | 2017-09-01 08:02:21 -0500 | [diff] [blame] | 113 | ENUMERATE_INVENTORY = OPENBMC_BASE + 'inventory/enumerate' |
| 114 | ENUMERATE_ELOG = OPENBMC_BASE + 'logging/entry/enumerate' |
| 115 | ENUMERATE_LED = OPENBMC_BASE + 'led/enumerate' |
| 116 | ENUMERATE_SW = OPENBMC_BASE + 'software/enumerate' |
| 117 | ENUMERATE_CONTROL = OPENBMC_BASE + 'control/enumerate' |
George Keishing | 9be77cd | 2017-11-13 07:52:08 -0600 | [diff] [blame^] | 118 | ENUMERATE_STATE = OPENBMC_BASE + 'state/enumerate' |
George Keishing | ba00038 | 2017-09-19 13:25:29 -0500 | [diff] [blame] | 119 | ENUMERATE_OCC = OPENPOWER_BASE + 'control/enumerate' |
George Keishing | 49e24a7 | 2017-08-09 11:37:42 -0500 | [diff] [blame] | 120 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 121 | # Add file name and correcponding Get Request |
| 122 | FFDC_GET_REQUEST = { |
| 123 | 'GET REQUESTS': |
| 124 | { |
| 125 | # File Name Command |
George Keishing | f77ea87 | 2017-09-01 08:02:21 -0500 | [diff] [blame] | 126 | 'FIRMWARE_list': ENUMERATE_SW, |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 127 | 'BMC_sensor_list': ENUMERATE_SENSORS, |
George Keishing | 49e24a7 | 2017-08-09 11:37:42 -0500 | [diff] [blame] | 128 | 'BMC_control_list': ENUMERATE_CONTROL, |
George Keishing | f77ea87 | 2017-09-01 08:02:21 -0500 | [diff] [blame] | 129 | 'BMC_inventory': ENUMERATE_INVENTORY, |
George Keishing | c06fc99 | 2017-02-22 09:01:08 -0600 | [diff] [blame] | 130 | 'BMC_elog': ENUMERATE_ELOG, |
George Keishing | f77ea87 | 2017-09-01 08:02:21 -0500 | [diff] [blame] | 131 | 'BMC_led': ENUMERATE_LED, |
George Keishing | 9be77cd | 2017-11-13 07:52:08 -0600 | [diff] [blame^] | 132 | 'BMC_state': ENUMERATE_STATE, |
George Keishing | ba00038 | 2017-09-19 13:25:29 -0500 | [diff] [blame] | 133 | 'OCC_state': ENUMERATE_OCC, |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 134 | }, |
| 135 | } |
| 136 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 137 | |
| 138 | # Define your keywords in method/utils and call here |
| 139 | FFDC_METHOD_CALL = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 140 | '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 Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 146 | 'OS FFDC': 'OS FFDC Files', |
George Keishing | 7a52022 | 2017-02-27 09:44:30 -0600 | [diff] [blame] | 147 | 'Core Files': 'SCP Coredump Files', |
George Keishing | eb7b4bc | 2017-03-13 12:04:28 -0500 | [diff] [blame] | 148 | 'SEL Log': 'Collect eSEL Log', |
Steven Sombar | 96de573 | 2017-08-17 09:04:52 -0500 | [diff] [blame] | 149 | 'Sys Inventory Files': 'System Inventory Files', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 150 | }, |
| 151 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 152 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 153 | # ----------------------------------------------------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 154 | |
| 155 | |
| 156 | # base class for FFDC default list |
| 157 | class openbmc_ffdc_list(): |
| 158 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 159 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 167 | return FFDC_BMC_CMD[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 168 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 169 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 177 | return FFDC_BMC_FILE[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 178 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 179 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 189 | def get_ffdc_cmd_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 190 | r""" |
| 191 | ######################################################################## |
| 192 | # @brief This method returns the list index from dictionary |
| 193 | # @return List of index to the dictionary |
| 194 | ######################################################################## |
| 195 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 196 | return FFDC_BMC_CMD.keys() |
| 197 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 198 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 207 | def get_ffdc_file_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 208 | r""" |
| 209 | ######################################################################## |
| 210 | # @brief This method returns the list index from dictionary |
| 211 | # @return List of index to the dictionary |
| 212 | ######################################################################## |
| 213 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 214 | return FFDC_BMC_FILE.keys() |
| 215 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 216 | def get_ffdc_method_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 217 | r""" |
| 218 | ######################################################################## |
| 219 | # @brief This method returns the key pair from the dictionary |
| 220 | # @return Index of the method dictionary |
| 221 | ######################################################################## |
| 222 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 223 | return FFDC_METHOD_CALL.keys() |
| 224 | |
Michael Walsh | e844e9a | 2017-04-20 16:51:10 -0500 | [diff] [blame] | 225 | 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 Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 235 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 242 | return FFDC_METHOD_CALL[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 243 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 244 | 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 Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 262 | 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 Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 282 | def get_strip_string(self, i_str): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 283 | 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 Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 290 | return ''.join(e for e in i_str if e.isalnum()) |
George Keishing | 28da948 | 2017-07-27 13:38:54 -0500 | [diff] [blame] | 291 | |
| 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] |