George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | ''' |
| 3 | ############################################################# |
| 4 | # @file openbmc_ffdc_list.py |
| 5 | # @author: George Keishing |
| 6 | # |
| 7 | # @brief List for FFDC ( First failure data capture ) |
| 8 | # commands and files to be collected as a part |
| 9 | # of the test case failure. |
| 10 | ############################################################# |
| 11 | ''' |
| 12 | |
| 13 | #------------------- |
| 14 | # FFDC default list |
| 15 | #------------------- |
| 16 | |
| 17 | #----------------------------------------------------------------- |
| 18 | #Dict Name { Index string : { Key String : Comand string} } |
| 19 | #----------------------------------------------------------------- |
| 20 | FFDC_CMD = { |
| 21 | 'DRIVER INFO' : |
| 22 | { |
| 23 | 'FW Level' : 'cat /etc/os-release', |
| 24 | 'OS Details' : 'uname -a', |
| 25 | 'Build Info' : 'cat /etc/version', |
| 26 | }, |
| 27 | 'BMC DATA' : |
| 28 | { |
| 29 | 'System journal log' : 'journalctl --no-pager', |
| 30 | 'Displays processor activity' : 'top -n 1 -b', |
| 31 | }, |
| 32 | 'APPLICATION DATA' : |
| 33 | { |
| 34 | 'BMC state' : '/usr/sbin/obmcutil state', |
| 35 | }, |
| 36 | } |
| 37 | |
| 38 | # add file list needed to be offload from BMC |
| 39 | FFDC_FILE = { |
| 40 | 'BMC FILES' : |
| 41 | { |
| 42 | # Sample example how to add the file that |
| 43 | # is needed to be offloaded |
| 44 | #'Release info' : '/etc/os-release', |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | #----------------------------------------------------------------- |
| 49 | |
| 50 | |
| 51 | # base class for FFDC default list |
| 52 | class openbmc_ffdc_list(): |
| 53 | |
| 54 | ######################################################################## |
| 55 | # @@brief This method returns the list from the dictionary for cmds |
| 56 | # @param i_type: @type string: string index lookup |
| 57 | # @return List of key pair from the dictionary |
| 58 | ######################################################################## |
| 59 | def get_ffdc_cmd(self,i_type): |
| 60 | return FFDC_CMD[i_type].items() |
| 61 | |
| 62 | ######################################################################## |
| 63 | # @@brief This method returns the list from the dictionary for scp |
| 64 | # @param i_type: @type string: string index lookup |
| 65 | # @return List of key pair from the dictionary |
| 66 | ######################################################################## |
| 67 | def get_ffdc_file(self,i_type): |
| 68 | return FFDC_FILE[i_type].items() |
| 69 | |
| 70 | ######################################################################## |
| 71 | # @@brief This method returns the list index from dictionary |
| 72 | # @return List of index to the dictionary |
| 73 | ######################################################################## |
| 74 | def get_ffdc_index(self): |
| 75 | return FFDC_CMD.keys() |
| 76 | |
| 77 | ######################################################################## |
| 78 | # @brief Returns the stripped strings |
| 79 | # @param i_str: @type string: string name |
| 80 | # @return Remove all special chars and return the string |
| 81 | ######################################################################## |
| 82 | def get_strip_string(self, i_str): |
| 83 | return ''.join(e for e in i_str if e.isalnum()) |
| 84 | |