#!/bin/bash
# BEGIN_ICS_COPYRIGHT8 ****************************************
# INTEL CONFIDENTIAL
# Copyright (c) 2008-2012  Intel Corporation All Rights Reserved.
# The source code contained or described herein and all documents related
# to the source code ("Material") are owned by Intel Corporation or its
# suppliers or licensors. Title to the Material remains with Intel Corporation
# or its suppliers and licensors. The Material contains trade secrets and
# proprietary and confidential information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright and trade
# secret laws and treaty provisions. No part of the Material may be used,
# copied, reproduced, modified, published, uploaded, posted, transmitted,
# distributed, or disclosed in any way without Intel's prior express
# written permission.
#
# No license under any patent, copyright, trade secret or other intellectual
# property right is granted to or conferred upon you by disclosure or delivery
# of the Materials, either expressly, by implication, inducement, estoppel or
# otherwise. Any license under such intellectual property rights must be
# express and approved by Intel in writing.
# END_ICS_COPYRIGHT8   ****************************************

# [ICS VERSION STRING: @(#) ./bin/iba_manage_switch 7_4_3_0_2 [01/26/18 09:02]

cmdName=iba_manage_switch

captureCapable=n

resultsFile=$PWD/iba_manage_switch.res

# Functions

# checkCapture

checkCapture()
{
	if [ -x $bindir/xedge_capture ]
	then
		captureCapable=y
	fi
}

# Usage

Usage()
{
    if [ $captureCapable = y ]
	then
	echo "Usage: $cmdName -t target-guid [-H] [-v] [-h hca] [-p port] [ -x] [-S] [ -f fileName] [-r] [-C configOption] [-i integer-value] [-s string-value] [-c captureFile] operation"
#	echo "Usage: $cmdName -t target-guid [-H] [-v] [-h hca] [-p port] [ -x] [-S] [ -f fileName] [-r] [-C configOption] [-i integer-value] [-s string-value] [ -F ] [-c captureFile] operation"
	else
	echo "Usage: $cmdName -t target-guid [-H] [-v] [-h hca] [-p port] [ -x] [-S] [ -f fileName] [-r] [-C configOption] [-i integer-value] [-s string-value] operation"
#	echo "Usage: $cmdName -t target-guid [-H] [-v] [-h hca] [-p port] [ -x] [-S] [ -f fileName] [-r] [-C configOption] [-i integer-value] [-s string-value] [ -F ] operation"
	fi
	echo "         -H - help (this message)"
	echo "         -v - verbose - additional output"
	echo "         -t - guid of target switch in hex format, e.g. 0x00066a00e3001234"
	echo "         -h - hca number, default is first HCA"
	echo "         -p - port number, default is first active port"
	echo "         -x - clobber previous results file"
	echo "         -S - enforce password, will be prompted for each subcommand"
	echo "         -f - fileName of the emfw file to be used in fwUpdate operation - must be a valid emfw file with .emfw suffix"
	echo "         -r - reset switch after fwUpdate (only valid with fwUpdate operation)"
	echo "         -C - configuration option for setConfigValue operation"
	echo "              mtucap - mtu capability - use -i for integer value (4-2048, 5-4096)"
	echo "              vlcap - vl capability - use -i for integer value (1-1VL, 2-2VLs, 3-4VLs, 4-8VLs, 5-15VLs)"
	echo "              linkwidth - link width supported - use -i for integer value (1-1X, 2-4X, 3-1X/4X, 4-8X, 5-1X/8X, 6-4X/8X, 7-1X/4X/8X)"
	echo "              vlcreditdist - VL credit distribution - use -i for integer value (0, 1, 2, 3, or 4)"
	echo "              linkspeed - link speed supported - use -i for integer value (1-SDR, 2-DDR, 3-SDR/DDR, 4-QDR, 7-SDR/DDR/QDR)"
	echo "         -i - integer value"
	echo "         -s - string value"
    if [ $captureCapable = y ]
	then
	echo "         -c - filename of capture output file"
	fi
#	echo "         -F - perform fwUpdate operation on secondary (failsafe) EEPROM"
	echo "         operation:"
	echo "            fwUpdate - perform firmware update using fileName parameter, must be an emfw file"
	echo "            fwVerify - perform firmware validation - validate firmware in primary/secondary EEPROMs, report which was booted"
	echo "            ping - test for switch presence"
	echo "            reboot - reboot switch"
	echo "            setConfigValue - update configuration value - use -C for config option and -i for integer value"
	echo "            setIBNodeDesc - set the IB node description - use -s for string value of node desc"
	echo "            setPassword - set the vendor key (prompts for password to be used for subsequent switch access)"
	echo "            showConfig - report user-configurable settings"
	echo "            showFwVersion - report firmware version running on switch"
	echo "            showPowerCooling - report status of power supplies and fans"
    if [ $captureCapable = y ]
	then
	echo "            capture - perform capture of switch"
	fi
	echo "            showVPD - report VPD information of switch"
#	echo "            compareEEPROM - compare EEPROMs"
	echo ""
	echo "         Examples:"
	echo "            iba_manage_switch -t 0x00066a00e3001234 -f Intel_12000_V1_firmware.7.2.0.0.32.emfw fwUpdate"
	echo "            iba_manage_switch -t 0x00066a00e3001234 reboot"
	echo "            iba_manage_switch -t 0x00066a00e3001234 showFwVersion"
	echo "            iba_manage_switch -t 0x00066a00e3001234 -s i12k1234 setIBNodeDesc"
	echo "            iba_manage_switch -t 0x00066a00e3001234 -C mtucap -i 4 setConfigValue"
	echo "            iba_manage_switch -H"
	echo ""
	echo "         Results are recorded in iba_manage_switch.res file in the current directory - use -x option to clobber and create anew"

	exit 1
}

