George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 2 | |
| 3 | from gen_print import * |
| 4 | from gen_valid import * |
| 5 | from gen_arg import * |
| 6 | from gen_misc import * |
| 7 | from gen_cmd import * |
| 8 | from gen_plug_in_utils import * |
| 9 | from gen_call_robot import * |
| 10 | |
| 11 | # Set exit_on_error for gen_valid functions. |
| 12 | set_exit_on_error(True) |
| 13 | |
| 14 | parser = argparse.ArgumentParser( |
| 15 | usage='%(prog)s [OPTIONS]', |
| 16 | description="%(prog)s will determine whether FFDC should be collected. If so, it will return " |
| 17 | + repr(dump_ffdc_rc()) + ".", |
| 18 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 19 | prefix_chars='-+') |
| 20 | |
| 21 | # The stock_list will be passed to gen_get_options. We populate it with the names of stock parm options we |
| 22 | # want. These stock parms are pre-defined by gen_get_options. |
| 23 | stock_list = [("test_mode", get_plug_default("test_mode", 0)), |
| 24 | ("quiet", get_plug_default("quiet", 0)), |
| 25 | ("debug", get_plug_default("debug", 0))] |
| 26 | |
| 27 | # For now we are hard-coding this value vs adding a soft_errors=boolean entry in the parm_def file. |
| 28 | FFDC_SOFT_ERRORS = 1 |
| 29 | |
| 30 | |
| 31 | def exit_function(signal_number=0, |
| 32 | frame=None): |
| 33 | r""" |
| 34 | Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). |
| 35 | |
| 36 | This function will be called by gen_exit_function(). |
| 37 | """ |
| 38 | |
| 39 | process_robot_output_files() |
| 40 | |
| 41 | |
| 42 | def validate_parms(): |
| 43 | r""" |
| 44 | Validate program parameters, etc. |
| 45 | |
| 46 | This function will be called by gen_setup(). |
| 47 | """ |
| 48 | |
| 49 | get_plug_vars() |
| 50 | |
| 51 | valid_value(AUTOBOOT_OPENBMC_HOST) |
| 52 | |
| 53 | |
| 54 | def main(): |
| 55 | |
| 56 | gen_setup() |
| 57 | |
| 58 | print_plug_in_header() |
| 59 | |
| 60 | if FFDC_COMMAND.upper() == "FAIL": |
| 61 | if AUTOBOOT_BOOT_SUCCESS == "0": |
| 62 | print_timen("The caller wishes to dump FFDC after each boot failure.") |
| 63 | exit(dump_ffdc_rc()) |
| 64 | elif FFDC_COMMAND.upper() == "ALL": |
| 65 | print_timen("The caller wishes to dump FFDC after each boot test.") |
| 66 | exit(dump_ffdc_rc()) |
| 67 | elif len(FFDC_COMMAND) > 0: |
| 68 | shell_rc, out_buf = shell_cmd(FFDC_COMMAND, quiet=quiet) |
| 69 | if shell_rc != 0: |
| 70 | print_timen("The caller wishes to dump FFDC.") |
| 71 | exit(dump_ffdc_rc()) |
| 72 | if FFDC_SOFT_ERRORS: |
| 73 | # Check the num_error_logs value left by the Soft_errors plug-in. |
| 74 | num_error_logs = int(restore_plug_in_value(0, "Soft_errors")) |
| 75 | if num_error_logs > 0: |
| 76 | print_timen("The \"Soft_errors\" plug-in found soft_errors and the" |
| 77 | + " caller wishes to dump FFDC on soft errors.") |
| 78 | exit(dump_ffdc_rc()) |
| 79 | |
| 80 | print_timen("The caller does not wish for any FFDC to be collected.") |
| 81 | |
| 82 | |
| 83 | main() |