1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #575: Added error messages to vmm scripts

This commit is contained in:
Javi Fontan 2011-04-26 21:08:15 +02:00
parent 9c0fcc9702
commit 9ddf1b5f28
12 changed files with 102 additions and 3 deletions

View File

@ -17,7 +17,17 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
virsh --connect $LIBVIRT_URI destroy $deploy_id
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not destroy $deploy_id"
exit $error_code
fi

View File

@ -17,6 +17,7 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
domain=$1
@ -28,5 +29,6 @@ data=`virsh --connect $LIBVIRT_URI create $domain`
if [ "x$?" = "x0" ]; then
echo $data | sed 's/Domain //' | sed 's/ created from .*$//'
else
error_message "Could not create domain from $domain"
exit -1
fi

View File

@ -17,8 +17,18 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
dest_host=$2
virsh --connect $LIBVIRT_URI migrate --live $deploy_id $QEMU_PROTOCOL://$dest_host/system
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not migrate $deploy_id to $dest_host"
exit $error_code
fi

View File

@ -17,7 +17,17 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
file=$1
virsh --connect $LIBVIRT_URI restore $file
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not restore from $file"
exit $error_code
fi

View File

@ -17,6 +17,7 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
file=$2
@ -27,3 +28,12 @@ if [ ! -f $file ]; then
fi
virsh --connect $LIBVIRT_URI save $deploy_id $file
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not save $deploy_id to $file"
exit $error_code
fi

View File

@ -17,6 +17,7 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
#------------------------------------------------------------------------------
# Wait the VM to shutdown TIMEOUT (xPOLL_INTERVAL) seconds.
@ -32,6 +33,7 @@ virsh --connect $LIBVIRT_URI shutdown $deploy_id
exit_code=$?
if [ "$exit_code" != "0" ]; then
error_message "Could not shutdown $deploy_id"
exit $exit_code
fi
@ -41,6 +43,7 @@ do
sleep $POLL_INTERVAL
if [ "$count" -gt "$TIMEOUT" ]
then
error_message "Timeout reached and VM $deploy_id is still alive"
echo "Timeout reached" >&2
exit 1
fi

View File

@ -17,7 +17,17 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
$XM_CANCEL $deploy_id
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not destroy $deploy_id"
exit $error_code
fi

View File

@ -17,10 +17,13 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
function error_exit() {
exit_code=$1
message=$2
if [ "x$exit_code" != "x0" ]; then
error_message $message
exit $exit_code
fi
}
@ -32,7 +35,7 @@ cat > $domain
output=`$XM_CREATE $domain`
error_exit $?
error_exit $? "Unable to create domain"
domain_name=`echo $output | grep 'Started domain' | sed 's/^.*Started domain //' | tr -d '\n'`
@ -41,11 +44,13 @@ out=`grep -e '^\#O CPU_CREDITS =' < $domain`
if [ "x$?" = "x0" ]; then
credits=`echo $out | cut -d= -f2 | tr -d ' '`
log_debug "Credits set to $credits"
name=`grep -e '^name =' < $domain | cut -d= -f2 | tr -d ' ' | tr -d "\'"`
$XM_CREDITS -d $name -w $credits
error_exit $?
error_exit $? "Unable to set VM credits"
fi
echo $domain_name

View File

@ -17,8 +17,18 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
dest_host=$2
$XM_MIGRATE $deploy_id $dest_host
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not migrate $deploy_id to $dest_host"
exit $error_code
fi

View File

@ -17,8 +17,18 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
file=$1
$XM_RESTORE $file
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not restore from $file"
exit $error_code
fi

View File

@ -17,9 +17,18 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
file=$2
$XM_SAVE $deploy_id $file
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not save $deploy_id to $file"
exit $error_code
fi

View File

@ -17,6 +17,7 @@
#--------------------------------------------------------------------------- #
source $(dirname $0)/xenrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
@ -24,7 +25,16 @@ function gdm {
$XM_LIST | grep "$deploy_id "
}
$XM_SHUTDOWN $deploy_id || exit -1
$XM_SHUTDOWN $deploy_id
error_code=$?
if [ "x$?" = "x0" ]; then
exit $error_code
else
error_message "Could not shutdown $deploy_id"
exit $error_code
fi
OUT=$(gdm)