#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# tech_eth_output    - Shared show tech-support fast script for Ethernet output  
#                                      
#
# November 2008, Matthew Edwards
#
# Copyright (c) 2008, 2011-2015 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------

#
# Load the script provided by show-tech infra, which provides worker functions
#
. /pkg/bin/show_tech_main_fragment

#
# Parse the arguments to the script - card type and interface filter are the 
# only support options currently.  No need to use the default parser function,
# as this has been done by caller.
#
__cardtype="unspecified"
trace_only="0"
show_only="0"

while [ "$#" -gt "0" ]; do
    case "$1" in
        -T) trace_only="1"; shift 1;;
        -S) show_only="1"; shift 1;;
        -t) __cardtype="$2"; shift 2;;
        *) shift;;
    esac
done

if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

#
# List of commands to be run.  East set must finish with a pair of empty 
# strings.  Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands.
#
# For all of these the __ksh variable is the process that will actually be 
# spawned, the _exec variable is just a string that is printed in the output to
# describe it. 
#


#
# No show commands for FHRP Output are run only on the LR
#

###############################################################################
# Show commands that run on all RP or LC                                      #
###############################################################################

#
# Trace commands
#
rplc_trace_exec[1]='show fhrp-output trace location $location'
rplc_trace__ksh[1]='fhrp_output_show_ltrace'

rplc_trace_exec[2]='show fhrp-output trace idb location $location'
rplc_trace__ksh[2]='fhrp_output_idb_show_ltrace'

rplc_trace_exec[3]=''
rplc_trace__ksh[3]=''

#
# Show commands
#
rplc_show_exec[1]=''
rplc_show__ksh[1]=''

#
# The display() function is the one that does all the work - called by us as 
# this is a worker script.
#
display() {
    
    case "$__cardtype" in
    "LC")
        print_main_heading "FHRP Output tech-support info"
        if [ "$trace_only" = "0" ]; then
            exec_commands rplc_show
        fi
        if [ "$show_only" = "0" ]; then
            exec_commands rplc_trace
        fi
        print_main_heading "FHRP Output tech-support info complete"
        ;;
    esac

}

display
