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 Get Request 65FFDC_GET_REQUEST = { 66 'GET REQUESTS': 67 { 68 # File Name Command 69 'BMC_sensor_list': '/org/openbmc/sensors/enumerate', 70 'BMC_inventory': '/org/openbmc/inventory/system/enumerate', 71 'BMC_led': '/org/openbmc/control/led/enumerate', 72 'BMC_record_log': '/org/openbmc/records/events/enumerate', 73 }, 74} 75 76 77# Define your keywords in method/utils and call here 78FFDC_METHOD_CALL = { 79 'BMC LOGS': 80 { 81 # Description Keyword name 82 'FFDC Generic Report': 'BMC FFDC Manifest', 83 'BMC Specific Files': 'BMC FFDC Files', 84 'Get Request FFDC': 'BMC FFDC Get Requests', 85 'OS FFDC': 'OS FFDC Files', 86 }, 87} 88 89# ----------------------------------------------------------------- 90 91 92# base class for FFDC default list 93class openbmc_ffdc_list(): 94 95 def get_ffdc_bmc_cmd(self, i_type): 96 r""" 97 ######################################################################## 98 # @brief This method returns the list from the dictionary for cmds 99 # @param i_type: @type string: string index lookup 100 # @return List of key pair from the dictionary 101 ######################################################################## 102 """ 103 return FFDC_BMC_CMD[i_type].items() 104 105 def get_ffdc_bmc_file(self, i_type): 106 r""" 107 ######################################################################## 108 # @brief This method returns the list from the dictionary for scp 109 # @param i_type: @type string: string index lookup 110 # @return List of key pair from the dictionary 111 ######################################################################## 112 """ 113 return FFDC_BMC_FILE[i_type].items() 114 115 def get_ffdc_get_request(self, i_type): 116 r""" 117 ######################################################################## 118 # @brief This method returns the list from the dictionary for scp 119 # @param i_type: @type string: string index lookup 120 # @return List of key pair from the dictionary 121 ######################################################################## 122 """ 123 return FFDC_GET_REQUEST[i_type].items() 124 125 def get_ffdc_cmd_index(self): 126 r""" 127 ######################################################################## 128 # @brief This method returns the list index from dictionary 129 # @return List of index to the dictionary 130 ######################################################################## 131 """ 132 return FFDC_BMC_CMD.keys() 133 134 def get_ffdc_get_request_index(self): 135 r""" 136 ######################################################################## 137 # @brief This method returns the list index from dictionary 138 # @return List of index to the dictionary 139 ######################################################################## 140 """ 141 return FFDC_GET_REQUEST.keys() 142 143 def get_ffdc_file_index(self): 144 r""" 145 ######################################################################## 146 # @brief This method returns the list index from dictionary 147 # @return List of index to the dictionary 148 ######################################################################## 149 """ 150 return FFDC_BMC_FILE.keys() 151 152 def get_ffdc_method_index(self): 153 r""" 154 ######################################################################## 155 # @brief This method returns the key pair from the dictionary 156 # @return Index of the method dictionary 157 ######################################################################## 158 """ 159 return FFDC_METHOD_CALL.keys() 160 161 def get_ffdc_method_call(self, i_type): 162 r""" 163 ######################################################################## 164 # @brief This method returns the key pair from the dictionary 165 # @return List of key pair keywords 166 ######################################################################## 167 """ 168 return FFDC_METHOD_CALL[i_type].items() 169 170 def get_ffdc_os_all_distros_index(self): 171 r""" 172 ######################################################################## 173 # @brief This method returns the key pair from the dictionary 174 # @return Index of the method dictionary 175 ######################################################################## 176 """ 177 return FFDC_OS_ALL_DISTROS_FILE.keys() 178 179 def get_ffdc_os_all_distros_call(self, i_type): 180 r""" 181 ######################################################################## 182 # @brief This method returns the key pair from the dictionary 183 # @return List of key pair keywords 184 ######################################################################## 185 """ 186 return FFDC_OS_ALL_DISTROS_FILE[i_type].items() 187 188 def get_strip_string(self, i_str): 189 r""" 190 ######################################################################## 191 # @brief Returns the stripped strings 192 # @param i_str: @type string: string name 193 # @return Remove all special chars and return the string 194 ######################################################################## 195 """ 196 return ''.join(e for e in i_str if e.isalnum()) 197