#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# ospf_show_tech_routes - OSPF show tech-support routes script
#
# Feb 2017 - Manish Kumar 
# Copyright (c) 2017-2018 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

### Required by show_tech
. /pkg/bin/show_tech_main_fragment


### List the sets of show commands to run. Each set must finish with
### an empty string. Note that it is important to use single quotes
### rather than double quotes for the strings containing your commands.

    index=1
## Command set 1 - configuration & other basic info
### Variable initialization
standby=""
rp_role="active"
process_name=""
process_args="+"
__cardtype="unspecified"
showtech_argv="" 
showtech_argc="0"
skip_active="0"
skip_standby="0"
# Read in the arguments to the script, setting mode
# according to these arguments.
# Note that it is important for security reasons that users can only enter
# alphanumeric filenames and nodes and that anywhere calling this script must
# enforce this.
  
while [ $# -gt 0 ]; do
  case "$1" in
     -P) process_name="$2"; shift 2;;
     -SA) skip_active=1; shift 1;;
     -SS) skip_standby=1; shift 1;;
     -t) __cardtype="$2"; shift 2;;
      *)  showtech_argv="$showtech_argv $1"; (( showtech_argc+=1 )); shift 1;;
    esac
  done
  
## Command set 2 - ospf commands

    ospf_exec[$index]="show ospfv3 $process_name routes"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v + -L active"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name routes external"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v + -L active -e 0x1"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name routes backup-path"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v + -L active -b"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name routes summary"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v + -L active -s"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name vrf all routes"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v all -L active"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name vrf all routes external"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v all -L active -e 0x1"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name vrf all routes backup-path"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v all -L active -b"
    index=$((index + 1))

    ospf_exec[$index]="show ospfv3 $process_name vrf all routes summary"
	ospf__ksh[$index]="ospfv3_show_top -T $process_args -v all -L active -s"
    index=$((index + 1))

    ospf_exec[$index]=""
    ospf__ksh[$index]=""
    index=1
  
 
#
# Call the showtech infra default parser - using set to recreate the $#, $@,
# etc. - "--" is necessary so set doesn"t try to interpret any of the
# arguments we are passing through
#
if [[ $showtech_argc -ne 0 ]]; then
  set -- $showtech_argv
  default_parser_function $@
fi
 
if [ "$__cardtype" == "unspecified" ]; then
  __cardtype=`node_type`
fi
  
### display - run the show commands
### MUST be named display.
### Called by show_tech_file_fragment().
display() {
 
   # Print the output heading
   print_main_heading "show tech-support routing ospfv3 routes"
 
   if [ "$__cardtype" == "SYS" ]; then
           exec_commands ospf
 
   fi    
      
       # Print the closing heading. 
       print_main_heading "show tech-support routing ospfv3 routes"
  }
  
### This mandatory bit calls display() and handles output redirection.
. /pkg/bin/show_tech_file_fragment
 
