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 | |
George Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame^] | 12 | from robot.libraries.BuiltIn import BuiltIn |
| 13 | |
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 | # FFDC default list |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 16 | # ------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 17 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 18 | # ----------------------------------------------------------------- |
| 19 | # Dict Name { Index string : { Key String : Comand string} } |
| 20 | # ----------------------------------------------------------------- |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 21 | # Add cmd's needed to be part of the ffdc report manifest file |
| 22 | FFDC_BMC_CMD = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 23 | '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 Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 33 | 'BMC File System Disk Space Usage': 'df -hT', |
| 34 | }, |
| 35 | 'APPLICATION DATA': |
| 36 | { |
| 37 | 'BMC state': '/usr/sbin/obmcutil state', |
| 38 | }, |
| 39 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 40 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 41 | # Add file name and correcponding command needed for BMC |
| 42 | FFDC_BMC_FILE = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 43 | 'BMC FILES': |
| 44 | { |
| 45 | # File Name Command |
| 46 | 'BMC_proc_list': 'top -n 1 -b', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 47 | 'BMC_journalctl': 'journalctl --no-pager', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 48 | 'BMC_dmesg': 'dmesg', |
Gunnar Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 49 | 'BMC_procinfo': 'cat /proc/cpuinfo', |
| 50 | 'BMC_meminfo': 'cat /proc/meminfo', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 51 | }, |
| 52 | } |
| 53 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 54 | # Add file name and correcponding command needed for all Linux distributions |
| 55 | FFDC_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 Mills | aca140d | 2016-10-26 13:05:10 -0500 | [diff] [blame] | 63 | 'OS_procinfo': 'cat /proc/cpuinfo', |
| 64 | 'OS_meminfo': 'cat /proc/meminfo', |
| 65 | 'OS_netstat': 'netstat -a', |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 66 | }, |
| 67 | } |
| 68 | |
Gunnar Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 69 | # Add file name and correcponding command needed for Ubuntu Linux |
| 70 | FFDC_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 |
| 83 | FFDC_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 |
| 95 | FFDC_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 Keishing | fe5724d | 2016-11-23 09:25:36 -0600 | [diff] [blame^] | 105 | # import variables from resource.txt file |
| 106 | BuiltIn().import_resource('resource.txt') |
| 107 | OPENBMC_BASE = BuiltIn().get_variable_value('${OPENBMC_BASE_URI}') |
| 108 | |
| 109 | ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' |
| 110 | ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/system/enumerate' |
| 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, |
| 121 | 'BMC_led': ENUMERATE_EVENTS, |
| 122 | 'BMC_record_log': ENUMERATE_LED, |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 123 | }, |
| 124 | } |
| 125 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 126 | |
| 127 | # Define your keywords in method/utils and call here |
| 128 | FFDC_METHOD_CALL = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 129 | '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 Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 135 | 'OS FFDC': 'OS FFDC Files', |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 136 | }, |
| 137 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 138 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 139 | # ----------------------------------------------------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 140 | |
| 141 | |
| 142 | # base class for FFDC default list |
| 143 | class openbmc_ffdc_list(): |
| 144 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 145 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 153 | return FFDC_BMC_CMD[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 154 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 155 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 163 | return FFDC_BMC_FILE[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 164 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 165 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 175 | def get_ffdc_cmd_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 176 | r""" |
| 177 | ######################################################################## |
| 178 | # @brief This method returns the list index from dictionary |
| 179 | # @return List of index to the dictionary |
| 180 | ######################################################################## |
| 181 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 182 | return FFDC_BMC_CMD.keys() |
| 183 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 184 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 193 | def get_ffdc_file_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 194 | r""" |
| 195 | ######################################################################## |
| 196 | # @brief This method returns the list index from dictionary |
| 197 | # @return List of index to the dictionary |
| 198 | ######################################################################## |
| 199 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 200 | return FFDC_BMC_FILE.keys() |
| 201 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 202 | def get_ffdc_method_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 203 | r""" |
| 204 | ######################################################################## |
| 205 | # @brief This method returns the key pair from the dictionary |
| 206 | # @return Index of the method dictionary |
| 207 | ######################################################################## |
| 208 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 209 | return FFDC_METHOD_CALL.keys() |
| 210 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 211 | 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 Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 218 | return FFDC_METHOD_CALL[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 219 | |
Gunnar Mills | 7e2cda2 | 2016-10-11 15:37:34 -0500 | [diff] [blame] | 220 | 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 Mills | cce185d | 2016-10-17 17:04:15 -0500 | [diff] [blame] | 238 | 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 Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 258 | def get_strip_string(self, i_str): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 259 | 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 Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 266 | return ''.join(e for e in i_str if e.isalnum()) |