#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# Optics_snapshot - show commands for show tech-support optics
#
# Oct 2015, Alok Kumar Sinha

# Copyright (c) 2015-2022 by cisco Systems, Inc.
# All rights reserved.
# --------------------------------------------------------------------



. /pkg/bin/show_tech_main_fragment

PLAT=`/pkg/bin/get_platform_type`

if [ $PLAT != 8000 ]
then
    source /pkg/bin/tech_fabric_common
fi

__cardtype="unspecified"
__iswhitebox=0

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

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

__isciscohw=$(xr_sysctl -e -n cisco.ios.xr.portmap.is_cisco_hw)
: ${__isciscohw:=1}
if [ "$__isciscohw" == "0" ]; then
    __npufamily=`xr_sysctl --values cisco.ios.xr.portmap.npu_family`
    if [ "$__npufamily" == "WHITE_BOX" ]; then
        __iswhitebox="1"
    fi
fi

#save the ctrace for the led for a given LC node process to the outfile argument passed
led_save_ctrace () {
    outfile=$1/led

    /pkg/bin/ctracedec -gktTdslAwp optics_led >> $outfile
}

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

#
# SYS commands 
#
### General information
sys_exec[1]='show version'
sys__ksh[1]='ng_show_version'

sys_exec[2]='show platform'
sys__ksh[2]='show_platform_sysdb'

sys_exec[3]='show logging'
sys__ksh[3]='show_logging'

sys_exec[4]='show process optics_driver location all'
sys__ksh[4]='sysmgr_show -o -p optics_driver -n all'

sys_exec[5]='show processes blocked'
sys__ksh[5]='sh_proc_ng_blocked -l all'

sys_exec[6]='show running-config'
sys__ksh[6]='nvgen -c -l 1 -t 1 -o 1'

sys_exec[7]='show cli history detail'
sys__ksh[7]='show_parser_history -h 0x2'

sys_exec[8]='Envmon Power Budgeting Info'
sys__ksh[8]='spi_envmon_test -D'

sys_exec[9]='show install fixes active'
sys__ksh[9]='xrinstall show-fixes active'

# Commands that run on all LCs
#show optics-driver trace all location
lc_exec[1]='show optics-driver trace all location $location'
lc__ksh[1]='optics_icpe_show_ltrace -A -i location $location'

#show optics trace 
lc_exec[2]='show optics trace ext location $location'
lc__ksh[2]='optics_show_ltrace -X'

lc_exec[3]='show optics trace init location $location'
lc__ksh[3]='optics_show_ltrace -Z'

lc_exec[4]='show optics trace event location $location'
lc__ksh[4]='optics_show_ltrace -H'

lc_exec[5]='show optics-driver trace driver all location $location'
lc__ksh[5]='optics_icpe_show_ltrace -C -i $fq_nodeid'

#show vether-ea trace all location
lc_exec[6]='show vether-ea trace all location $location'
lc__ksh[6]='dpa_vether_ea_show_ltrace -i $fq_nodeid -E -V'

#show ether-ea trace all location
lc_exec[7]='show ether-ea trace all location $location'
lc__ksh[7]='dpa_ether_ea_show_ltrace -i $fq_nodeid -E -V'

#show eapd optics trace all location
lc_exec[8]='show eapd optics trace all location $location'
lc__ksh[8]='optics_eapd_show_ltrace -A -i $fq_nodeid'

#show ofa trace location
lc_exec[16]='show ofa trace location $location'
lc__ksh[16]='ofa_show_ltrace -i $fq_nodeid'

#show dpa trace location
lc_exec[9]='show dpa trace location $location'
lc__ksh[9]='dpa_show_ltrace -i $fq_nodeid'

#show optics-driver trace icpe all location
lc_exec[10]='show optics-driver trace icpe all location $location'
lc__ksh[10]='optics_icpe_show_ltrace -A -i $fq_nodeid'

lc_exec[19]='show optics-driver debug all location $location'
lc__ksh[19]='optics_debug_show -A -n 0xfa -k 0x14 -m8 -i $fq_nodeid'

#show controllers fia trace all location
lc_exec[11]='show controllers fia trace all location $location'
lc__ksh[11]='fia_show_ltrace -A -i $fq_nodeid'

