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