1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#
# ConVirt - Copyright (c) 2008 Convirture Corp.
# ======
#
# ConVirt is a Virtualization management tool with a graphical user
# interface that allows for performing the standard set of VM operations
# (start, stop, pause, kill, shutdown, reboot, snapshot, etc...). It
# also attempts to simplify various aspects of VM lifecycle management.
#
#
# This software is subject to the GNU General Public License, Version 2 (GPLv2)
# and for details, please consult it at:
#
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#
#
# author : mkelkar@users.sourceforge.net
#
# Contains utility functions used at many places.
# Mostly distro and virtualization platform independent stuff.
function check_prerequisite {
if [ "" != "$1" ]; then
is_dameon_installed=`ps -ef | grep "${1}" | grep -v grep`
if [ "$is_dameon_installed" == "" ]; then
echo "ERROR:The ${1} dameon is not running"
exit 1
fi
fi
is_cmd_installed=`which ${2} 2>/dev/null`
if [ $? != 0 ]; then
echo "ERROR:The ${2} is not installed"
exit 1
fi
}
function check_function_return_value {
if [ $? != 0 ]; then
echo "ERROR:$1"
exit 1
fi
}
function parse_field_values {
#echo $1 $2 $3
if [ "$1" != "" ] && [ "$2" != "" ]; then
for nameValue in `echo $1 | xargs -d'|'`
do
if echo "$nameValue" | grep $2 >/dev/null
then
value=`echo $nameValue | cut -d'=' -f2`
fi
done
fi
}
function isRequiedParamPresent {
if [ "${1}" == "" ]; then
echo "ERROR:The required parameter ${2} is missing."
exit 1
fi
}
|