# UsageWarn

UsageWarn()
{
	echo "Enter 'iba_manage_switch -H' for help"
	exit 1
}

# Log results

logResults()
{
	cat $1 >> $resultsFile
}

# Check exit

check_exit()
{
	status=$1
	file=$2
	if [ $status -ne 0 ]
	then
		if [ "$file" != "" ]
		then
			grep -i error $file
			grep mismatch $file
			logResults $file
			rm -f $file
		fi
		exit 1
	fi
}

# Execute command

execCommand()
{
	echo Executing $cmd $args >> $resultsFile
	if [ "$verboseArg" != "-v" -a "$teeOut" != "yes" ]
	then
		$cmd $args > $tmpFile 2>&1
	else
		$cmd $args | grep -v completed | tee $tmpFile 2>&1
	fi
}

# Get module type

getModType()
{
	cmd=$bindir/xedge_query
	args="-t $target $hcaPortArgs $pswdArg $verboseArg $quietArg -Q 1"
	tmpFile=.query
	execCommand
	check_exit $? .query
	t=`grep type .query | cut -d ' ' -f 4`
	if [ $t = XEDGE ]
	then
		t1=1
	else
		t1=2
	fi
	logResults .query
	rm -f .query
	return $t1
}

# Get board id

getBoardID()
{
	cmd=$bindir/xedge_query
	args="-t $target $hcaPortArgs $pswdArg $verboseArg $quietArg -Q 12"
	tmpFile=.query
	execCommand
	check_exit $? .query
	boardID=`grep BoardID .query | cut -d ' ' -f 2`
	logResults .query
	rm -f .query
	return 0
}


pswdArg=
fileNameArg=
hcaArg=
portArg=
failSafeArg=
resetArg=
configOptArg=
integerArg=
stringArg=
captureOutArg=
clobberArg=
helpArg=
verboseArg=
quietArg=
teeOut=

options='C:Ff:Hh:i:p:rSs:t:c:vx'
bindir=/opt/iba/ib_tools

checkCapture

