| George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 2 |  | 
|  | 3 | r""" | 
|  | 4 | See help text for details. | 
|  | 5 | """ | 
|  | 6 |  | 
| George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 7 | import sys | 
|  | 8 |  | 
| Sridevi Ramesh | 47375aa | 2022-12-08 05:05:31 -0600 | [diff] [blame] | 9 | save_path_0 = sys.path[0] | 
|  | 10 | del sys.path[0] | 
|  | 11 |  | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 12 | from gen_arg import *  # NOQA | 
|  | 13 | from gen_print import *  # NOQA | 
|  | 14 | from gen_valid import *  # NOQA | 
|  | 15 | from openbmc_ffdc_list import *  # NOQA | 
| George Keishing | 37c58c8 | 2022-12-08 07:42:54 -0600 | [diff] [blame] | 16 |  | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 17 | # Restore sys.path[0]. | 
|  | 18 | sys.path.insert(0, save_path_0) | 
|  | 19 |  | 
|  | 20 | # Set exit_on_error for gen_valid functions. | 
|  | 21 | set_exit_on_error(True) | 
|  | 22 |  | 
|  | 23 | parser = argparse.ArgumentParser( | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 24 | usage="%(prog)s [OPTIONS]", | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 25 | description=( | 
|  | 26 | "%(prog)s will print a colon-delimited list of all valid OBMC FFDC" | 
|  | 27 | " functions.\n\nExample:" | 
|  | 28 | ) | 
|  | 29 | + "\n\n\nDump Log:FFDC Generic Report:Get Request FFDC:SEL Log:BMC" | 
|  | 30 | " Specific Files:Sys Inventory Files" | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 31 | + ":Core Files:OS FFDC:Dump Files", | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 32 | formatter_class=argparse.RawDescriptionHelpFormatter, | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 33 | prefix_chars="-+", | 
|  | 34 | ) | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 35 |  | 
|  | 36 | # Populate stock_list with options we want. | 
|  | 37 | stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)] | 
|  | 38 |  | 
|  | 39 |  | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 40 | def exit_function(signal_number=0, frame=None): | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 41 | r""" | 
|  | 42 | Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). | 
|  | 43 | """ | 
|  | 44 |  | 
|  | 45 | dprint_executing() | 
|  | 46 | dprint_var(signal_number) | 
|  | 47 |  | 
|  | 48 | qprint_pgm_footer() | 
|  | 49 |  | 
|  | 50 |  | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 51 | def signal_handler(signal_number, frame): | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 52 | r""" | 
|  | 53 | Handle signals.  Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately | 
|  | 54 | with return code 143 and without calling our exit_function. | 
|  | 55 | """ | 
|  | 56 |  | 
|  | 57 | # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly | 
|  | 58 | # call exit_function from here. | 
|  | 59 |  | 
|  | 60 | dprint_executing() | 
|  | 61 |  | 
|  | 62 | # Calling exit prevents us from returning to the code that was running when we received the signal. | 
|  | 63 | exit(0) | 
|  | 64 |  | 
|  | 65 |  | 
|  | 66 | def validate_parms(): | 
|  | 67 | r""" | 
|  | 68 | Validate program parameters, etc. | 
|  | 69 | """ | 
|  | 70 |  | 
|  | 71 | gen_post_validation(exit_function, signal_handler) | 
|  | 72 |  | 
|  | 73 |  | 
|  | 74 | def main(): | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 75 | gen_get_options(parser, stock_list) | 
|  | 76 |  | 
|  | 77 | validate_parms() | 
|  | 78 |  | 
|  | 79 | qprint_pgm_header() | 
|  | 80 |  | 
|  | 81 | my_openbmc_ffdc_list = openbmc_ffdc_list() | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 82 | ffdc_function_list = my_openbmc_ffdc_list.get_ffdc_method_desc("BMC LOGS") | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 83 | # Convert from list to colon-delimited string. | 
| Patrick Williams | a57fef4 | 2022-12-03 07:00:14 -0600 | [diff] [blame] | 84 | ffdc_function_list = ":".join(ffdc_function_list) | 
| Michael Walsh | ffe21d7 | 2018-08-20 15:01:58 -0500 | [diff] [blame] | 85 | print(ffdc_function_list) | 
|  | 86 |  | 
|  | 87 |  | 
|  | 88 | main() |