#!/pkg/bin/ksh
#
# Panchalingesh Konannavar, October 2007.
#
# Copyright (c) 2007-2008, 2017, 2020-2021 by cisco Systems, Inc.
# All rights reserved.
#----------------------------------------------------------------------

# This script fragment contains the code for the following functions
# - print_main_heading
# - print_command_heading
# - run_single_command
# - run_commands
# - run_single_command_on_all_nodes
# - run_commands_on_all_nodes
# - default_parser_function

. /pkg/bin/show_tech_main_fragment

# Initialise any variables used.
location=""

# Read in the arguments to the script, setting node_required and filename
# 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
     -L) location="location $2"; all_cards="location $2"; shift 2;;
     *)  default_parser_function "$@"; shift $#;;
  esac
done

# List each set of show commands to be 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; showtech infra expects the command
# exactly the way it was entered.
# Use "\" ahead of any special character (eg. |) used in the command line.
commandCommon[0]='show l2vpn bridge-domain summary'
commandCommon[1]='show l2vpn bridge-domain private'
commandCommon[2]='show l2vpn bridge-domain hardware'
commandCommon[3]=''

# Commands for All Nodes
commandAllNodes[0]='show l2vpn forwarding bridge-domain private no-statistics location $location'
commandAllNodes[1]='show l2vpn forwarding bridge-domain mac-address private location $location'
commandAllNodes[2]='show l2vpn forwarding bridge-domain mac-address internal private location $location'
commandAllNodes[3]='show l2vpn forwarding bridge-domain mac-address aging location $location'
commandAllNodes[4]='show l2vpn forwarding retry-list location $location'
commandAllNodes[5]=''

# A function called display() must be provided that calls the functions to 
# run the required show commands.

display() {
    # Print the output heading 
    print_main_heading "show tech-support l2vpn bridging"
     
    # Execute commands
    run_commands Common
    run_commands_on_all_nodes AllNodes

    # call platform-specific script
    vpls_show_tech_platform
    
    # Print the closing heading. 
    print_main_heading "show tech-support l2vpn bridging complete"
}

. /pkg/bin/show_tech_file_fragment