while getopts "$options" param
do
	case $param in
	c)
		captureOutArg="$OPTARG";;
	C)
		configOptArg="$OPTARG";;
	F)
		failSafeArg=-F;;
	f)
		fileNameArg="$OPTARG";;
	H)
		helpArg="help";;
	h)
		hcaArg="-h $OPTARG";;
	i)
		integerArg="$OPTARG";;
	p)
		portArg="-o $OPTARG";;
	r)
		resetArg="-S";;
	S)
		pswdArg=-K;;
	s)
		stringArg="$OPTARG";;
	t)
		target="$OPTARG";;
	v)
		verboseArg=-v;;
	x)
		clobberArg=1;;
	?)
		Usage;;
	esac
done
shift $((OPTIND -1))

if [ "$helpArg" == "help" ]
then
	Usage
fi

numParams=$#
if [ $numParams -gt 1 ]
then
	echo "Error: only one operation allowed"
	UsageWarn
fi

operation=$1

if [ "$operation" = "" ]
then
	echo "Must provide an operation"
	UsageWarn
fi

if [ "$target" = "" ]
then
	echo "Must provide a target guid"
	UsageWarn
fi

if [ $captureCapable != y -a "$operation" == "capture" ]
then
	echo "Capture operation is not available"
	UsageWarn
fi

if [ "$fileNameArg" != "" -a "$operation" != "fwUpdate" ]
then
	echo "Filename parameter is only valid for fwUpdate operation"
	UsageWarn
fi

if [ "$configOptArg" != "" -a "$operation" != "setConfigValue" ]
then
	echo "configOption parameter is only valid for configure operation"
	UsageWarn
fi

if [ "$captureOutArg" != "" -a "$operation" != "capture" ]
then
	if [ $captureCapable != y ]
	then
		echo "Capture operation is not available"
	else
		echo "Capture outfile parameter is only valid for capture operation"
	fi
	UsageWarn
fi

if [ "$clobberArg" = "1" ]
then
	> $resultsFile
else
	echo "" >> $resultsFile
fi
echo "********************" >> $resultsFile
date >> $resultsFile
echo Beginning operation: $operation >> $resultsFile
echo "********************" >> $resultsFile

if [ "$pswdArg" != "" ]
then
	# prompt for password
	echo -n "Enter password:" > /dev/tty
	stty -echo < /dev/tty > /dev/tty
	xedge_password=
	read xedge_password < /dev/tty
	stty echo < /dev/tty > /dev/tty
	echo > /dev/tty
	export xedge_password
fi

if [ "$verboseArg" != "-v" ]
then
	quietArg=-q
else
	quietArg=
fi

case $operation in
capture)
	if [ "$captureOutArg" = "" ]
	then
		echo "Must provide a capture outfile parameter for capture operation"
		UsageWarn
	fi
	quietArg=
	echo "Performing switch capture..."
	cmd=$bindir/xedge_capture
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $captureOutArg"
	tmpFile=.cap
	teeOut=yes
	execCommand
	check_exit $? .cap
	logResults .cap
	rm -f .cap
	;;
