#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_lsd - show commands for show tech-support lsd
#                     spawned by show_tech_fast
#
# October 2013, Danial Johari
#
# Copyright (c) 2013-2014, 2016-2017 by cisco Systems, Inc.
# All rights reserved.
# --------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

# Initialise any variables used.
location=""
__cardtype="unspecified"


# Parse the arguments to the script.
while [ "$#" -gt "0" ]; do
    case "$1" in
        -t) __cardtype="$2"; shift 2;;
        -l) location="$2"; shift 2;;
        *)  default_parser_function "$@"; shift $#;;
    esac
done

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

# ***********************************************************
#  Show commands to be run by the show tech-support commands
# ***********************************************************

# System commands
i=1
j=1
System_exec[$((i++))]='show clock'
System__ksh[$((j++))]='iosclock -d 0x0'
System_exec[$((i++))]='show running-config hostname'
System__ksh[$((j++))]='nvgen -c -q gl/a/hostname'
System_exec[$((i++))]='show platform'
if [[ "$platform" = "viking" ]]; then 
     System__ksh[$((j++))]='show_platform_vkg -e'
elif [[ "$platform" = "panini" ]]; then
     System__ksh[$((j++))]='show_platform_sysdb -v'
elif [[ "$platform" = "hfr" ]]; then
     System__ksh[$((j++))]='shelfmgr_show_hfr -e'
else 
     System__ksh[$((j++))]='show_platform -a'
fi
System_exec[$((i++))]='show version'
if [[ "$platform" = "panini" ]]; then 
     System__ksh[$((j++))]='ng_show_version'
else
     System__ksh[$((j++))]='show_version'
fi
if [[ "$platform" = "panini" ]]; then 
     System_exec[$((i++))]='show install active'
     System__ksh[$((j++))]='sdr_instcmd show install active'
else
     System_exec[$((i++))]='show install active summary'
     System__ksh[$((j++))]='instcmd show install active summary'
fi
System_exec[$((i++))]='show redundancy location $location'
System__ksh[$((j++))]='redcon_show -n $fq_nodeid'
System_exec[$((i++))]='show redundancy summary'
System__ksh[$((j++))]='redcon_show -s'
System_exec[$((i++))]='show logging'
System__ksh[$((j++))]='show_logging'

# The following commands will execute only on RPs
i=1
j=1
Common_exec[$((i++))]='show redundancy location $location'
Common__ksh[$((j++))]='redcon_show -n $fq_nodeid'
Common_exec[$((i++))]='show proc mpls_lsd location $location'
Common__ksh[$((j++))]='sysmgr_show -o -p mpls_lsd -n $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd clients location $location'
Common__ksh[$((j++))]='mpls_lsd_show -c -L $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd applications private location $location'
Common__ksh[$((j++))]='mpls_lsd_show -a -P -L $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd forwarding summary location $location'
Common__ksh[$((j++))]='mpls_lsd_fwd_show -s -L $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd forwarding detail location $location'
Common__ksh[$((j++))]='mpls_lsd_fwd_show -d -L $fq_nodeid'
Common_exec[$((i++))]='show mpls forwarding no-counters location $location'
Common__ksh[$((j++))]='fib_mpls_show_fwding -h $fq_nodeid -Z'
Common_exec[$((i++))]='show mpls label range'
Common__ksh[$((j++))]='mpls_lsd_show -r 0x0'
Common_exec[$((i++))]='show mpls label table summary location $location'
Common__ksh[$((j++))]='mpls_lsd_show -t 0x0 -s -L $fq_nodeid'
Common_exec[$((i++))]='show mpls label table detail private location $location'
Common__ksh[$((j++))]='mpls_lsd_show -t 0x0 -d -P -L $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd trace location $location'
Common__ksh[$((j++))]='mpls_lsd_trace_show -i $fq_nodeid'
Common_exec[$((i++))]='show mpls lsd private location $location'
Common__ksh[$((j++))]='mpls_lsd_show -p -L $fq_nodeid'
Common_exec[$((i++))]='show mpls interfaces location $location'
Common__ksh[$((j++))]='mpls_lsd_show -n -L $fq_nodeid'
Common_exec[$((i++))]='show mpls ea interfaces location $location'
Common__ksh[$((j++))]='mpls_io_show_intf -e -a -p -l $fq_nodeid'
Common_exec[$((i++))]=''
Common__ksh[$((j++))]=''


display() {
    print_main_heading "show tech-support mpls lsd start"

    if [ "$__cardtype" == "SYS" ]; then
	exec_commands System
    else
        exec_commands Common
    fi

    print_main_heading "show tech-support mpls lsd complete"
}

# This function calls the display() function and sends the output to file if
# the file option has been set. 
. /pkg/bin/show_tech_file_fragment
