|
Packit |
857059 |
#!/bin/bash
|
|
Packit |
857059 |
# BEGIN_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Copyright (c) 2015-2017, Intel Corporation
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
# modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
# this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
# notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
# documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
# * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
# may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
# without specific prior written permission.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# END_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# [ICS VERSION STRING: unknown]
|
|
Packit |
857059 |
|
|
Packit |
857059 |
TEMP1="$(mktemp)"
|
|
Packit |
857059 |
TEMP2="$(mktemp)"
|
|
Packit |
857059 |
PROG_NAME=$0
|
|
Packit |
857059 |
trap "rm -f $TEMP1 $TEMP2; exit 1" SIGHUP SIGTERM SIGINT
|
|
Packit |
857059 |
trap "rm -f $TEMP1 $TEMP2" EXIT
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Usage()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
echo "Usage: $(basename $PROG_NAME) [-f][-l] [-d 'diff_args'] file1 file2" >&2
|
|
Packit |
857059 |
echo " or $(basename $PROG_NAME) --help" >&2
|
|
Packit |
857059 |
echo " " >&2
|
|
Packit |
857059 |
echo " --help - produce full help text" >&2
|
|
Packit |
857059 |
echo " -f - filter out FM parameters which are not part of consistency check" >&2
|
|
Packit |
857059 |
echo " Removes config tags that do not cause consistency checks on the" >&2
|
|
Packit |
857059 |
echo " FM to fail from diff" >&2
|
|
Packit |
857059 |
echo " -l - include comments in XML to indicate original line numbers" >&2
|
|
Packit |
857059 |
echo " -d 'diff_args' - additional arguments to diff command" >&2
|
|
Packit |
857059 |
echo " e.g. -uw for unified format ignoring whitespace." >&2
|
|
Packit |
857059 |
echo " " >&2
|
|
Packit |
857059 |
exit 2
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Usage_full()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
echo "Usage: $(basename $PROG_NAME) [-f][-l] [-d 'diff_args'] file1 file2" >&2
|
|
Packit |
857059 |
echo " or $(basename $PROG_NAME) --help" >&2
|
|
Packit |
857059 |
echo " " >&2
|
|
Packit |
857059 |
echo " --help - produce full help text" >&2
|
|
Packit |
857059 |
echo " -f - filter out FM parameters which are not part of consistency check" >&2
|
|
Packit |
857059 |
echo " Removes config tags that do not cause consistency checks on the" >&2
|
|
Packit |
857059 |
echo " FM to fail from diff" >&2
|
|
Packit |
857059 |
echo " -l - include comments in XML to indicate original line numbers" >&2
|
|
Packit |
857059 |
echo " -d 'diff_args' - additional arguments to diff command" >&2
|
|
Packit |
857059 |
echo " e.g. -uw for unified format ignoring whitespace." >&2
|
|
Packit |
857059 |
echo " " >&2
|
|
Packit |
857059 |
echo "$(basename $PROG_NAME) performs a difference between two config files corresponding" >&2
|
|
Packit |
857059 |
echo "to two FM instances described by file1 and file2" >&2
|
|
Packit |
857059 |
echo " " >&2
|
|
Packit |
857059 |
echo "Examples:" >&2
|
|
Packit |
857059 |
echo " $(basename $PROG_NAME) /etc/opa-fm/opafm.xml /usr/share/opa-fm/opafm.xml" >&2
|
|
Packit |
857059 |
echo " $(basename $PROG_NAME) -f /etc/opa-fm/opafm.xml /usr/share/opa-fm/opafm.xml" >&2
|
|
Packit |
857059 |
echo " $(basename $PROG_NAME) -d -uw /etc/opa-fm/opafm.xml /usr/share/opa-fm/opafm.xml" >&2
|
|
Packit |
857059 |
exit 0
|
|
Packit |
857059 |
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Main function
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ x"$1" = "x--help" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
Usage_full
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IFS_FM_BASE=/usr/lib/opa-fm
|
|
Packit |
857059 |
tooldir=$IFS_FM_BASE/bin
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ x"$1" = "x--help" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
filter=n
|
|
Packit |
857059 |
filter_args=
|
|
Packit |
857059 |
diff_args=
|
|
Packit |
857059 |
while getopts fld: param
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
case $param in
|
|
Packit |
857059 |
f) filter=y;;
|
|
Packit |
857059 |
l) filter_args="$filter_args -l";;
|
|
Packit |
857059 |
d) diff_args="$diff_args $OPTARG";;
|
|
Packit |
857059 |
?) Usage;;
|
|
Packit |
857059 |
esac
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
shift $((OPTIND -1))
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $# -lt 2 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
file1=$1
|
|
Packit |
857059 |
file2=$2
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ ! -e $file1 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "$file1: Not Found" >&2
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
if [ ! -e $file2 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "$file2: Not Found" >&2
|
|
Packit |
857059 |
Usage
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ x"$filter" = xy ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
filter_args="$filter_args -s Start -s Hca -s Port -s Debug -s RmppDebug -s Priority -s ElevatedPriority -s LogLevel -s LogFile -s LogMode -s SyslogFacility
|
|
Packit |
857059 |
-s *_LogMask -s Name -s PortGUID -s Sm.TrapLogSuppressTriggerInterval -s Sm.SmPerfDebug -s Sm.SaPerfDebug -s Sm.DebugDor -s Sm.DebugVf -s Sm.DebugJm -s Sm.DebugLidAssign -s Sm.LoopTestOn -s Sm.LoopTestPacket -s Sm.LID -s Sm.DynamicPortAlloc -s Sm.SaRmppChecksum -s Pm.ThresholdsExceededMsgLimit -s Pm.SweepErrorsLogThreshold -s Bm.DebugFlag -s Fe.TcpPort"
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
$tooldir/opafmxmlfilter -i 4 $filter_args $file1 > $TEMP1
|
|
Packit |
857059 |
[ $? != 0 ] && exit 1
|
|
Packit |
857059 |
|
|
Packit |
857059 |
$tooldir/opafmxmlfilter -i 4 $filter_args $file2 > $TEMP2
|
|
Packit |
857059 |
[ $? != 0 ] && exit 1
|
|
Packit |
857059 |
|
|
Packit |
857059 |
diff $diff_args $TEMP1 $TEMP2
|
|
Packit |
857059 |
res=$?
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rm -f $TEMP1 $TEMP
|
|
Packit |
857059 |
exit $res
|