#show ethernet v-ether trace location
lc_exec[12]='show ethernet v-ether trace location $location'
lc__ksh[12]='eth_intf_show_trace -i $fq_nodeid'

#show qos ea trace all location
lc_exec[13]='show qos ea trace all location $location'
lc__ksh[13]='qos_ea_show_ltrace -i $fq_nodeid -A'

#show vether-driver server trace
lc_exec[14]='show vether-driver server event location $location'
lc__ksh[14]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x1 -Y 0x0 -Z libvether_server'

#show vether-driver server error trace
lc_exec[15]='show vether-driver server error location $location'
lc__ksh[15]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x0 -Y 0x0 -Z libvether_server'

lc_exec[17]='sfpga ltrace'
lc__ksh[17]='optics_sfpga_show_ltrace -A $fq_nodeid'

#show controller fia diagshell 
lc_exec[18]='show controller fia diagshell'
lc__ksh[18]='cat /tmp/diagshell_lc'

#show port and group db dumps
lc_exec[21]='show port DB'
lc__ksh[21]='vether_test ddb -t 0'

if [ "$platform_variant" == "fretta" ]; then
    #show vether ea events
    lc_exec[22]='show vether ea event'
    lc__ksh[22]='/pkg/bin/fretta_vether_ea_show_ltrace -V'

    #show vether ea error
    lc_exec[23]='show vether ea error'
    lc__ksh[23]='/pkg/bin/fretta_vether_ea_show_ltrace -E'
fi

# Command that run on all RPs 
rp_exec[1]='show version'
rp__ksh[1]='ng_show_version'

rp_exec[2]='show platform'
rp__ksh[2]='show_platform_sysdb'

rp_exec[3]='show dpa trace location $location'
rp__ksh[3]='dpa_show_ltrace -i $fq_nodeid'

rp_exec[4]='show inventory details'
rp__ksh[4]='show_inventory -e -x'

rp_exec[5]='show alarms brief'
rp__ksh[5]='show_operational -a Alarms Brief'

rp_exec[6]='show inventory vendor-type'
rp__ksh[6]='show_inventory -e -o'

rp_exec[7]='show ipv4 interface brief'
rp__ksh[7]='show_ip_interface -b -v default'

#show controller optics trace
rp_exec[8]='show controllers optics *'
rp__ksh[8]='show_controller_optics -a Optics.*'


cmd_index=0
((cmd_index++))
sflc_exec[$cmd_index]='show optics-driver debug optics port all location $location'
sflc__ksh[$cmd_index]='optics_debug_show -O -n 0xfa -k 0x14 -m8 -i $fq_nodeid'

((cmd_index++))
sflc_exec[$cmd_index]='show optics-driver debug phy port all location $location'
sflc__ksh[$cmd_index]='optics_debug_show -P -n 0xfa -k 0x14 -m8 -i $fq_nodeid'

((cmd_index++))
sflc_exec[$cmd_index]='show optics trace ext location $location'
sflc__ksh[$cmd_index]='optics_show_ltrace -X'

((cmd_index++))
sflc_exec[$cmd_index]='show optics trace init location $location'
sflc__ksh[$cmd_index]='optics_show_ltrace -Z'

((cmd_index++))
sflc_exec[$cmd_index]='show optics trace event location $location'
sflc__ksh[$cmd_index]='optics_show_ltrace -H'

#show optics-driver trace icpe all location
((cmd_index++))
sflc_exec[$cmd_index]='show optics-driver trace icpe all location $location'
sflc__ksh[$cmd_index]='optics_icpe_show_ltrace -A -i $fq_nodeid'

#show vether-ea trace all location
((cmd_index++))
sflc_exec[$cmd_index]='show vether-ea trace all location $location'
sflc__ksh[$cmd_index]='ofa_vether_ea_show_ltrace -i $fq_nodeid -E -V'

((cmd_index++))
sflc_exec[$cmd_index]='show vether-ea platform trace all location $location'
sflc__ksh[$cmd_index]='show_vether_platform_trace -A -i $fq_nodeid'

#show ether-ea trace all location
((cmd_index++))
sflc_exec[$cmd_index]='show ether-ea trace all location $location'
sflc__ksh[$cmd_index]='ofa_ether_ea_show_ltrace -i $fq_nodeid -E -V'

