#!/bin/bash 
#
#    Copyright (c) 2018-2019 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    Description:
#
#    This BSL CLI script will be run as part of the BSL inventory 
#    collection. It collects the list of chassis and VF based CLI command outputs.


file=$1
vfId=$2
lsId=$3

maxHr=24
swCmdMapsHr=("mapsdb --show congestion -state -hr")
swCmdList=("secpolicydump" "mapsdb --show congestion -freq" "aptpolicy" "topologyshow -1" "fcrconfigure --show" "fcrconfigure --show -alias" "fcredgeshow" "fcrfabricshow" "fcrresourceshow" "fcrrouterportcost" "fcrrouteshow" "ficonshow rnid" "ficonshow lirr" "ficonshow rlir" "ficoncupshow fmsmode");

chassisCmdList=("timeout" "lfcfg --showall -cfg" "lfcfg --showall -lisl -v" "lfcfg --showall -xisl" "apploginhistory --show" "historyshow");

#Switch commands 
count=${#swCmdList[@]}
for (( i = 0; i < $count; i++ ))
	do 
		${swCmdList[$i]} > "$file/${swCmdList[$i]}.$vfId.cli"
	done

#Switch maps hour commands
for (( j = 0; j < $maxHr; j++ ))
	do 
		${swCmdMapsHr[0]} $j >> "$file/${swCmdMapsHr[0]}.$vfId.cli"
	done

#Chassis commands
count=${#chassisCmdList[@]}
for (( i = 0; i < $count; i++ ))
	do 
		if [ $lsId -eq 0 ]; then
			${chassisCmdList[$i]} > "$file/${chassisCmdList[$i]}.cli"
		fi	
	done
