George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 2 | r""" |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 3 | ############################################################# |
| 4 | # @file openbmc_ffdc_list.py |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 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 | ############################################################# |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 10 | """ |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 11 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 12 | # ------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 13 | # FFDC default list |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 14 | # ------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 15 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------- |
| 17 | # Dict Name { Index string : { Key String : Comand string} } |
| 18 | # ----------------------------------------------------------------- |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 19 | # Add cmd's needed to be part of the ffdc report manifest file |
| 20 | FFDC_BMC_CMD = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 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 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 40 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 41 | # Add file name and correcponding command needed for BMC |
| 42 | FFDC_BMC_FILE = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 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 Get Request |
| 53 | FFDC_GET_REQUEST = { |
| 54 | 'GET REQUESTS': |
| 55 | { |
| 56 | # File Name Command |
| 57 | 'BMC_sensor_list': '/org/openbmc/sensors/enumerate', |
| 58 | 'BMC_inventory': '/org/openbmc/inventory/system/enumerate', |
| 59 | 'BMC_led': '/org/openbmc/control/led/enumerate', |
| 60 | 'BMC_record_log': '/org/openbmc/records/events/enumerate', |
| 61 | }, |
| 62 | } |
| 63 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 64 | |
| 65 | # Define your keywords in method/utils and call here |
| 66 | FFDC_METHOD_CALL = { |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 67 | 'BMC LOGS': |
| 68 | { |
| 69 | # Description Keyword name |
| 70 | 'FFDC Generic Report': 'BMC FFDC Manifest', |
| 71 | 'BMC Specific Files': 'BMC FFDC Files', |
| 72 | 'Get Request FFDC': 'BMC FFDC Get Requests', |
| 73 | }, |
| 74 | } |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 75 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 76 | # ----------------------------------------------------------------- |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 77 | |
| 78 | |
| 79 | # base class for FFDC default list |
| 80 | class openbmc_ffdc_list(): |
| 81 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 82 | def get_ffdc_bmc_cmd(self, i_type): |
| 83 | r""" |
| 84 | ######################################################################## |
| 85 | # @brief This method returns the list from the dictionary for cmds |
| 86 | # @param i_type: @type string: string index lookup |
| 87 | # @return List of key pair from the dictionary |
| 88 | ######################################################################## |
| 89 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 90 | return FFDC_BMC_CMD[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 91 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 92 | def get_ffdc_bmc_file(self, i_type): |
| 93 | r""" |
| 94 | ######################################################################## |
| 95 | # @brief This method returns the list from the dictionary for scp |
| 96 | # @param i_type: @type string: string index lookup |
| 97 | # @return List of key pair from the dictionary |
| 98 | ######################################################################## |
| 99 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 100 | return FFDC_BMC_FILE[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 101 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 102 | def get_ffdc_get_request(self, i_type): |
| 103 | r""" |
| 104 | ######################################################################## |
| 105 | # @brief This method returns the list from the dictionary for scp |
| 106 | # @param i_type: @type string: string index lookup |
| 107 | # @return List of key pair from the dictionary |
| 108 | ######################################################################## |
| 109 | """ |
| 110 | return FFDC_GET_REQUEST[i_type].items() |
| 111 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 112 | def get_ffdc_cmd_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 113 | r""" |
| 114 | ######################################################################## |
| 115 | # @brief This method returns the list index from dictionary |
| 116 | # @return List of index to the dictionary |
| 117 | ######################################################################## |
| 118 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 119 | return FFDC_BMC_CMD.keys() |
| 120 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 121 | def get_ffdc_get_request_index(self): |
| 122 | r""" |
| 123 | ######################################################################## |
| 124 | # @brief This method returns the list index from dictionary |
| 125 | # @return List of index to the dictionary |
| 126 | ######################################################################## |
| 127 | """ |
| 128 | return FFDC_GET_REQUEST.keys() |
| 129 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 130 | def get_ffdc_file_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 131 | r""" |
| 132 | ######################################################################## |
| 133 | # @brief This method returns the list index from dictionary |
| 134 | # @return List of index to the dictionary |
| 135 | ######################################################################## |
| 136 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 137 | return FFDC_BMC_FILE.keys() |
| 138 | |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 139 | def get_ffdc_method_index(self): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 140 | r""" |
| 141 | ######################################################################## |
| 142 | # @brief This method returns the key pair from the dictionary |
| 143 | # @return Index of the method dictionary |
| 144 | ######################################################################## |
| 145 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 146 | return FFDC_METHOD_CALL.keys() |
| 147 | |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 148 | def get_ffdc_method_call(self, i_type): |
| 149 | r""" |
| 150 | ######################################################################## |
| 151 | # @brief This method returns the key pair from the dictionary |
| 152 | # @return List of key pair keywords |
| 153 | ######################################################################## |
| 154 | """ |
George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 155 | return FFDC_METHOD_CALL[i_type].items() |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 156 | |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 157 | def get_strip_string(self, i_str): |
Gunnar Mills | a812e0f | 2016-09-29 20:30:03 -0500 | [diff] [blame] | 158 | r""" |
| 159 | ######################################################################## |
| 160 | # @brief Returns the stripped strings |
| 161 | # @param i_str: @type string: string name |
| 162 | # @return Remove all special chars and return the string |
| 163 | ######################################################################## |
| 164 | """ |
George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 165 | return ''.join(e for e in i_str if e.isalnum()) |