#show eapd optics trace all location
((cmd_index++))
sflc_exec[$cmd_index]='show eapd optics trace all location $location'
sflc__ksh[$cmd_index]='optics_eapd_show_ltrace -A -i $fq_nodeid'

((cmd_index++))
sflc_exec[$cmd_index]='show controllers npu trace all location $location'
sflc__ksh[$cmd_index]='npu_show_ctrace -A -h $fq_nodeid'

#show ethernet v-ether trace location
((cmd_index++))
sflc_exec[$cmd_index]='show ethernet v-ether trace location $location'
sflc__ksh[$cmd_index]='eth_intf_show_trace -i $fq_nodeid'

#show qos ea trace all location
((cmd_index++))
sflc_exec[$cmd_index]='show qos ea trace all location $location'
sflc__ksh[$cmd_index]='qos_ea_show_ltrace -i $fq_nodeid -A'

#show vether-driver server trace
((cmd_index++))
sflc_exec[$cmd_index]='show vether-driver server event location $location'
sflc__ksh[$cmd_index]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x1 -Y 0x0 -Z libvether_server'

#show vether-driver server error trace
((cmd_index++))
sflc_exec[$cmd_index]='show vether-driver server error location $location'
sflc__ksh[$cmd_index]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x0 -Y 0x0 -Z libvether_server'

((cmd_index++))
sflc_exec[$cmd_index]='show vether-driver fsm event location $location'
sflc__ksh[$cmd_index]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x3 -Y 0x0 -Z libvether_server'

((cmd_index++))
sflc_exec[$cmd_index]='show vether-driver fsm error location $location'
sflc__ksh[$cmd_index]='easy_debug_ltrace -i $fq_nodeid -W 0 -X 0x2 -Y 0x0 -Z libvether_server'

#show icpe-internal local controller optics trace location
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics trace location $location'
sflc__ksh[$cmd_index]='icpe_local_show_trace -C 0x0 -i $fq_nodeid'

#show icpe-internal local controller optics db all global all location
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics db all global all location $location'
sflc__ksh[$cmd_index]='icpe_local_show_db -C 0x0 -P 0x0 -G $fq_nodeid -F 0x0'

#show icpe-internal local controller optics db all interface
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics db all interface'
sflc__ksh[$cmd_index]='icpe_local_show_db -C 0x0 -P 0x0 -A'

#show icpe-internal local controller optics db all im-event-history
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics db all im-event-history'
sflc__ksh[$cmd_index]='icpe_local_show_db -C 0x0 -P 0x0 -E $fq_nodeid'

#show icpe-internal local controller optics db all redundancy all
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics db all redundancy all'
sflc__ksh[$cmd_index]='icpe_local_show_db -C 0x0 -P 0x0 -R $fq_nodeid -T 0x0'

#show icpe-internal local controller optics api-stats all location
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics api-stats all location $location'
sflc__ksh[$cmd_index]='icpe_local_show_api_stats -P 0x0 -g 0x0 -S -N $fq_nodeid'

#show icpe-internal local controller optics api-stats all detail location
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics api-stats all detail location $location'
sflc__ksh[$cmd_index]='icpe_local_show_api_stats -P 0x0 -g 0x0 -S -d -N $fq_nodeid'

#show icpe-internal local controller optics status
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics status'
sflc__ksh[$cmd_index]='icpe_local_show_status -C 0x0'

#show icpe-internal local controller optics status detail
((cmd_index++))
sflc_exec[$cmd_index]='show icpe-internal local controller optics status detail'
sflc__ksh[$cmd_index]='icpe_local_show_status -C 0x0 -D'

#show optics trace all location
((cmd_index++))
sflc_exec[$cmd_index]='show optics trace all location $location'
sflc__ksh[$cmd_index]='optics_show_ltrace -A -i $fq_nodeid'

((cmd_index++))
sflc_exec[$cmd_index]='show im trace location $location'
sflc__ksh[$cmd_index]='im_show_trace -i $fq_nodeid'

# Command that run on all RPs 
cmd_index=0
# specify context 11 to display dumper context for last 10 crashes (not in CLI)
((cmd_index++))
sfrp_exec[$cmd_index]='show context'
sfrp__ksh[$cmd_index]='corehelper_context -c 0xb -n all'