fwUpdate)
	# must have a filename parameter
	if [ "$fileNameArg" = "" ]
	then
		echo "Must provide a fileName parameter for fwUpdate operation"
		UsageWarn
	fi

	# verify filename is for V1 silicon
	echo $fileNameArg | grep -i V1 > /dev/null 2>&1
	if [ $? -ne 0 ]
	then
		echo "$fileNameArg does not appear to be a V1 silicon emfw file"
		UsageWarn
	fi

	# verify filename is emfw
	sfx=`echo $fileNameArg |  awk -F . '{print $NF}'`
	if [ "$sfx" != "emfw" ]
	then
		# maybe prompt then to continue??
		echo "Filename parameter must be an emfw file"
		UsageWarn
	fi

	# verify file format
	tar tzf $fileNameArg > /dev/null 2>&1
	if [ $? -ne 0 ]
	then
		echo "File $fileNameArg has invalid format"
		UsageWarn
	fi

	# get the module type and boardID of the switch
	getModType
	modType=$?
	getBoardID

	# create a directory and untar the emfw
	c=`echo $fileNameArg | cut -b 1`
	if [ "$c" != "/" ]
	then
		thisdir=`pwd`
		fn=$thisdir/$fileNameArg
	else
		fn=$fileNameArg
	fi
	tmpdir=/tmp/12200FW$$
	mkdir $tmpdir
	cd $tmpdir
	tar xzf $fn > /dev/null 2>&1

	# set names
	if [ -f emfwMapFile ]
	then
		binName=`grep $boardID emfwMapFile | cut -d ' ' -f 2`
		if [ $modType -eq 1 ]
		then
			inibinName=`grep $boardID emfwMapFile | cut -d ' ' -f 3`
		else
			inibinName=iniViper.inibin
		fi
	else
		# no emfwMapFile - use standard f/w and xedge/viper inibin
		binName=s20fwV1_fw.bin
		if [ $modType -eq 1 ]
		then
			inibinName=iniXedge.inibin
		else
			inibinName=iniViper.inibin
		fi
	fi

	# do fwconfigure and fwupdate
	echo Updating config block...
	cmd=$bindir/xedge_fwconfigure
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -m $modType -f $inibinName $failSafeArg"
	tmpFile=.fw
	execCommand
	check_exit $? .fw
	logResults .fw
	rm -f .fw
	export xedge_save_password=$xedge_password
	cmd=$bindir/xedge_configure
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -C 2 -S"
	tmpFile=.pswd
	execCommand
	check_exit $?
	logResults .pswd
	rm -f .pswd
	echo Updating firmware...
	cmd=$bindir/xedge_fwupdate
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -m $modType -f $binName $resetArg $failSafeArg"
	tmpFile=.fw
	execCommand
	check_exit $? .fw
	logResults .fw
	if [ "$verboseArg" != "-v" ]
	then
		grep Verification .fw
		grep Resetting .fw
	fi
	rm -f .fw
	cd $thisdir
	rm -rf $tmpdir
	;;
fwVerify)
	echo -n "Validating firmware in primary EEPROM...     "
	cmd=$bindir/xedge_fwverify
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target"
	tmpFile=.fwv
	execCommand
	check_exit $? .fwv
	validity=`grep found .fwv | cut -d ' ' -f 2`
	logResults .fwv
	echo "Primary image is $validity"
	echo " "
	echo -n "Validating firmware in secondary EEPROM...   "
	cmd=$bindir/xedge_fwverify
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -F"
	tmpFile=.fwv
	execCommand
	check_exit $? .fwv
	validity=`grep found .fwv | cut -d ' ' -f 2`
	logResults .fwv
	echo "Secondary image is $validity"
	echo " "
	echo -n "Checking boot EEPROM ...                     "
	cmd=$bindir/xedge_query
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 2"
	tmpFile=.fwv
	execCommand
	check_exit $? .fwv
	booteeprom=`grep booted .fwv | cut -d ' ' -f 5`
	echo "Switch has booted from $booteeprom EEPROM"
	logResults .fwv
	rm -f .fwv
	;;
ping)
	cmd=$bindir/xedge_ping
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target"
	tmpFile=.png
	execCommand
	grep present .png > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		grep present .png | grep not > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			echo "Unit is not present"
		else
			echo "Unit is present"
		fi
	else
		echo "Unit is not present"
	fi
	logResults .png
	rm .png
	;;
reboot)
	echo "Resetting switch..."
	cmd=$bindir/xedge_swreset
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target"
	tmpFile=.res
	execCommand
	check_exit $? .res
	logResults .res
	rm -f .res
	;;
