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 12from robot.libraries.BuiltIn import BuiltIn 13 14# ------------------- 15# FFDC default list 16# ------------------- 17 18# ----------------------------------------------------------------- 19# Dict Name { Index string : { Key String : Comand string} } 20# ----------------------------------------------------------------- 21# Add cmd's needed to be part of the ffdc report manifest file 22FFDC_BMC_CMD = { 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', 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': 'journalctl --no-pager', 48 'BMC_dmesg': 'dmesg', 49 'BMC_procinfo': 'cat /proc/cpuinfo', 50 'BMC_meminfo': 'cat /proc/meminfo', 51 }, 52} 53 54# Add file name and correcponding command needed for all Linux distributions 55FFDC_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', 63 'OS_procinfo': 'cat /proc/cpuinfo', 64 'OS_meminfo': 'cat /proc/meminfo', 65 'OS_netstat': 'netstat -a', 66 }, 67} 68 69# Add file name and correcponding command needed for Ubuntu Linux 70FFDC_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 83FFDC_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 95FFDC_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 105# import variables from resource.txt file 106BuiltIn().import_resource('resource.txt') 107OPENBMC_BASE = BuiltIn().get_variable_value('${OPENBMC_BASE_URI}') 108 109ENUMERATE_SENSORS = OPENBMC_BASE + 'sensors/enumerate' 110ENUMERATE_SYSTEMS = OPENBMC_BASE + 'inventory/system/enumerate' 111ENUMERATE_EVENTS = OPENBMC_BASE + 'records/events/enumerate' 112ENUMERATE_LED = OPENBMC_BASE + 'control/led/enumerate' 113 114# Add file name and correcponding Get Request 115FFDC_GET_REQUEST = { 116 'GET REQUESTS': 117 { 118 # File Name Command 119 'BMC_sensor_list': ENUMERATE_SENSORS, 120 'BMC_inventory': ENUMERATE_SYSTEMS, 121 'BMC_led': ENUMERATE_EVENTS, 122 'BMC_record_log': ENUMERATE_LED, 123 }, 124} 125 126 127# Define your keywords in method/utils and call here 128FFDC_METHOD_CALL = { 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', 135 'OS FFDC': 'OS FFDC Files', 136 }, 137} 138 139# ----------------------------------------------------------------- 140 141 142# base class for FFDC default list 143class openbmc_ffdc_list(): 144 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 """ 153 return FFDC_BMC_CMD[i_type].items() 154 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 """ 163 return FFDC_BMC_FILE[i_type].items() 164 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 175 def get_ffdc_cmd_index(self): 176 r""" 177 ######################################################################## 178 # @brief This method returns the list index from dictionary 179 # @return List of index to the dictionary 180 ######################################################################## 181 """ 182 return FFDC_BMC_CMD.keys() 183 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 193 def get_ffdc_file_index(self): 194 r""" 195 ######################################################################## 196 # @brief This method returns the list index from dictionary 197 # @return List of index to the dictionary 198 ######################################################################## 199 """ 200 return FFDC_BMC_FILE.keys() 201 202 def get_ffdc_method_index(self): 203 r""" 204 ######################################################################## 205 # @brief This method returns the key pair from the dictionary 206 # @return Index of the method dictionary 207 ######################################################################## 208 """ 209 return FFDC_METHOD_CALL.keys() 210 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 """ 218 return FFDC_METHOD_CALL[i_type].items() 219 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 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 258 def get_strip_string(self, i_str): 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 """ 266 return ''.join(e for e in i_str if e.isalnum()) 267