#!/pkg/bin/ksh
# show tech-support placed command
#
# Feb 2010, Kiran Rathna Kempahanumaiah
#
# Copyright (c) 2010-2014, 2017-2018, 2020 by cisco Systems, Inc.
# All rights reserved.
#----------------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

sys_exec[1]='show version'

if [[ "$platform" = "panini" ]]; then
    sys__ksh[1]='ng_show_version'
else
    sys__ksh[1]='show_version'
fi

sys_exec[2]='show redundancy summary'
sys__ksh[2]='redcon_show -s'
sys_exec[3]='show redundancy'
sys__ksh[3]='redcon_show'
sys_exec[4]='show redundancy trace location all'
sys__ksh[4]='show_rmf_trace -ESDL -i all'
sys__ksh[5]=''

dumpcore_location_cmds_exec[1]='dumpcore running placed'
dumpcore_location_cmds__ksh[1]='corehelper_gen -o running -p placed'
dumpcore_location_cmds__ksh[2]=''

current_location_cmds_exec[1]='run sysmgr_show -o -l all -n $fq_nodeid'
current_location_cmds__ksh[1]='sysmgr_show -o -l all -n $fq_nodeid'
current_location_cmds_exec[2]='show log local location $location'
current_location_cmds__ksh[2]='show_local_log -n $fq_nodeid'
current_location_cmds_exec[3]='run sysmgr_show -o -b -n $fq_nodeid'
current_location_cmds__ksh[3]='sysmgr_show -o -b -n $fq_nodeid'
current_location_cmds_exec[4]='show placement trace all location $location'
current_location_cmds__ksh[4]='show_ltrace_placed -i $fq_nodeid -T all'
current_location_cmds_exec[5]='show placement node-inventory'
current_location_cmds__ksh[5]='placed_show -n'
current_location_cmds_exec[6]='show placement program all'
current_location_cmds__ksh[6]='placed_show -p all'
current_location_cmds_exec[7]='show placement internal-state'
current_location_cmds__ksh[7]='placed_show -x'
current_location_cmds__ksh[8]=''

dumpcore=0;
__cardtype="unspecified";


while [ "$#" -gt "0" ]; do
    case "$1" in
       -D) dumpcore=1;
	   shift 1;;
       -t) __cardtype="$2"; shift 2;;
       -l) location="$2"; shift 2;;
        *) default_parser_function $@; shift $#;;
    esac
done

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

display() {

    print_main_heading "show tech-support placed"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "DRP"|"RP")
 	    if [ "$dumpcore" == "1" ]; then
		exec_commands dumpcore_location_cmds
	    fi
            exec_commands current_location_cmds
            ;;
         "SC")
            exec_commands current_location_cmds
            ;;
         "LC")
            ;;
         esac
    fi

    #Include show tech processmgr/sysmgr, tech ds  
    enable_techs "" /pkg/bin/sysmgr_show_tech_support_fast show_tech_ds_fast
    set_max_depth 2

    print_main_heading "show tech-support placed complete"

}

. /pkg/bin/show_tech_file_fragment

