blob: b060e3e3c4ca189e88c86752bf67116388f7b82c [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
Michael Walshffe21d72018-08-20 15:01:58 -05002
3r"""
4See help text for details.
5"""
6
George Keishinge635ddc2022-12-08 07:38:02 -06007import sys
8
Sridevi Ramesh47375aa2022-12-08 05:05:31 -06009save_path_0 = sys.path[0]
10del sys.path[0]
11
Patrick Williams20f38712022-12-08 06:18:26 -060012from gen_arg import * # NOQA
13from gen_print import * # NOQA
14from gen_valid import * # NOQA
15from openbmc_ffdc_list import * # NOQA
George Keishing37c58c82022-12-08 07:42:54 -060016
Michael Walshffe21d72018-08-20 15:01:58 -050017# Restore sys.path[0].
18sys.path.insert(0, save_path_0)
19
20# Set exit_on_error for gen_valid functions.
21set_exit_on_error(True)
22
23parser = argparse.ArgumentParser(
Patrick Williamsa57fef42022-12-03 07:00:14 -060024 usage="%(prog)s [OPTIONS]",
Patrick Williams20f38712022-12-08 06:18:26 -060025 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"
George Keishing7899a452023-02-15 02:46:54 -060030 " Specific Files:Sys Inventory Files:Core Files:OS FFDC:Dump Files",
Michael Walshffe21d72018-08-20 15:01:58 -050031 formatter_class=argparse.RawDescriptionHelpFormatter,
Patrick Williamsa57fef42022-12-03 07:00:14 -060032 prefix_chars="-+",
33)
Michael Walshffe21d72018-08-20 15:01:58 -050034
35# Populate stock_list with options we want.
36stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)]
37
38
Patrick Williamsa57fef42022-12-03 07:00:14 -060039def exit_function(signal_number=0, frame=None):
Michael Walshffe21d72018-08-20 15:01:58 -050040 r"""
41 Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
42 """
43
44 dprint_executing()
45 dprint_var(signal_number)
46
47 qprint_pgm_footer()
48
49
Patrick Williamsa57fef42022-12-03 07:00:14 -060050def signal_handler(signal_number, frame):
Michael Walshffe21d72018-08-20 15:01:58 -050051 r"""
52 Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
53 with return code 143 and without calling our exit_function.
54 """
55
56 # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
57 # call exit_function from here.
58
59 dprint_executing()
60
61 # Calling exit prevents us from returning to the code that was running when we received the signal.
62 exit(0)
63
64
65def validate_parms():
66 r"""
67 Validate program parameters, etc.
68 """
69
70 gen_post_validation(exit_function, signal_handler)
71
72
73def main():
Michael Walshffe21d72018-08-20 15:01:58 -050074 gen_get_options(parser, stock_list)
75
76 validate_parms()
77
78 qprint_pgm_header()
79
80 my_openbmc_ffdc_list = openbmc_ffdc_list()
Patrick Williamsa57fef42022-12-03 07:00:14 -060081 ffdc_function_list = my_openbmc_ffdc_list.get_ffdc_method_desc("BMC LOGS")
Michael Walshffe21d72018-08-20 15:01:58 -050082 # Convert from list to colon-delimited string.
Patrick Williamsa57fef42022-12-03 07:00:14 -060083 ffdc_function_list = ":".join(ffdc_function_list)
Michael Walshffe21d72018-08-20 15:01:58 -050084 print(ffdc_function_list)
85
86
87main()