setConfigValue)
	intOpt=
	cfgOpt=
	if [ "$configOptArg" = "" ]
	then
		echo "Must provide a configOption parameter for setConfigValue operation"
		UsageWarn
	fi
	if [ "$integerArg" = "" ]
	then
		echo "Must provide an integer parameter for setConfigValue operation"
		UsageWarn
	fi
	intOpt="-i $integerArg"
	cmd=$bindir/xedge_configure
	tmpFile=.cfg
	case $configOptArg in
	mtucap)
		cfgOpt="-C 3"
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $cfgOpt $intOpt -S"
		execCommand
		grep Error .cfg > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
			logResults .cfg
			rm -f .cfg
			exit 1
		fi
		logResults .cfg
		rm -f .cfg
		;;
	vlcap)
		cfgOpt="-C 4"
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $cfgOpt $intOpt -S"
		execCommand
		grep Error .cfg > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
			logResults .cfg
			rm -f .cfg
			exit 1
		fi
		logResults .cfg
		rm -f .cfg
		;;
	linkwidth)
		cfgOpt="-C 5"
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $cfgOpt $intOpt -S"
		execCommand
		grep Error .cfg > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
			logResults .cfg
			rm -f .cfg
			exit 1
		fi
		logResults .cfg
		rm -f .cfg
		;;
	vlcreditdist)
		cfgOpt="-C 6"
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $cfgOpt $intOpt -S"
		execCommand
		grep Error .cfg > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
			logResults .cfg
			rm -f .cfg
			exit 1
		fi
		logResults .cfg
		rm -f .cfg
		;;
	linkspeed)
		cfgOpt="-C 7"
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target $cfgOpt $intOpt -S"
		execCommand
		grep Error .cfg > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
			logResults .cfg
			rm -f .cfg
			exit 1
		fi
		logResults .cfg
		rm -f .cfg
		;;
	*)
		echo "Invalid configOption parameter $configOptArg"
		UsageWarn
		;;
	esac
	intVal=`echo $intOpt | cut -d ' ' -f 2`
	echo Successfully set $configOptArg to $intVal
	;;
setIBNodeDesc)
	strOpt=
	if [ "$stringArg" = "" ]
	then
		echo "Must include a string value for setIBNodeDesc operation"
		UsageWarn
	fi
	if [ "$integerArg" != "" ]
	then
		echo "Integer value is not valid with setIBNodeDesc operation"
		UsageWarn
	fi
	strOpt="-s $stringArg"
	cmd=$bindir/xedge_configure
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -C 1 $strOpt -S"
	tmpFile=.cfg
	execCommand
	check_exit $? .cfg
	grep Error .cfg > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		grep Error .cfg | cut -d ':' -f 2- | cut -d ' ' -f 2-
		logResults .cfg
		rm -f .cfg
		exit 1
	fi
	logResults .cfg
	rm -f .cfg
	;;
setPassword)
	if [ "$stringArg" != "" -o "$integerArg" != "" ]
	then
		echo "String or integer parameter not valid with setPassword operation"
		UsageWarn
	fi
	cmd=$bindir/xedge_configure
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -C 2 -S"
	tmpFile=.pswd
	teeOut=yes
	execCommand
	check_exit $?
	logResults .pswd
	rm -f .pswd
	;;
showConfig)
	echo "Reporting user-configurable settings..."
	cmd=$bindir/xedge_query
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 11"
	tmpFile=.query
	teeOut=yes
	execCommand
	check_exit $?
	logResults .query
	rm -f .query
	;;
showFwVersion)
	cmd=$bindir/xedge_query
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 3"
	tmpFile=.fwv
	execCommand
	check_exit $? .fwv
	fwversion=`grep Version .fwv | cut -d ' ' -f 4`
	echo "Firmware version is $fwversion"
	logResults .fwv
	rm -f .fwv
	;;
