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 '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', 31 'BMC Proc Info': 'cat /proc/cpuinfo', 32 'BMC Mem Info': 'cat /proc/meminfo', 33 'BMC File System Disk Space Usage': 'df -hT', 34 }, 35 'APPLICATION DATA': 36 { 37 'BMC state': '/usr/sbin/obmcutil state', 38 }, 39} 40 41# Add file name and correcponding command needed for BMC 42FFDC_BMC_FILE = { 43 'BMC FILES': 44 { 45 # File Name Command 46 'BMC_proc_list': 'top -n 1 -b', 47 'BMC_journalctl.log': 'journalctl --no-pager', 48 'BMC_dmesg': 'dmesg', 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 }, 62} 63 64# Add file name and correcponding command needed for Ubuntu Linux 65FFDC_OS_UBUNTU_FILE = { 66 'OS FILES': 67 { 68 # File Name Command 69 'OS_isusb': 'lsusb -t ; lsusb -v', 70 'OS_kern': 'tail -n 50000 /var/log/kern.log', 71 'OS_authlog': 'cat /var/log/auth.log; cat /var/log/auth.log.1', 72 'OS_syslog': 'tail -n 200000 /var/log/syslog', 73 'OS_info': 'uname -a; dpkg -s opal-prd; dpkg -s ipmitool', 74 }, 75} 76 77# Add file name and correcponding command needed for RHEL Linux 78FFDC_OS_RHEL_FILE = { 79 'OS FILES': 80 { 81 # File Name Command 82 'OS_rsct': '/usr/bin/ctversion -bv', 83 'OS_secure': 'cat /var/log/secure', 84 'OS_syslog': 'tail -n 200000 /var/log/messages', 85 'OS_info': 'lsb_release -a; cat /etc/redhat-release; uname -a; rpm -qa', 86 }, 87} 88 89# Add file name and correcponding command needed for RHEL Linux 90FFDC_OS_IBM_POWERKVM_FILE = { 91 'OS FILES': 92 { 93 # File Name Command 94 'OS_secure': 'cat /var/log/secure', 95 'OS_syslog': 'tail -n 200000 /var/log/messages', 96 'OS_info': 'lsb_release -a; uname -a; rpm -qa', 97 }, 98} 99 100# Add file name and correcponding Get Request 101FFDC_GET_REQUEST = { 102 'GET REQUESTS': 103 { 104 # File Name Command 105 'BMC_sensor_list': '/org/openbmc/sensors/enumerate', 106 'BMC_inventory': '/org/openbmc/inventory/system/enumerate', 107 'BMC_led': '/org/openbmc/control/led/enumerate', 108 'BMC_record_log': '/org/openbmc/records/events/enumerate', 109 }, 110} 111 112 113# Define your keywords in method/utils and call here 114FFDC_METHOD_CALL = { 115 'BMC LOGS': 116 { 117 # Description Keyword name 118 'FFDC Generic Report': 'BMC FFDC Manifest', 119 'BMC Specific Files': 'BMC FFDC Files', 120 'Get Request FFDC': 'BMC FFDC Get Requests', 121 'OS FFDC': 'OS FFDC Files', 122 }, 123} 124 125# ----------------------------------------------------------------- 126 127 128# base class for FFDC default list 129class openbmc_ffdc_list(): 130 131 def get_ffdc_bmc_cmd(self, i_type): 132 r""" 133 ######################################################################## 134 # @brief This method returns the list from the dictionary for cmds 135 # @param i_type: @type string: string index lookup 136 # @return List of key pair from the dictionary 137 ######################################################################## 138 """ 139 return FFDC_BMC_CMD[i_type].items() 140 141 def get_ffdc_bmc_file(self, i_type): 142 r""" 143 ######################################################################## 144 # @brief This method returns the list from the dictionary for scp 145 # @param i_type: @type string: string index lookup 146 # @return List of key pair from the dictionary 147 ######################################################################## 148 """ 149 return FFDC_BMC_FILE[i_type].items() 150 151 def get_ffdc_get_request(self, i_type): 152 r""" 153 ######################################################################## 154 # @brief This method returns the list from the dictionary for scp 155 # @param i_type: @type string: string index lookup 156 # @return List of key pair from the dictionary 157 ######################################################################## 158 """ 159 return FFDC_GET_REQUEST[i_type].items() 160 161 def get_ffdc_cmd_index(self): 162 r""" 163 ######################################################################## 164 # @brief This method returns the list index from dictionary 165 # @return List of index to the dictionary 166 ######################################################################## 167 """ 168 return FFDC_BMC_CMD.keys() 169 170 def get_ffdc_get_request_index(self): 171 r""" 172 ######################################################################## 173 # @brief This method returns the list index from dictionary 174 # @return List of index to the dictionary 175 ######################################################################## 176 """ 177 return FFDC_GET_REQUEST.keys() 178 179 def get_ffdc_file_index(self): 180 r""" 181 ######################################################################## 182 # @brief This method returns the list index from dictionary 183 # @return List of index to the dictionary 184 ######################################################################## 185 """ 186 return FFDC_BMC_FILE.keys() 187 188 def get_ffdc_method_index(self): 189 r""" 190 ######################################################################## 191 # @brief This method returns the key pair from the dictionary 192 # @return Index of the method dictionary 193 ######################################################################## 194 """ 195 return FFDC_METHOD_CALL.keys() 196 197 def get_ffdc_method_call(self, i_type): 198 r""" 199 ######################################################################## 200 # @brief This method returns the key pair from the dictionary 201 # @return List of key pair keywords 202 ######################################################################## 203 """ 204 return FFDC_METHOD_CALL[i_type].items() 205 206 def get_ffdc_os_all_distros_index(self): 207 r""" 208 ######################################################################## 209 # @brief This method returns the key pair from the dictionary 210 # @return Index of the method dictionary 211 ######################################################################## 212 """ 213 return FFDC_OS_ALL_DISTROS_FILE.keys() 214 215 def get_ffdc_os_all_distros_call(self, i_type): 216 r""" 217 ######################################################################## 218 # @brief This method returns the key pair from the dictionary 219 # @return List of key pair keywords 220 ######################################################################## 221 """ 222 return FFDC_OS_ALL_DISTROS_FILE[i_type].items() 223 224 def get_ffdc_os_distro_index(self, distro): 225 r""" 226 ######################################################################## 227 # @brief This method returns the key pair from the dictionary 228 # @return Index of the method dictionary 229 ######################################################################## 230 """ 231 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 232 return eval(distro_file).keys() 233 234 def get_ffdc_os_distro_call(self, i_type, distro): 235 r""" 236 ######################################################################## 237 # @brief This method returns the key pair from the dictionary 238 # @return List of key pair keywords 239 ######################################################################## 240 """ 241 distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE" 242 return eval(distro_file)[i_type].items() 243 244 def get_strip_string(self, i_str): 245 r""" 246 ######################################################################## 247 # @brief Returns the stripped strings 248 # @param i_str: @type string: string name 249 # @return Remove all special chars and return the string 250 ######################################################################## 251 """ 252 return ''.join(e for e in i_str if e.isalnum()) 253