((cmd_index++))
sfrp_exec[$cmd_index]='show epm trace sys-events location all'
sfrp__ksh[$cmd_index]='epm_show_ltrace -i all -T 0x4'

((cmd_index++))
sfrp_exec[$cmd_index]='show controllers optics'
sfrp__ksh[$cmd_index]='show_controller_optics -a Optics.*'

((cmd_index++))
sfrp_exec[$cmd_index]='show inventory details'
sfrp__ksh[$cmd_index]='show_inventory -e -x'

((cmd_index++))
sfrp_exec[$cmd_index]='show controllers fabric plane all'
sfrp__ksh[$cmd_index]='fsdbagg_show -C P -p all -s NA -o NA'

((cmd_index++))
sfrp_exec[$cmd_index]='show optics server trace all'
sfrp__ksh[$cmd_index]='optics_server_show_ctrace -a'

((cmd_index++))
sfrp_exec[$cmd_index]='show controllers coherentDSP'
sfrp__ksh[$cmd_index]='intf_recovered -a CoherentDSP.*'

((cmd_index++))
sfrp_exec[$cmd_index]='show controllers coherentDSP prbs-details'
sfrp__ksh[$cmd_index]='intf_recovered -r CoherentDSP.*'

# Commands for ncs5k-skywarp platform collected in node.tech
# show version,platform,logging & running-config already collected in system.tech

skp_exec[1]='show inventory details'
skp__ksh[1]='show_inventory -e -x'

skp_exec[2]='show controllers optics *'
skp__ksh[2]='show_controller_optics -a Optics.*'

skp_exec[3]='show alarms brief'
skp__ksh[3]='show_operational -a Alarms Brief'

skp_exec[4]='show interfaces location $location'
skp__ksh[4]='show_interface -a -p 0x2a001000'

skp_exec[5]='show ipv4 interface brief'
skp__ksh[5]='show_ip_interface -b -v default'

skp_exec[6]='show im trace wrapping location $location'
skp__ksh[6]='im_show_trace -w -i 4096'

skp_exec[7]='show vether-ea trace all wrapping location $location'
skp__ksh[7]='skp_vether_ea_show_ltrace -w -i 4096 -E -V'

skp_exec[8]='show prm server error wrapping location $location'
skp__ksh[8]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x0 -Y 0x0 -Z prm_server'

skp_exec[9]='show prm server event wrapping location $location'
skp__ksh[9]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x1 -Y 0x0 -Z prm_server'

skp_exec[10]='show prm server uidb all software'
skp__ksh[10]='prm_show -s -uidb -all'

skp_exec[11]='show prm server port all software'
skp__ksh[11]='prm_show -s -port -all'

skp_exec[12]='show prm uidb error wrapping location $location'
skp__ksh[12]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x6 -Y 0x0 -Z prm_server'

skp_exec[13]='show prm uidb event wrapping location $location'
skp__ksh[13]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x7 -Y 0x0 -Z prm_server'

skp_exec[14]='show pm trace wrapping location $location'
skp__ksh[14]='sysmgr_show_ltrace -w -i 4096'

skp_exec[15]='show ethernet v-ether trace wrapping location $location'
skp__ksh[15]='eth_intf_show_trace -w -i 4096'

skp_exec[16]='show ethernet v-ether db all global all location $location'
skp__ksh[16]='eth_intf_show_db -P 0x0 -G 4096 -F 0x0'

skp_exec[17]='show ethernet v-ether db all interface all'
skp__ksh[17]='eth_intf_show_db -P 0x0 -A'

skp_exec[18]='show ethernet driver trace wrapping location $location'
skp__ksh[18]='ethernet_trace_show -w -i 4096'

skp_exec[19]='show ethernet infra trace wrapping location $location'
skp__ksh[19]='ether_show_trace -w -i 4096'

skp_exec[20]='show vether-driver server error wrapping location $location'
skp__ksh[20]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x0 -Y 0x0 -Z libvether_server'

skp_exec[21]='show vether-driver server event wrapping location $location'
skp__ksh[21]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x1 -Y 0x0 -Z libvether_server'

skp_exec[22]='show vether-driver fsm error wrapping location $location'
skp__ksh[22]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x2 -Y 0x0 -Z libvether_server'

skp_exec[23]='show vether-driver fsm event wrapping location $location'
skp__ksh[23]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x3 -Y 0x0 -Z libvether_server'

