1#!/usr/bin/python 2r""" 3############################################################# 4# @file openbmc_ffdc_list.py 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############################################################# 10""" 11 12# ------------------- 13# FFDC default list 14# ------------------- 15 16# ----------------------------------------------------------------- 17# Dict Name { Index string : { Key String : Comand string} } 18# ----------------------------------------------------------------- 19# Add cmd's needed to be part of the ffdc report manifest file 20FFDC_BMC_CMD = { 21 'DRIVER INFO': 22 { 23 # String Name Command 24 'FW Level': 'cat /etc/os-release', 25 }, 26 'BMC DATA': 27 { 28 'BMC OS': 'uname -a', 29 'BMC Uptime': 'uptime', 30 'BMC File System Disk Space Usage': 'df -hT', 31 }, 32 'APPLICATION DATA': 33 { 34 'BMC state': '/usr/sbin/obmcutil state', 35 }, 36} 37 38# Add file name and correcponding command needed for BMC 39FFDC_BMC_FILE = { 40 'BMC FILES': 41 { 42 # File Name Command 43 'BMC_proc_list': 'top -n 1 -b', 44 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/', 45 'BMC_journalctl': 'journalctl --no-pager', 46 'BMC_dmesg': 'dmesg', 47 'BMC_procinfo': 'cat /proc/cpuinfo', 48 'BMC_meminfo': 'cat /proc/meminfo', 49 }, 50} 51 52# Add file name and correcponding command needed for all Linux distributions 53FFDC_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', 61 'OS_procinfo': 'cat /proc/cpuinfo', 62 'OS_meminfo': 'cat /proc/meminfo', 63 'OS_netstat': 'netstat -a', 64 'OS_lspci': 'lspci', 65 'OS_lscpu': 'lscpu', 66 'OS_lscfg': 'lscfg', 67 }, 68} 69 70# Add file name and correcponding command needed for Ubuntu Linux 71FFDC_OS_UBUNTU_FILE = { 72 'OS FILES': 73 { 74 # File Name Command 75 'OS_isusb': 'lsusb -t ; lsusb -v', 76 'OS_kern': 'tail -n 50000 /var/log/kern.log', 77 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1', 78 'OS_syslog': 'tail -n 200000 /var/log/syslog', 79 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool', 80 }, 81} 82 83# Add file name and correcponding command needed for RHEL Linux 84FFDC_OS_RHEL_FILE = { 85 'OS FILES': 86 { 87 # File Name Command 88 'OS_rsct': '/usr/bin/ctversion -bv', 89 'OS_secure': 'cat /var/log/secure', 90 'OS_syslog': 'tail -n 200000 /var/log/messages', 91 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa', 92 }, 93} 94 95# Add file name and correcponding command needed for RHEL Linux 96FFDC_OS_IBM_POWERKVM_FILE = { 97 'OS FILES': 98 { 99 # File Name Command 100 'OS_secure': 'cat /var/log/secure', 101 'OS_syslog': 'tail -n 200000 /var/log/messages', 102 'OS_info': 'lsb_release -a; uname -a; rpm -qa', 103 }, 104} 105 106# Enable when ready with openbmc/openbmc-test-automation#203 107# replace with new path /xyz/openbmc_project 108OPENBMC_BASE = '/org/openbmc/' 109ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' 110# TODO: Use the xyz enums once moved to xyz completely 111# ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/enumerate' 112ENUMERATE_SYSTEMS = '/xyz/openbmc_project/inventory/enumerate' 113ENUMERATE_ELOG = '/xyz/openbmc_project/logging/entry/enumerate' 114ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate' 115ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate' 116 117# Sensors/control data. 118ENUMERATE_SENSOR = '/xyz/openbmc_project/sensors/enumerate' 119ENUMERATE_CONTROL = '/xyz/openbmc_project/control/enumerate' 120 121# Add file name and correcponding Get Request 122FFDC_GET_REQUEST = { 123 'GET REQUESTS': 124 { 125 # File Name Command 126 'BMC_sensor_list': ENUMERATE_SENSORS, 127 'BMC_sensor_xyz_list': ENUMERATE_SENSOR, 128 'BMC_control_list': ENUMERATE_CONTROL, 129 'BMC_inventory': ENUMERATE_SYSTEMS, 130 'BMC_elog': ENUMERATE_ELOG, 131 'BMC_led': ENUMERATE_EVENTS, 132 'BMC_record_log': ENUMERATE_LED, 133 }, 134} 135 136 137# Define your keywords in method/utils and call here 138FFDC_METHOD_CALL = { 139 'BMC LOGS': 140 { 141 # Description Keyword name 142 'FFDC Generic Report': 'BMC FFDC Manifest', 143 'BMC Specific Files': 'BMC FFDC Files', 144 'Get Request FFDC': 'BMC FFDC Get Requests', 145 'OS FFDC': 'OS FFDC Files', 146 'Core Files': 'SCP Coredump Files', 147 'SEL Log': 'Collect eSEL Log', 148 }, 149} 150 151# ----------------------------------------------------------------- 152 153 154# base class for FFDC default list 155class openbmc_ffdc_list(): 156 157 def get_ffdc_bmc_cmd(self, i_type): 158 r""" 159 ######################################################################## 160 # @brief This method returns the list from the dictionary for cmds 161 # @param i_type: @type string: string index lookup 162 # @return List of key pair from the dictionary 163 ######################################################################## 164 """ 165 return FFDC_BMC_CMD[i_type].items() 166 167 def get_ffdc_bmc_file(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_BMC_FILE[i_type].items() 176 177 def get_ffdc_get_request(self, i_type): 178 r""" 179 ######################################################################## 180 # @brief This method returns the list from the dictionary for scp 181 # @param i_type: @type string: string index lookup 182 # @return List of key pair from the dictionary 183 ######################################################################## 184 """ 185 return FFDC_GET_REQUEST[i_type].items() 186 187 def get_ffdc_cmd_index(self): 188 r""" 189 ######################################################################## 190 # @brief This method returns the list index from dictionary 191 # @return List of index to the dictionary 192 ######################################################################## 193 """ 194 return FFDC_BMC_CMD.keys() 195 196 def get_ffdc_get_request_index(self): 197 r""" 198 ######################################################################## 199 # @brief This method returns the list index from dictionary 200 # @return List of index to the dictionary 201 ######################################################################## 202 """ 203 return FFDC_GET_REQUEST.keys() 204 205 def get_ffdc_file_index(self): 206 r""" 207 ######################################################################## 208 # @brief This method returns the list index from dictionary 209 # @return List of index to the dictionary 210 ######################################################################## 211 """ 212 return FFDC_BMC_FILE.keys() 213 214 def get_ffdc_method_index(self): 215 r""" 216 ######################################################################## 217 # @brief This method returns the key pair from the dictionary 218 # @return Index of the method dictionary 219 ######################################################################## 220 """ 221 return FFDC_METHOD_CALL.keys() 222 223 def get_ffdc_method_desc(self, 224 index): 225 r""" 226 ######################################################################## 227 # @brief This method returns the just the keys from the dictionary. 228 # @return List of ffdc descriptions. 229 ######################################################################## 230 """ 231 return FFDC_METHOD_CALL[index].keys() 232 233 def get_ffdc_method_call(self, i_type): 234 r""" 235 ######################################################################## 236 # @brief This method returns the key pair from the dictionary 237 # @return List of key pair keywords 238 ######################################################################## 239 """ 240 return FFDC_METHOD_CALL[i_type].items() 241 242 def get_ffdc_os_all_distros_index(self): 243 r""" 244 ######################################################################## 245 # @brief This method returns the key pair from the dictionary 246 # @return Index of the method dictionary 247 ######################################################################## 248 """ 249 return FFDC_OS_ALL_DISTROS_FILE.keys() 250 251 def get_ffdc_os_all_distros_call(self, i_type): 252 r""" 253 ######################################################################## 254 # @brief This method returns the key pair from the dictionary 255 # @return List of key pair keywords 256 ######################################################################## 257 """ 258 return FFDC_OS_ALL_DISTROS_FILE[i_type].items() 259 260 def get_ffdc_os_distro_index(self, distro): 261 r""" 262 ######################################################################## 263 # @brief This method returns the key pair from the dictionary 264 # @return Index of the method dictionary 265 ######################################################################## 266 """ 267 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 268 return eval(distro_file).keys() 269 270 def get_ffdc_os_distro_call(self, i_type, distro): 271 r""" 272 ######################################################################## 273 # @brief This method returns the key pair from the dictionary 274 # @return List of key pair keywords 275 ######################################################################## 276 """ 277 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 278 return eval(distro_file)[i_type].items() 279 280 def get_strip_string(self, i_str): 281 r""" 282 ######################################################################## 283 # @brief Returns the stripped strings 284 # @param i_str: @type string: string name 285 # @return Remove all special chars and return the string 286 ######################################################################## 287 """ 288 return ''.join(e for e in i_str if e.isalnum()) 289 290 def get_esel_index(self, esel_list): 291 r""" 292 ####################################################################### 293 # @brief Returns the eSEL binary index. 294 # @param esel_ist: @type list: eSEL list. 295 # @return Index of "ESEL=" in the list. 296 ####################################################################### 297 """ 298 index = [i for i, str in enumerate(esel_list) if 'ESEL=' in str] 299 return index[0] 300