mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'feature-575' of git.opennebula.org:one into feature-575
This commit is contained in:
commit
f8a81bdd45
@ -39,12 +39,14 @@ DST=$2
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
exec_and_log "$WGET -O $DST $SRC"
|
||||
exec_and_log "$WGET -O $DST $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Copying local image $SRC to the image repository"
|
||||
exec_and_log "cp -f $SRC $DST"
|
||||
exec_and_log "cp -f $SRC $DST" \
|
||||
"Error copying $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -37,6 +37,8 @@ DST=$1
|
||||
FSTYPE=$2
|
||||
SIZE=$3
|
||||
|
||||
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M"
|
||||
exec_and_log "$MKFS -t $FSTYPE -F $DST"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST"
|
||||
exec_and_log "$MKFS -t $FSTYPE -F $DST" \
|
||||
"Unable to create filesystem $FSTYPE in $DST"
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
|
@ -39,12 +39,14 @@ DST=$2
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
exec_and_log "$WGET -O $DST $SRC"
|
||||
exec_and_log "$WGET -O $DST $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Moving local image $SRC to the image repository"
|
||||
exec_and_log "mv -f $SRC $DST"
|
||||
exec_and_log "mv -f $SRC $DST" \
|
||||
"Could not move $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -36,5 +36,6 @@ SRC=$1
|
||||
|
||||
if [ -e $SRC ] ; then
|
||||
log "Removing $SRC from the image repository"
|
||||
exec_and_log "rm $SRC"
|
||||
exec_and_log "rm $SRC" \
|
||||
"Error deleting $SRC"
|
||||
fi
|
||||
|
@ -83,20 +83,29 @@ function error_message
|
||||
) 1>&2
|
||||
}
|
||||
|
||||
# Executes a command, if it fails return error message and exits
|
||||
# Executes a command, if it fails returns error message and exits
|
||||
# If a second parameter is present it is used as the error message when
|
||||
# the command fails
|
||||
function exec_and_log
|
||||
{
|
||||
message=$2
|
||||
output=`$1 2>&1 1>/dev/null`
|
||||
code=$?
|
||||
if [ "x$code" != "x0" ]; then
|
||||
log_error "Command \"$1\" failed."
|
||||
log_error "$output"
|
||||
error_message "$output"
|
||||
if [ -n "$message" ]; then
|
||||
error_message "$output"
|
||||
else
|
||||
error_message "$message"
|
||||
fi
|
||||
exit $code
|
||||
fi
|
||||
log "Executed \"$1\"."
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Like exec_and_log but the first argument is the number of seconds
|
||||
# before here is timeout and kills the command
|
||||
#
|
||||
|
@ -34,8 +34,8 @@ DST_PATH=`arg_path $DST`
|
||||
|
||||
fix_paths
|
||||
|
||||
log "$1 $2"
|
||||
log "DST: $DST_PATH"
|
||||
log_debug "$1 $2"
|
||||
log_debug "DST: $DST_PATH"
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
@ -46,12 +46,14 @@ exec_and_log "chmod a+w $DST_DIR"
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC"
|
||||
exec_and_log "$WGET -O $DST_PATH $SRC"
|
||||
exec_and_log "$WGET -O $DST_PATH $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Cloning $SRC_PATH"
|
||||
exec_and_log "cp -r $SRC_PATH $DST_PATH"
|
||||
exec_and_log "cp -r $SRC_PATH $DST_PATH" \
|
||||
"Error copying $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -48,16 +48,19 @@ exec_and_log "mkdir -p $ISO_DIR"
|
||||
for f in $SRC; do
|
||||
case $f in
|
||||
http://*)
|
||||
exec_and_log "$WGET -O $ISO_DIR $f"
|
||||
exec_and_log "$WGET -O $ISO_DIR $f" \
|
||||
"Error downloading $f"
|
||||
;;
|
||||
|
||||
*)
|
||||
exec_and_log "cp -R $f $ISO_DIR"
|
||||
exec_and_log "cp -R $f $ISO_DIR" \
|
||||
"Error copying $f to $ISO_DIR"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exec_and_log "$MKISOFS -o $DST_PATH -J -R $ISO_DIR"
|
||||
exec_and_log "$MKISOFS -o $DST_PATH -J -R $ISO_DIR" \
|
||||
"Error creating iso fs"
|
||||
|
||||
exec_and_log "rm -rf $ISO_DIR"
|
||||
|
||||
|
@ -34,4 +34,5 @@ SRC_PATH=`arg_path $SRC`
|
||||
fix_src_path
|
||||
|
||||
log "Deleting $SRC_PATH"
|
||||
exec_and_log "rm -rf $SRC_PATH"
|
||||
exec_and_log "rm -rf $SRC_PATH" \
|
||||
"Error deleting $SRC_PATH"
|
||||
|
@ -37,7 +37,8 @@ fix_dst_path
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Creating directory $DST_DIR"
|
||||
exec_and_log "mkdir -p $DST_DIR"
|
||||
exec_and_log "mkdir -p $DST_DIR" \
|
||||
"Could not create directory $DST_DIR"
|
||||
exec_and_log "chmod a+w $DST_DIR"
|
||||
|
||||
log "Link $SRC_PATH"
|
||||
|
@ -36,8 +36,11 @@ fix_dst_path
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
exec_and_log "mkdir -p $DST_DIR"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
||||
exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH"
|
||||
exec_and_log "mkdir -p $DST_DIR" \
|
||||
"Error creating directory $DST_DIR"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST_PATH"
|
||||
exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH" \
|
||||
"Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
exec_and_log "chmod a+rw $DST_PATH"
|
||||
|
||||
|
@ -35,15 +35,17 @@ fix_dst_path
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Creating directory $DST_DIR"
|
||||
log_debug "Creating directory $DST_DIR"
|
||||
exec_and_log "mkdir -p $DST_DIR"
|
||||
exec_and_log "chmod a+w $DST_DIR"
|
||||
|
||||
log "Creating ${SIZE}Mb image in $DST_PATH"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
||||
log_debug "Creating ${SIZE}Mb image in $DST_PATH"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image file $DST_PATH"
|
||||
|
||||
log "Initializing swap space"
|
||||
exec_and_log "$MKSWAP $DST_PATH"
|
||||
log_debug "Initializing swap space"
|
||||
exec_and_log "$MKSWAP $DST_PATH" \
|
||||
"Could not create swap on $DST_PATH"
|
||||
|
||||
exec_and_log "chmod a+w $DST_PATH"
|
||||
|
||||
|
@ -43,7 +43,8 @@ else
|
||||
log "Will not move, is not saving image"
|
||||
else
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH" \
|
||||
"Could not move $SRC_PATH to $DST_PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -34,23 +34,26 @@ SRC_HOST=`arg_host $SRC`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
|
||||
log "$1 $2"
|
||||
log "DST: $DST_PATH"
|
||||
log_debug "$1 $2"
|
||||
log_debug "DST: $DST_PATH"
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Creating directory $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
|
||||
"Error creating directory $DST_DIR"
|
||||
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC"
|
||||
exec_and_log "$SSH $DST_HOST $WGET -O $DST_PATH $SRC"
|
||||
exec_and_log "$SSH $DST_HOST $WGET -O $DST_PATH $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Cloning $SRC"
|
||||
exec_and_log "$SCP $SRC $DST"
|
||||
exec_and_log "$SCP $SRC $DST" \
|
||||
"Error copying $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -47,21 +47,27 @@ fi
|
||||
ISO_DIR="$TMP_DIR/isofiles"
|
||||
|
||||
|
||||
exec_and_log "mkdir -p $ISO_DIR"
|
||||
exec_and_log "mkdir -p $ISO_DIR" \
|
||||
"Error creating directory $ISO_DIR"
|
||||
|
||||
for f in $SRC; do
|
||||
case $f in
|
||||
http://*)
|
||||
exec_and_log "$WGET -O $ISO_DIR $f"
|
||||
exec_and_log "$WGET -O $ISO_DIR $f" \
|
||||
"Error downloading $f"
|
||||
;;
|
||||
|
||||
*)
|
||||
exec_and_log "cp -R $f $ISO_DIR"
|
||||
exec_and_log "cp -R $f $ISO_DIR" \
|
||||
"Error copying $f to $ISO_DIR"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exec_and_log "$MKISOFS -o $TMP_DIR/$DST_FILE -J -R $ISO_DIR"
|
||||
exec_and_log "$SCP $TMP_DIR/$DST_FILE $DST"
|
||||
exec_and_log "rm -rf $TMP_DIR"
|
||||
exec_and_log "$MKISOFS -o $TMP_DIR/$DST_FILE -J -R $ISO_DIR" \
|
||||
"Error creating iso fs"
|
||||
exec_and_log "$SCP $TMP_DIR/$DST_FILE $DST" \
|
||||
"Error copying $TMP_DIR/$DST_FILE to $DST"
|
||||
exec_and_log "rm -rf $TMP_DIR" \
|
||||
"Error deleting $TMP_DIR"
|
||||
|
||||
|
@ -31,4 +31,5 @@ SRC_PATH=`arg_path $SRC`
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
|
||||
log "Deleting $SRC_PATH"
|
||||
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH"
|
||||
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" \
|
||||
"Error deleting $SRC_PATH"
|
||||
|
@ -32,7 +32,10 @@ DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
||||
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
|
||||
"Error creating directory $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" \
|
||||
"Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
|
@ -34,10 +34,12 @@ DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Creating ${SIZE}Mb image in $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
||||
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image file $DST_PATH"
|
||||
|
||||
log "Initializing swap space"
|
||||
exec_and_log "$SSH $DST_HOST $MKSWAP $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST $MKSWAP $DST_PATH" \
|
||||
"Could not create swap on $DST_PATH"
|
||||
|
||||
exec_and_log "$SSH $DST_HOST chmod a+w $DST_PATH"
|
||||
|
||||
|
@ -36,6 +36,8 @@ DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
|
||||
exec_and_log "$SCP -r $SRC $DST"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
|
||||
"Unable to create directory $DST_DIR"
|
||||
exec_and_log "$SCP -r $SRC $DST" \
|
||||
"Could not copy $SRC to $DST"
|
||||
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH"
|
||||
|
@ -17,7 +17,9 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
|
||||
virsh --connect $LIBVIRT_URI destroy $deploy_id
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI destroy $deploy_id" \
|
||||
"Could not destroy $deploy_id"
|
||||
|
@ -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
|
||||
|
@ -17,8 +17,10 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
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
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI migrate --live $deploy_id $QEMU_PROTOCOL://$dest_host/system" \
|
||||
"Could not migrate $deploy_id to $dest_host"
|
||||
|
@ -17,7 +17,9 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
file=$1
|
||||
|
||||
virsh --connect $LIBVIRT_URI restore $file
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI restore $file" \
|
||||
"Could not restore from $file"
|
||||
|
@ -17,6 +17,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
file=$2
|
||||
@ -26,4 +27,5 @@ if [ ! -f $file ]; then
|
||||
chmod 666 $file
|
||||
fi
|
||||
|
||||
virsh --connect $LIBVIRT_URI save $deploy_id $file
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI save $deploy_id $file" \
|
||||
"Could not save $deploy_id to $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
|
||||
|
@ -17,7 +17,9 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/xenrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
|
||||
$XM_CANCEL $deploy_id
|
||||
exec_and_log "$XM_CANCEL $deploy_id" \
|
||||
"Could not destroy $deploy_id"
|
||||
|
@ -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
|
||||
|
@ -17,8 +17,10 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/xenrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
dest_host=$2
|
||||
|
||||
$XM_MIGRATE $deploy_id $dest_host
|
||||
exec_and_log "$XM_MIGRATE $deploy_id $dest_host" \
|
||||
"Could not migrate $deploy_id to $dest_host"
|
||||
|
@ -17,8 +17,10 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/xenrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
file=$1
|
||||
|
||||
$XM_RESTORE $file
|
||||
exec_and_log "$XM_RESTORE $file" \
|
||||
"Could not restore from $file"
|
||||
|
||||
|
@ -17,9 +17,10 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/xenrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
file=$2
|
||||
|
||||
$XM_SAVE $deploy_id $file
|
||||
|
||||
exec_and_log "$XM_SAVE $deploy_id $file" \
|
||||
"Could not save $deploy_id to $file"
|
||||
|
@ -17,6 +17,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/xenrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
|
||||
@ -24,7 +25,8 @@ function gdm {
|
||||
$XM_LIST | grep "$deploy_id "
|
||||
}
|
||||
|
||||
$XM_SHUTDOWN $deploy_id || exit -1
|
||||
exec_and_log "$XM_SHUTDOWN $deploy_id" \
|
||||
"Could not shutdown $deploy_id"
|
||||
|
||||
OUT=$(gdm)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user