skp_exec[24]='show optics trace all wrapping location $location'
skp__ksh[24]='optics_show_ltrace -A -w -i 4096'

skp_exec[25]='show ethernet controller trace wrapping location $location'
skp__ksh[25]='icpe_eth_ctrlr_show_trace -w -i 4096'

skp_exec[26]='show optics-driver trace driver all wrapping location $location'
skp__ksh[26]='optics_icpe_show_ltrace -C -w -i 4096'

skp_exec[27]='show optics-driver debug all location $location'
skp__ksh[27]='optics_debug_show -A -i 4096'

skp_exec[28]='show optics-driver trace icpe all wrapping location $location'
skp__ksh[28]='optics_icpe_show_ltrace -A -w -i 4096'

skp_exec[29]='show eapd optics trace all wrapping location $location'
skp__ksh[29]='optics_eapd_show_ltrace -A -w -i 4096'

skp_exec[30]='show vether-client client error wrapping location $location'
skp__ksh[30]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x1 -Y 0x0 -Z libvether_client'

skp_exec[31]='show vether-client client event wrapping location $location'
skp__ksh[31]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x0 -Y 0x0 -Z libvether_client'

skp_exec[32]='show vether-stats error wrapping location $location'
skp__ksh[32]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x0 -Y 0x0 -Z libvether_stats_skp'

skp_exec[33]='show vether-stats event wrapping location $location'
skp__ksh[33]='easy_debug_ltrace -w -i 4096 -W 0 -X 0x1 -Y 0x0 -Z libvether_stats_skp'

skp_exec[34]='show controllers pm trace creation wrapping location $location'
skp__ksh[34]='show_skp_pm_ltrace -w -i 4096 -C'

skp_exec[35]='show controllers pm trace error wrapping location $location'
skp__ksh[35]='show_skp_pm_ltrace -w -i 4096 -R'

skp_exec[36]='show prm drv diagshell "version"'
skp__ksh[36]='prm_drv_show -c version'

skp_exec[37]='show prm drv diagshell "ps"'
skp__ksh[37]='prm_drv_show -c ps'

skp_exec[38]='show prm drv diagshell "phy info"'
skp__ksh[38]='prm_drv_show -c "phy info"'

skp_exec[39]='show prm drv diagshell "link"'
skp__ksh[39]='prm_drv_show -c link'

ncs540lrp_exec[1]='python /pkg/bin/phy_info_dump.py'
ncs540lrp__ksh[1]='python /pkg/bin/phy_info_dump.py'

show_controllers_optics(){
for j in `seq 0 7`;
    do
        /pkg/bin/show_sdr_sysdb -n | grep 0/$j/CPU0
        if [ $? -eq 0 ] 
            then
                echo "===================== Found LC$j ======================";
            echo
          # show controller optics command
                echo
                echo "================ Start of LC$j Optics ================="; 
                echo
                for i in `seq 0 35`;
                    do
                        echo "Optics Port Number = $i"
                        echo "----------------------"
                        echo "Running : show controller optics Optics0/$j/0/$i";
                        echo
                        /pkg/sbin/show_controller_optics -a 'Optics0_'$j'_0_'$i
                    done   
        fi
    done

    # show interface brief command
        echo
            echo "============ Start of show interface brief ============";
            echo
        /pkg/bin/show_interface -a -o 0x2;

    # show interface command
        echo
            echo "============ Start of show interface ============";
            echo
        /pkg/bin/show_interface -a;
}

show_diagshell_lc(){
echo "" > /tmp/diagshell_lc
for k in `seq 0 5`;
    do
       echo >> /tmp/diagshell_lc
          echo "Running : show controller fia diagshell $k ps location " >> /tmp/diagshell_lc
          /pkg/bin/fia_driver_show -c ps -u 0x$k -n $fq_nodeid >> /tmp/diagshell_lc

       echo >> /tmp/diagshell_lc
          echo "Running : show controller fia diagshell $k "diag nif" location" >> /tmp/diagshell_lc
          exec_diagnif_per_port_cmd 0x$k /tmp/diagshell_lc
    done
}

