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 | # ----------------------------------------------------------------- |
| 17 | # Dict Name { Index string : { Key String : Comand string} } |
| 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 |
| 24 | 'Build Info': 'cat /etc/version', |
| 25 | 'FW Level': 'cat /etc/os-release', |
| 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', |
| 32 | }, |
| 33 | 'APPLICATION DATA': |
| 34 | { |
| 35 | 'BMC state': '/usr/sbin/obmcutil state', |
| 36 | }, |
| 37 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 38 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 39 | # Add file name and correcponding command needed for BMC |
| 40 | FFDC_BMC_FILE = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 41 | 'BMC FILES': |
| 42 | { |
| 43 | # File Name Command |
| 44 | 'BMC_proc_list': 'top -n 1 -b', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 45 | 'BMC_journalctl': 'journalctl --no-pager', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 46 | 'BMC_dmesg': 'dmesg', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 47 | 'BMC_procinfo': 'cat /proc/cpuinfo', |
| 48 | 'BMC_meminfo': 'cat /proc/meminfo', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 49 | }, |
| 50 | } |
| 51 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 52 | # Add file name and correcponding command needed for all Linux distributions |
| 53 | FFDC_OS_ALL_DISTROS_FILE = { |
| 54 | 'OS FILES': |
| 55 | { |
| 56 | # File Name Command |
| 57 | 'OS_msglog': 'cat /sys/firmware/opal/msglog', |
| 58 | 'OS_cpufrequency': 'ppc64_cpu --frequency', |
| 59 | 'OS_dmesg': 'dmesg', |
| 60 | 'OS_boot': 'cat /var/log/boot.log', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 61 | 'OS_procinfo': 'cat /proc/cpuinfo', |
| 62 | 'OS_meminfo': 'cat /proc/meminfo', |
| 63 | 'OS_netstat': 'netstat -a', |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 64 | }, |
| 65 | } |
| 66 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 67 | # Add file name and correcponding command needed for Ubuntu Linux |
| 68 | FFDC_OS_UBUNTU_FILE = { |
| 69 | 'OS FILES': |
| 70 | { |
| 71 | # File Name Command |
| 72 | 'OS_isusb': 'lsusb -t ; lsusb -v', |
| 73 | 'OS_kern': 'tail -n 50000 /var/log/kern.log', |
| 74 | 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1', |
| 75 | 'OS_syslog': 'tail -n 200000 /var/log/syslog', |
| 76 | 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool', |
| 77 | }, |
| 78 | } |
| 79 | |
| 80 | # Add file name and correcponding command needed for RHEL Linux |
| 81 | FFDC_OS_RHEL_FILE = { |
| 82 | 'OS FILES': |
| 83 | { |
| 84 | # File Name Command |
| 85 | 'OS_rsct': '/usr/bin/ctversion -bv', |
| 86 | 'OS_secure': 'cat /var/log/secure', |
| 87 | 'OS_syslog': 'tail -n 200000 /var/log/messages', |
| 88 | 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa', |
| 89 | }, |
| 90 | } |
| 91 | |
| 92 | # Add file name and correcponding command needed for RHEL Linux |
| 93 | FFDC_OS_IBM_POWERKVM_FILE = { |
| 94 | 'OS FILES': |
| 95 | { |
| 96 | # File Name Command |
| 97 | 'OS_secure': 'cat /var/log/secure', |
| 98 | 'OS_syslog': 'tail -n 200000 /var/log/messages', |
| 99 | 'OS_info': 'lsb_release -a; uname -a; rpm -qa', |
| 100 | }, |
| 101 | } |
| 102 | |
George Keishing | 136bcc6 | 2016-11-23 08:34:16 -0600 | [diff] [blame] | 103 | # Enable when ready with openbmc/openbmc-test-automation#203 |
| 104 | # replace with new path /xyz/openbmc_project |
| 105 | OPENBMC_BASE = '/org/openbmc/' |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 106 | ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' |
George Keishing | 7f7040c | 2017-02-20 10:23:56 -0600 | [diff] [blame] | 107 | # TODO: Use the xyz enums once moved to xyz completely |
| 108 | # ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/enumerate' |
George Keishing | c06fc99 | 2017-02-22 09:01:08 -0600 | [diff] [blame] | 109 | ENUMERATE_SYSTEMS = '/xyz/openbmc_project/inventory/enumerate' |
| 110 | ENUMERATE_ELOG = '/xyz/openbmc_project/logging/entry/enumerate' |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 111 | ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate' |
| 112 | ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate' |
| 113 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 114 | # Add file name and correcponding Get Request |
| 115 | FFDC_GET_REQUEST = { |
| 116 | 'GET REQUESTS': |
| 117 | { |
| 118 | # File Name Command |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 119 | 'BMC_sensor_list': ENUMERATE_SENSORS, |
| 120 | 'BMC_inventory': ENUMERATE_SYSTEMS, |
George Keishing | c06fc99 | 2017-02-22 09:01:08 -0600 | [diff] [blame] | 121 | 'BMC_elog': ENUMERATE_ELOG, |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame] | 122 | 'BMC_led': ENUMERATE_EVENTS, |
| 123 | 'BMC_record_log': ENUMERATE_LED, |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 124 | }, |
| 125 | } |
| 126 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 127 | |
| 128 | # Define your keywords in method/utils and call here |
| 129 | FFDC_METHOD_CALL = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 130 | 'BMC LOGS': |
| 131 | { |
| 132 | # Description Keyword name |
| 133 | 'FFDC Generic Report': 'BMC FFDC Manifest', |
| 134 | 'BMC Specific Files': 'BMC FFDC Files', |
| 135 | 'Get Request FFDC': 'BMC FFDC Get Requests', |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 136 | 'OS FFDC': 'OS FFDC Files', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 137 | }, |
| 138 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 139 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 140 | # ----------------------------------------------------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 141 | |
| 142 | |
| 143 | # base class for FFDC default list |
| 144 | class openbmc_ffdc_list(): |
| 145 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 146 | def get_ffdc_bmc_cmd(self, i_type): |
| 147 | r""" |
| 148 | ######################################################################## |
| 149 | # @brief This method returns the list from the dictionary for cmds |
| 150 | # @param i_type: @type string: string index lookup |
| 151 | # @return List of key pair from the dictionary |
| 152 | ######################################################################## |
| 153 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 154 | return FFDC_BMC_CMD[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 155 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 156 | def get_ffdc_bmc_file(self, i_type): |
| 157 | r""" |
| 158 | ######################################################################## |
| 159 | # @brief This method returns the list from the dictionary for scp |
| 160 | # @param i_type: @type string: string index lookup |
| 161 | # @return List of key pair from the dictionary |
| 162 | ######################################################################## |
| 163 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 164 | return FFDC_BMC_FILE[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 165 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 166 | def get_ffdc_get_request(self, i_type): |
| 167 | r""" |
| 168 | ######################################################################## |
| 169 | # @brief This method returns the list from the dictionary for scp |
| 170 | # @param i_type: @type string: string index lookup |
| 171 | # @return List of key pair from the dictionary |
| 172 | ######################################################################## |
| 173 | """ |
| 174 | return FFDC_GET_REQUEST[i_type].items() |
| 175 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 176 | def get_ffdc_cmd_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 177 | r""" |
| 178 | ######################################################################## |
| 179 | # @brief This method returns the list index from dictionary |
| 180 | # @return List of index to the dictionary |
| 181 | ######################################################################## |
| 182 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 183 | return FFDC_BMC_CMD.keys() |
| 184 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 185 | def get_ffdc_get_request_index(self): |
| 186 | r""" |
| 187 | ######################################################################## |
| 188 | # @brief This method returns the list index from dictionary |
| 189 | # @return List of index to the dictionary |
| 190 | ######################################################################## |
| 191 | """ |
| 192 | return FFDC_GET_REQUEST.keys() |
| 193 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 194 | def get_ffdc_file_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 195 | r""" |
| 196 | ######################################################################## |
| 197 | # @brief This method returns the list index from dictionary |
| 198 | # @return List of index to the dictionary |
| 199 | ######################################################################## |
| 200 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 201 | return FFDC_BMC_FILE.keys() |
| 202 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 203 | def get_ffdc_method_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 204 | r""" |
| 205 | ######################################################################## |
| 206 | # @brief This method returns the key pair from the dictionary |
| 207 | # @return Index of the method dictionary |
| 208 | ######################################################################## |
| 209 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 210 | return FFDC_METHOD_CALL.keys() |
| 211 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 212 | def get_ffdc_method_call(self, i_type): |
| 213 | r""" |
| 214 | ######################################################################## |
| 215 | # @brief This method returns the key pair from the dictionary |
| 216 | # @return List of key pair keywords |
| 217 | ######################################################################## |
| 218 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 219 | return FFDC_METHOD_CALL[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 220 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 221 | def get_ffdc_os_all_distros_index(self): |
| 222 | r""" |
| 223 | ######################################################################## |
| 224 | # @brief This method returns the key pair from the dictionary |
| 225 | # @return Index of the method dictionary |
| 226 | ######################################################################## |
| 227 | """ |
| 228 | return FFDC_OS_ALL_DISTROS_FILE.keys() |
| 229 | |
| 230 | def get_ffdc_os_all_distros_call(self, i_type): |
| 231 | r""" |
| 232 | ######################################################################## |
| 233 | # @brief This method returns the key pair from the dictionary |
| 234 | # @return List of key pair keywords |
| 235 | ######################################################################## |
| 236 | """ |
| 237 | return FFDC_OS_ALL_DISTROS_FILE[i_type].items() |
| 238 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 239 | def get_ffdc_os_distro_index(self, distro): |
| 240 | r""" |
| 241 | ######################################################################## |
| 242 | # @brief This method returns the key pair from the dictionary |
| 243 | # @return Index of the method dictionary |
| 244 | ######################################################################## |
| 245 | """ |
| 246 | distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" |
| 247 | return eval(distro_file).keys() |
| 248 | |
| 249 | def get_ffdc_os_distro_call(self, i_type, distro): |
| 250 | r""" |
| 251 | ######################################################################## |
| 252 | # @brief This method returns the key pair from the dictionary |
| 253 | # @return List of key pair keywords |
| 254 | ######################################################################## |
| 255 | """ |
| 256 | distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" |
| 257 | return eval(distro_file)[i_type].items() |
| 258 | |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 259 | def get_strip_string(self, i_str): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 260 | r""" |
| 261 | ######################################################################## |
| 262 | # @brief Returns the stripped strings |
| 263 | # @param i_str: @type string: string name |
| 264 | # @return Remove all special chars and return the string |
| 265 | ######################################################################## |
| 266 | """ |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 267 | return ''.join(e for e in i_str if e.isalnum()) |