1#!/usr/bin/python 2r""" 3# @file openbmc_ffdc_list.py 4# @brief List for FFDC ( First failure data capture ) 5# commands and files to be collected as a part 6# of the test case failure. 7""" 8# ------------------- 9# FFDC default list 10# ------------------- 11# ----------------------------------------------------------------- 12# Dict Name { Index string : { Key String : Command string} } 13# ----------------------------------------------------------------- 14# Add cmd's needed to be part of the ffdc report manifest file 15FFDC_BMC_CMD = { 16 'DRIVER INFO': 17 { 18 # String Name Command 19 'FW Level': 'cat /etc/os-release', 20 'FW Timestamp': 'cat /etc/timestamp', 21 }, 22 'BMC DATA': 23 { 24 'BMC OS': 'uname -a', 25 'BMC Uptime': 'uptime', 26 'BMC File System Disk Space Usage': 'df -hT', 27 'BMC Date Time': 'date;/sbin/hwclock --show;/usr/bin/timedatectl' 28 }, 29 'APPLICATION DATA': 30 { 31 'BMC state': '/usr/sbin/obmcutil state', 32 }, 33} 34# Add file name and correcponding command needed for BMC 35FFDC_BMC_FILE = { 36 'BMC FILES': 37 { 38 # File Name Command 39 'BMC_proc_list': 'top -n 1 -b', 40 'BMC_proc_fd_active_list': 'ls -Al /proc/*/fd/', 41 'BMC_journalctl_nopager': 'journalctl --no-pager', 42 'BMC_journalctl_pretty': 'journalctl -o json-pretty', 43 'BMC_dmesg': 'dmesg', 44 'BMC_procinfo': 'cat /proc/cpuinfo', 45 'BMC_meminfo': 'cat /proc/meminfo', 46 'BMC_systemd': 'systemctl status --all', 47 'SOL': 'cat /var/log/obmc-console.log', 48 }, 49} 50# Add file name and correcponding command needed for all Linux distributions 51FFDC_OS_ALL_DISTROS_FILE = { 52 'OS FILES': 53 { 54 # File Name Command 55 'OS_msglog': 'cat /sys/firmware/opal/msglog', 56 'OS_cpufrequency': 'ppc64_cpu --frequency', 57 'OS_dmesg': 'dmesg', 58 'OS_opal_prd': 'cat /var/log/opal-prd*', 59 'OS_boot': 'cat /var/log/boot.log', 60 'OS_procinfo': 'cat /proc/cpuinfo', 61 'OS_meminfo': 'cat /proc/meminfo', 62 'OS_netstat': 'netstat -a', 63 'OS_lspci': 'lspci', 64 'OS_lscpu': 'lscpu', 65 'OS_lscfg': 'lscfg', 66 }, 67} 68# Add file name and correcponding command needed for Ubuntu Linux 69FFDC_OS_UBUNTU_FILE = { 70 'OS FILES': 71 { 72 # File Name Command 73 'OS_isusb': 'lsusb -t ; lsusb -v', 74 'OS_kern': 'tail -n 50000 /var/log/kern.log', 75 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1', 76 'OS_syslog': 'tail -n 200000 /var/log/syslog', 77 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool', 78 }, 79} 80# Add file name and correcponding command needed for RHEL Linux 81FFDC_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# Add file name and correcponding command needed for RHEL Linux 92FFDC_OS_IBM_POWERKVM_FILE = { 93 'OS FILES': 94 { 95 # File Name Command 96 'OS_secure': 'cat /var/log/secure', 97 'OS_syslog': 'tail -n 200000 /var/log/messages', 98 'OS_info': 'lsb_release -a; uname -a; rpm -qa', 99 }, 100} 101OPENBMC_BASE = '/xyz/openbmc_project/' 102OPENPOWER_BASE = '/org/open_power/' 103ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' 104ENUMERATE_INVENTORY = OPENBMC_BASE + 'inventory/enumerate' 105ENUMERATE_ELOG = OPENBMC_BASE + 'logging/entry/enumerate' 106ENUMERATE_LED = OPENBMC_BASE + 'led/enumerate' 107ENUMERATE_SW = OPENBMC_BASE + 'software/enumerate' 108ENUMERATE_CONTROL = OPENBMC_BASE + 'control/enumerate' 109ENUMERATE_STATE = OPENBMC_BASE + 'state/enumerate' 110ENUMERATE_OCC = OPENPOWER_BASE + 'control/enumerate' 111ENUMERATE_DUMPS = OPENBMC_BASE + 'dumps/enumerate' 112ENUMERATE_USER = OPENBMC_BASE + 'user/enumerate' 113 114# Add file name and correcponding Get Request 115FFDC_GET_REQUEST = { 116 'GET REQUESTS': 117 { 118 # File Name Command 119 'FIRMWARE_list': ENUMERATE_SW, 120 'BMC_sensor_list': ENUMERATE_SENSORS, 121 'BMC_control_list': ENUMERATE_CONTROL, 122 'BMC_inventory': ENUMERATE_INVENTORY, 123 'BMC_elog': ENUMERATE_ELOG, 124 'BMC_led': ENUMERATE_LED, 125 'BMC_state': ENUMERATE_STATE, 126 'OCC_state': ENUMERATE_OCC, 127 'BMC_dumps': ENUMERATE_DUMPS, 128 'BMC_USER': ENUMERATE_USER, 129 }, 130} 131# Define your keywords in method/utils and call here 132FFDC_METHOD_CALL = { 133 'BMC LOGS': 134 { 135 # Description Keyword name 136 'FFDC Generic Report': 'BMC FFDC Manifest', 137 'BMC Specific Files': 'BMC FFDC Files', 138 'Get Request FFDC': 'BMC FFDC Get Requests', 139 'OS FFDC': 'OS FFDC Files', 140 'Core Files': 'SCP Coredump Files', 141 'SEL Log': 'Collect eSEL Log', 142 'Sys Inventory Files': 'System Inventory Files', 143 'Dump Log': 'Collect Dump Log', 144 'Dump Files': 'SCP Dump Files', 145 'Redfish Log': 'Enumerate Redfish Resources', 146 }, 147} 148# ----------------------------------------------------------------- 149# base class for FFDC default list 150 151 152class openbmc_ffdc_list(): 153 def get_ffdc_bmc_cmd(self, i_type): 154 r""" 155 ####################################################################### 156 # @brief This method returns the list from the dictionary for cmds 157 # @param i_type: @type string: string index lookup 158 # @return List of key pair from the dictionary 159 ####################################################################### 160 """ 161 return FFDC_BMC_CMD[i_type].items() 162 163 def get_ffdc_bmc_file(self, i_type): 164 r""" 165 ####################################################################### 166 # @brief This method returns the list from the dictionary for scp 167 # @param i_type: @type string: string index lookup 168 # @return List of key pair from the dictionary 169 ####################################################################### 170 """ 171 return FFDC_BMC_FILE[i_type].items() 172 173 def get_ffdc_get_request(self, i_type): 174 r""" 175 ####################################################################### 176 # @brief This method returns the list from the dictionary for scp 177 # @param i_type: @type string: string index lookup 178 # @return List of key pair from the dictionary 179 ####################################################################### 180 """ 181 return FFDC_GET_REQUEST[i_type].items() 182 183 def get_ffdc_cmd_index(self): 184 r""" 185 ####################################################################### 186 # @brief This method returns the list index from dictionary 187 # @return List of index to the dictionary 188 ####################################################################### 189 """ 190 return FFDC_BMC_CMD.keys() 191 192 def get_ffdc_get_request_index(self): 193 r""" 194 ####################################################################### 195 # @brief This method returns the list index from dictionary 196 # @return List of index to the dictionary 197 ####################################################################### 198 """ 199 return FFDC_GET_REQUEST.keys() 200 201 def get_ffdc_file_index(self): 202 r""" 203 ####################################################################### 204 # @brief This method returns the list index from dictionary 205 # @return List of index to the dictionary 206 ####################################################################### 207 """ 208 return FFDC_BMC_FILE.keys() 209 210 def get_ffdc_method_index(self): 211 r""" 212 ####################################################################### 213 # @brief This method returns the key pair from the dictionary 214 # @return Index of the method dictionary 215 ####################################################################### 216 """ 217 return FFDC_METHOD_CALL.keys() 218 219 def get_ffdc_method_desc(self, 220 index): 221 r""" 222 ####################################################################### 223 # @brief This method returns the just the keys from the dictionary. 224 # @return List of ffdc descriptions. 225 ####################################################################### 226 """ 227 return FFDC_METHOD_CALL[index].keys() 228 229 def get_ffdc_method_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_METHOD_CALL[i_type].items() 237 238 def get_ffdc_os_all_distros_index(self): 239 r""" 240 ####################################################################### 241 # @brief This method returns the key pair from the dictionary 242 # @return Index of the method dictionary 243 ####################################################################### 244 """ 245 return FFDC_OS_ALL_DISTROS_FILE.keys() 246 247 def get_ffdc_os_all_distros_call(self, i_type): 248 r""" 249 ####################################################################### 250 # @brief This method returns the key pair from the dictionary 251 # @return List of key pair keywords 252 ####################################################################### 253 """ 254 return FFDC_OS_ALL_DISTROS_FILE[i_type].items() 255 256 def get_ffdc_os_distro_index(self, distro): 257 r""" 258 ####################################################################### 259 # @brief This method returns the key pair from the dictionary 260 # @return Index of the method dictionary 261 ####################################################################### 262 """ 263 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 264 return eval(distro_file).keys() 265 266 def get_ffdc_os_distro_call(self, i_type, distro): 267 r""" 268 ####################################################################### 269 # @brief This method returns the key pair from the dictionary 270 # @return List of key pair keywords 271 ####################################################################### 272 """ 273 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 274 return eval(distro_file)[i_type].items() 275 276 def get_strip_string(self, i_str): 277 r""" 278 ####################################################################### 279 # @brief Returns the stripped strings 280 # @param i_str: @type string: string name 281 # @return Remove all special chars and return the string 282 ####################################################################### 283 """ 284 return ''.join(e for e in i_str if e.isalnum()) 285 286 def get_esel_index(self, esel_list): 287 r""" 288 ####################################################################### 289 # @brief Returns the eSEL binary index. 290 # @param esel_ist: @type list: eSEL list. 291 # @return Index of "ESEL=" in the list. 292 ####################################################################### 293 """ 294 index = [i for i, str in enumerate(esel_list) if 'ESEL=' in str] 295 return index[0] 296 297 def get_dump_index(self, dump_list): 298 r""" 299 ####################################################################### 300 # @brief Returns the eSEL binary index. 301 # @param esel_ist: @type list: eSEL list. 302 # @return Index of "ESEL=" in the list. 303 ####################################################################### 304 """ 305 index = [i for i, str in enumerate(dump_list) if 'DUMP=' in str] 306 return index[0] 307