1e7e9171eSGeorge Keishing#!/usr/bin/env python3 2642b3552SMichael Walsh 3*20f38712SPatrick Williamsfrom gen_arg import * 4*20f38712SPatrick Williamsfrom gen_call_robot import * 5*20f38712SPatrick Williamsfrom gen_cmd import * 6*20f38712SPatrick Williamsfrom gen_misc import * 7*20f38712SPatrick Williamsfrom gen_plug_in_utils import * 8642b3552SMichael Walshfrom gen_print import * 9642b3552SMichael Walshfrom gen_valid import * 10642b3552SMichael Walsh 11642b3552SMichael Walsh# Set exit_on_error for gen_valid functions. 12642b3552SMichael Walshset_exit_on_error(True) 13642b3552SMichael Walsh 14642b3552SMichael Walshparser = argparse.ArgumentParser( 15*20f38712SPatrick Williams usage="%(prog)s [OPTIONS]", 16*20f38712SPatrick Williams description=( 17*20f38712SPatrick Williams "%(prog)s will determine whether FFDC should be collected. If so, it" 18*20f38712SPatrick Williams " will return " 19*20f38712SPatrick Williams ) 20*20f38712SPatrick Williams + repr(dump_ffdc_rc()) 21*20f38712SPatrick Williams + ".", 22642b3552SMichael Walsh formatter_class=argparse.ArgumentDefaultsHelpFormatter, 23*20f38712SPatrick Williams prefix_chars="-+", 24*20f38712SPatrick Williams) 25642b3552SMichael Walsh 26642b3552SMichael Walsh# The stock_list will be passed to gen_get_options. We populate it with the names of stock parm options we 27642b3552SMichael Walsh# want. These stock parms are pre-defined by gen_get_options. 28*20f38712SPatrick Williamsstock_list = [ 29*20f38712SPatrick Williams ("test_mode", get_plug_default("test_mode", 0)), 30642b3552SMichael Walsh ("quiet", get_plug_default("quiet", 0)), 31*20f38712SPatrick Williams ("debug", get_plug_default("debug", 0)), 32*20f38712SPatrick Williams] 33642b3552SMichael Walsh 34642b3552SMichael Walsh# For now we are hard-coding this value vs adding a soft_errors=boolean entry in the parm_def file. 35642b3552SMichael WalshFFDC_SOFT_ERRORS = 1 36642b3552SMichael Walsh 37642b3552SMichael Walsh 38*20f38712SPatrick Williamsdef exit_function(signal_number=0, frame=None): 39642b3552SMichael Walsh r""" 40642b3552SMichael Walsh Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). 41642b3552SMichael Walsh 42642b3552SMichael Walsh This function will be called by gen_exit_function(). 43642b3552SMichael Walsh """ 44642b3552SMichael Walsh 45642b3552SMichael Walsh process_robot_output_files() 46642b3552SMichael Walsh 47642b3552SMichael Walsh 48642b3552SMichael Walshdef validate_parms(): 49642b3552SMichael Walsh r""" 50642b3552SMichael Walsh Validate program parameters, etc. 51642b3552SMichael Walsh 52642b3552SMichael Walsh This function will be called by gen_setup(). 53642b3552SMichael Walsh """ 54642b3552SMichael Walsh 55642b3552SMichael Walsh get_plug_vars() 56642b3552SMichael Walsh 57642b3552SMichael Walsh valid_value(AUTOBOOT_OPENBMC_HOST) 58642b3552SMichael Walsh 59642b3552SMichael Walsh 60642b3552SMichael Walshdef main(): 61642b3552SMichael Walsh gen_setup() 62642b3552SMichael Walsh 63642b3552SMichael Walsh print_plug_in_header() 64642b3552SMichael Walsh 65642b3552SMichael Walsh if FFDC_COMMAND.upper() == "FAIL": 66642b3552SMichael Walsh if AUTOBOOT_BOOT_SUCCESS == "0": 67*20f38712SPatrick Williams print_timen( 68*20f38712SPatrick Williams "The caller wishes to dump FFDC after each boot failure." 69*20f38712SPatrick Williams ) 70642b3552SMichael Walsh exit(dump_ffdc_rc()) 71642b3552SMichael Walsh elif FFDC_COMMAND.upper() == "ALL": 72642b3552SMichael Walsh print_timen("The caller wishes to dump FFDC after each boot test.") 73642b3552SMichael Walsh exit(dump_ffdc_rc()) 74642b3552SMichael Walsh elif len(FFDC_COMMAND) > 0: 75642b3552SMichael Walsh shell_rc, out_buf = shell_cmd(FFDC_COMMAND, quiet=quiet) 76642b3552SMichael Walsh if shell_rc != 0: 77642b3552SMichael Walsh print_timen("The caller wishes to dump FFDC.") 78642b3552SMichael Walsh exit(dump_ffdc_rc()) 79642b3552SMichael Walsh if FFDC_SOFT_ERRORS: 80642b3552SMichael Walsh # Check the num_error_logs value left by the Soft_errors plug-in. 81642b3552SMichael Walsh num_error_logs = int(restore_plug_in_value(0, "Soft_errors")) 82642b3552SMichael Walsh if num_error_logs > 0: 83*20f38712SPatrick Williams print_timen( 84*20f38712SPatrick Williams 'The "Soft_errors" plug-in found soft_errors and the' 85*20f38712SPatrick Williams + " caller wishes to dump FFDC on soft errors." 86*20f38712SPatrick Williams ) 87642b3552SMichael Walsh exit(dump_ffdc_rc()) 88642b3552SMichael Walsh 89642b3552SMichael Walsh print_timen("The caller does not wish for any FFDC to be collected.") 90642b3552SMichael Walsh 91642b3552SMichael Walsh 92642b3552SMichael Walshmain() 93