#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# show_tech_fast_ether_pd_ethernet - Show tech-support fast script for 
#                                    ethernet PD (generic PI version)
#
# October 2008, Simon Osborne
#
# Copyright (c) 2008-2009, 2012 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"
internal_if="unspecified"
external_if=""
ether_arg_string=""
bundle_only_arg_string=""

while [ "$#" -gt "0" ]; do
    case "$1" in
        -I) internal_if="$2"; shift 2;;
        -t) __cardtype="$2"; shift 2;;
        *) shift;;
    esac
done

if [ "$internal_if" != "unspecified" ]; then
    external_if=`convert_interface_fmt '-e' $internal_if`
fi

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. 
#

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

#
# Commands from c12k
#
rplc_exec[1]='show ethernet trace hardware spa'
rplc__ksh[1]='spa_ether_show_ltrace'

#
# No HFR or Viking commands because they provide their own script, and having
# commands here slows down show tech on EnXR.
#
rplc_exec[2]=''
rplc__ksh[2]=''


###############################################################################
# Commands that need to loop for all nodes within the rack.  This is used for #
# commands that require a location, don't support location all, and don't run #
# on the LCs                                                                  #
###############################################################################

#
# C12k commands
# 
rp_loc_exec[1]='show ethernet trace hardware plim location $location'
rp_loc__ksh[1]='plim_4p_ge_show_ltrace -i $fq_nodeid'

#
# No HFR or Viking commands because they provide their own script, and having
# commands here slows down show tech on EnXR.
#
rp_loc_exec[2]=''
rp_lpc__ksh[2]=''


#
# The display() function is the one that does all the work - called by us as 
# this is a worker script.
#
display() {
    print_main_heading "show tech-support ether pd"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "RP")
            exec_commands rplc
            exec_commands_rack_nodes rp_loc
            ;;
        "LC")
            exec_commands rplc
            ;;
        esac
    fi
    
    print_main_heading "show tech-support ether pd complete"
}

display


