| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/python | 
|  | 2 | ''' | 
|  | 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 | ############################################################# | 
|  | 10 | ''' | 
|  | 11 |  | 
|  | 12 | #------------------- | 
|  | 13 | # FFDC default list | 
|  | 14 | #------------------- | 
|  | 15 |  | 
|  | 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 = { | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 21 | 'DRIVER INFO' : | 
|  | 22 | { | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 23 | #String Name         Command | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 24 | 'Build Info' : 'cat /etc/version', | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 25 | 'FW Level'   : 'cat /etc/os-release', | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 26 | }, | 
|  | 27 | 'BMC DATA' : | 
|  | 28 | { | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 29 | 'BMC OS'     : 'uname -a', | 
|  | 30 | 'BMC Uptime' : 'uptime', | 
|  | 31 | 'BMC Proc Info' : 'cat /proc/cpuinfo', | 
|  | 32 | 'BMC File System Disk Space Usage' : 'df -hT', | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 33 | }, | 
|  | 34 | 'APPLICATION DATA' : | 
|  | 35 | { | 
|  | 36 | 'BMC state' : '/usr/sbin/obmcutil  state', | 
|  | 37 | }, | 
|  | 38 | } | 
|  | 39 |  | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 40 | # Add file name and correcponding command needed for BMC | 
|  | 41 | FFDC_BMC_FILE = { | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 42 | 'BMC FILES' : | 
|  | 43 | { | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 44 | #File Name         Command | 
|  | 45 | 'BMC_proc_list' : 'top -n 1 -b', | 
|  | 46 | 'BMC_journalctl.log' : 'journalctl --no-pager', | 
|  | 47 | }, | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | # Define your keywords in method/utils and call here | 
|  | 51 | FFDC_METHOD_CALL = { | 
|  | 52 | 'BMC LOGS' : | 
|  | 53 | { | 
|  | 54 | #Description             Keyword name | 
|  | 55 | 'FFDC Generic Report' : 'BMC FFDC Manifest', | 
|  | 56 | 'BMC Specific Files'  : 'BMC FFDC Files', | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 57 | }, | 
|  | 58 | } | 
|  | 59 |  | 
|  | 60 | #----------------------------------------------------------------- | 
|  | 61 |  | 
|  | 62 |  | 
|  | 63 | # base class for FFDC default list | 
|  | 64 | class openbmc_ffdc_list(): | 
|  | 65 |  | 
|  | 66 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 67 | #   @brief    This method returns the list from the dictionary for cmds | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 68 | #   @param    i_type: @type string: string index lookup | 
|  | 69 | #   @return   List of key pair from the dictionary | 
|  | 70 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 71 | def get_ffdc_bmc_cmd(self,i_type): | 
|  | 72 | return FFDC_BMC_CMD[i_type].items() | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 73 |  | 
|  | 74 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 75 | #   @brief    This method returns the list from the dictionary for scp | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 76 | #   @param    i_type: @type string: string index lookup | 
|  | 77 | #   @return   List of key pair from the dictionary | 
|  | 78 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 79 | def get_ffdc_bmc_file(self,i_type): | 
|  | 80 | return FFDC_BMC_FILE[i_type].items() | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 81 |  | 
|  | 82 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 83 | #   @brief    This method returns the list index from dictionary | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 84 | #   @return   List of index to the dictionary | 
|  | 85 | ######################################################################## | 
| George Keishing | 69e6f71 | 2016-09-12 06:30:09 -0500 | [diff] [blame] | 86 | def get_ffdc_cmd_index(self): | 
|  | 87 | return FFDC_BMC_CMD.keys() | 
|  | 88 |  | 
|  | 89 | ######################################################################## | 
|  | 90 | #   @brief    This method returns the list index from dictionary | 
|  | 91 | #   @return   List of index to the dictionary | 
|  | 92 | ######################################################################## | 
|  | 93 | def get_ffdc_file_index(self): | 
|  | 94 | return FFDC_BMC_FILE.keys() | 
|  | 95 |  | 
|  | 96 | ######################################################################## | 
|  | 97 | #   @brief    This method returns the key pair from the dictionary | 
|  | 98 | #   @return   Index of the method dictionary | 
|  | 99 | ######################################################################## | 
|  | 100 | def get_ffdc_method_index(self): | 
|  | 101 | return FFDC_METHOD_CALL.keys() | 
|  | 102 |  | 
|  | 103 | ######################################################################## | 
|  | 104 | #   @brief    This method returns the key pair from the dictionary | 
|  | 105 | #   @return   List of key pair keywords | 
|  | 106 | ######################################################################## | 
|  | 107 | def get_ffdc_method_call(self,i_type): | 
|  | 108 | return FFDC_METHOD_CALL[i_type].items() | 
| George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 109 |  | 
|  | 110 | ######################################################################## | 
|  | 111 | #   @brief    Returns the stripped strings | 
|  | 112 | #   @param    i_str: @type string: string name | 
|  | 113 | #   @return   Remove all special chars and return the string | 
|  | 114 | ######################################################################## | 
|  | 115 | def get_strip_string(self, i_str): | 
|  | 116 | return ''.join(e for e in i_str if e.isalnum()) |