ext_node_name=`node_list_generation -f MY`
sh_tech_err_file=$__tar_file_directory_on_node/sh_tech.err
log_file_list='
               /tmp/slot*_meta_dx1_sdk*
               /tmp/cpa_optics_driver*
               /tmp/hw_id_file_s*
               /tmp/hw_status_file_s*
               /tmp/sfp_eeprom_slot*
               /tmp/optics_driver_*ctrace*
              '

gather_opt_log_files_from_list () {
    ext_node_folder=`node_conversion -N $ext_node_name`_logs
    fq_nodeid=`node_conversion -i $int_node_name`

    # Create folder to host the files
    if [ ! -e "$__tar_file_directory_on_node/$ext_node_folder" ]; then
        mkdir $__tar_file_directory_on_node/$ext_node_folder
    fi

    ### Gather the data for PHY and optics ###
    # Initiate the PHY debug so that logs are generated
    optics_debug_show -P -n 0xfa -k 0x14 -m8 -i $fq_nodeid
    # Use the -B option to dump all the optics driver traces to files
    optics_icpe_show_ltrace -B -C -i $fq_nodeid

    # Copy all the files to the tar file directory
    for file in $log_file_list; do
        if [ -e $file ]; then
            cp -f $file $__tar_file_directory_on_node/$ext_node_folder 2>> $sh_tech_err_file
        fi
    done

    # Clean up the tmp optics ctraces
    rm /tmp/optics_*ctrace*

    # Gather optics proxy logs in separate files instead of using optics_icpe_show_ltrace which goes to the .tech file
    echo "optics proxy trace location $location from signal" >> $__tar_file_directory_on_node/$ext_node_folder/optics_proxy_ctrace_from_signal.t
    ctracedec  -pkltgwLTG optics_proxy >> $__tar_file_directory_on_node/$ext_node_folder/optics_proxy_ctrace_from_signal.t
    echo "optics proxy trace location $location from buffer" >> $__tar_file_directory_on_node/$ext_node_folder/optics_proxy_ctrace_from_buffer
    ctracedec  -pkltgwLTA optics_proxy >> $__tar_file_directory_on_node/$ext_node_folder/optics_proxy_ctrace_from_buffer

    # Gather other traces
    ctracedec -pkltgwLTA spitfire_vether_pd >> $__tar_file_directory_on_node/$ext_node_folder/sf_vether_pd_ctrace
    ctracedec -pkltgwLTA spitfire_fwdlib >> $__tar_file_directory_on_node/$ext_node_folder/sf_fwdlib_ctrace
}

display() {
#Print opening heading
    print_main_heading "show tech-support optics"
    if [ "$__cardtype" == "SYS" ]; then
            exec_commands sys
    else

       TMP_PLAT=`/pkg/bin/get_platform_type`
       case "$__cardtype" in
            "RP")

               if [ $TMP_PLAT == 8000 ]
               then   
                   exec_commands sfrp
               else
                  #Platform check, returns 0 for NCS-5500/Fretta 
                  /pkg/bin/show_sdr_sysdb -n | grep "NCS-55\|NC55\|N540"
                  if [ $? -eq 0 ] || [ "$__iswhitebox" == "1" ] 
                      then
                          exec_commands rp
                  else 
                  #NCS-5000/Skywarp case
                      exec_commands skp 
                  fi  
               fi    
               
               if [ $TMP_PLAT == "NCS540L" ] || [ $TMP_PLAT == "NCS5700" ]
               then   
                   exec_commands ncs540lrp
               fi    
           ;;

           "LC")

               if [ $TMP_PLAT == 8000 ]
               then    
                   exec_commands sflc
               else
                  #LC only for NCS-5500/Fretta ; to skip for NCS-5000/Skywarp
                  /pkg/bin/show_sdr_sysdb -n | grep "NCS-55\|NC55\|N540\|NC57"
                  if [ $? -eq 0 ] || [ "$__iswhitebox" == "1" ]
                      then
                          show_diagshell_lc;
                          exec_commands lc
                          node_subdir=$__tar_file_directory_on_node/$node_name
                          if [ ! -d "$node_subdir" ]; then
                              /bin/mkdir -p $node_subdir
                          fi
                          led_save_ctrace $node_subdir
                  fi
               fi
           ;;
       esac
    fi

    if [ "$__cardtype" != "SYS" ]; then
        gather_opt_log_files_from_list
    fi

    print_main_heading "show tech-support optics complete"
}

. /pkg/bin/show_tech_file_fragment