showPowerCooling)
	echo "Reporting power and cooling status..."

	# middle digit of part number tells how many PS
	cmd=$bindir/xedge_query
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 4"
	tmpFile=.pwc
	execCommand
	check_exit $? .pwc
	prtno=`grep VPD .pwc | cut -d ',' -f 2`
	psIndicator=`echo $prtno | cut -d '-' -f 2 | awk '{ print substr( $0, 2, 1 ) }'`
	case $psIndicator in
	0)
		numPS=1
		;;
	1)
		numPS=2
		;;
	*)
		numPS=1
		;;
	esac
	logResults .pwc
	getBoardID

	cmd=$bindir/xedge_query
	tmpFile=.pwc
	if [ "$boardID" != "0x13" ]
	then
		args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 7 -i 1"
		execCommand
		check_exit $? .pwc
		fan1_0stat=`grep FAN .pwc |cut -d ':' -f 2 | cut -d ' ' -f 1`
		fan1_1stat=`grep FAN .pwc |cut -d ':' -f 3`
		logResults .pwc
	else
		fan1_0stat="N/A   "
		fan1_1stat="N/A"
	fi
	args="$bindir/xedge_query $pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 7 -i 2"
	execCommand
	check_exit $? .pwc
	logResults .pwc
	fan2_0stat=`grep FAN .pwc |cut -d ':' -f 2 | cut -d ' ' -f 1`
	fan2_1stat=`grep FAN .pwc |cut -d ':' -f 3`
	if [ $numPS -eq 2 ]
	then
		args="$bindir/xedge_query $pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 8 -i 1"
		execCommand
		check_exit $? .pwc
		ps1stat=`grep PS .pwc | cut -d ' ' -f 3`
		logResults .pwc
	else
		ps1stat="N/A"
	fi
	args="$bindir/xedge_query $pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 8 -i 2"
	execCommand
	check_exit $? .pwc
	ps2stat=`grep PS .pwc | cut -d ' ' -f 3`
	echo "Fan status: Fan 1/0: $fan1_0stat    Fan 1/1: $fan1_1stat"
	echo "Fan status: Fan 2/0: $fan2_0stat    Fan 2/1: $fan2_1stat"
	echo "PS status : PS1    : $ps1stat       PS2    : $ps2stat"
	logResults .pwc
	rm -f .pwc
	;;
showVPD)
	echo "Reporting switch VPD info..."
	cmd=$bindir/xedge_query
	args="$bindir/xedge_query $pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -Q 4"
	tmpFile=.vpd
	execCommand
	check_exit $? .vpd
	serno=`grep VPD .vpd | cut -d ' ' -f 2 | cut -d ',' -f 1`
	prtno=`grep VPD .vpd | cut -d ',' -f 2`
	model=`grep VPD .vpd | cut -d ',' -f 3`
	hwver=`grep VPD .vpd | cut -d ',' -f 4`
	mfgnm=`grep VPD .vpd | cut -d ',' -f 5`
	prdnm=`grep VPD .vpd | cut -d ',' -f 6`
	mfgid=`grep VPD .vpd | cut -d ',' -f 7`
	mfgdt=`grep VPD .vpd | cut -d ',' -f 8`
	mfgtm=`grep VPD .vpd | cut -d ',' -f 9`
	echo "   Serial Number :    $serno"
	echo "   Part Number   :    $prtno"
	echo "   Model         :    $model"
	echo "   H/W Version   :    $hwver"
	echo "   Mfg Name      :    $mfgnm"
	echo "   Product Name  :    $prdnm"
	echo "   Mfg ID        :    $mfgid"
	echo "   Mfg Date      :    $mfgdt"
	echo "   Mfg Time      :    $mfgtm"
	logResults .vpd
	rm -f .vpd
	;;
compareEEPROM)
	echo "Comparing switch EEPROMs..."
	cmd=$bindir/xedge_fwverify
	args="$pswdArg $verboseArg $quietArg $hcaArg $portArg -t $target -C"
	tmpFile=.fwv
	execCommand
	check_exit $? .fwv
	match=`grep CRC .fwv | cut -d ' ' -f 3`
	if [ "$match" = "match" ]
	then
		echo "Switch EEPROMs match"
	else
		echo "Switch EEPROMs do not match"
	fi
	logResults .fwv
	rm -f .fwv
	;;
*)
	echo "$operation is not a valid operation"
	UsageWarn
esac

exit 0
