mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-02 09:47:00 +03:00
Feature #1154: image/transfer driver for qcow2 and multiple datastore
This commit is contained in:
parent
0d63b57851
commit
63f03bbe0a
12
install.sh
12
install.sh
@ -229,6 +229,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/tm/dummy \
|
||||
$VAR_LOCATION/remotes/tm/lvm \
|
||||
$VAR_LOCATION/remotes/tm/shared \
|
||||
$VAR_LOCATION/remotes/tm/qcow2 \
|
||||
$VAR_LOCATION/remotes/tm/ssh \
|
||||
$VAR_LOCATION/remotes/tm/vmware \
|
||||
$VAR_LOCATION/remotes/tm/iscsi \
|
||||
@ -385,6 +386,7 @@ INSTALL_FILES=(
|
||||
VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware
|
||||
TM_FILES:$VAR_LOCATION/remotes/tm
|
||||
TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared
|
||||
TM_QCOW2_FILES:$VAR_LOCATION/remotes/tm/qcow2
|
||||
TM_SSH_FILES:$VAR_LOCATION/remotes/tm/ssh
|
||||
TM_VMWARE_FILES:$VAR_LOCATION/remotes/tm/vmware
|
||||
TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi
|
||||
@ -760,6 +762,7 @@ NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \
|
||||
#-------------------------------------------------------------------------------
|
||||
# Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands
|
||||
# - SHARED TM, $VAR_LOCATION/tm/shared
|
||||
# - QCOW2 TM, $VAR_LOCATION/tm/qcow2
|
||||
# - SSH TM, $VAR_LOCATION/tm/ssh
|
||||
# - dummy TM, $VAR_LOCATION/tm/dummy
|
||||
# - LVM TM, $VAR_LOCATION/tm/lvm
|
||||
@ -776,6 +779,15 @@ TM_SHARED_FILES="src/tm_mad/shared/clone \
|
||||
src/tm_mad/shared/context \
|
||||
src/tm_mad/shared/mvds"
|
||||
|
||||
TM_QCOW2_FILES="src/tm_mad/qcow2/clone \
|
||||
src/tm_mad/qcow2/delete \
|
||||
src/tm_mad/qcow2/ln \
|
||||
src/tm_mad/qcow2/mkswap \
|
||||
src/tm_mad/qcow2/mkimage \
|
||||
src/tm_mad/qcow2/mv \
|
||||
src/tm_mad/qcow2/context \
|
||||
src/tm_mad/qcow2/mvds"
|
||||
|
||||
TM_SSH_FILES="src/tm_mad/ssh/clone \
|
||||
src/tm_mad/ssh/delete \
|
||||
src/tm_mad/ssh/ln \
|
||||
|
@ -80,9 +80,9 @@ MAC_PREFIX = "02:00"
|
||||
#*******************************************************************************
|
||||
# DataStore Configuration
|
||||
#*******************************************************************************
|
||||
# DATASTORE_LOCATION: Path for Datastores in the hosts. It IS the same for all
|
||||
# DATASTORE_LOCATION: Path for Datastores in the hosts. It IS the same for all
|
||||
# the hosts in the cluster. DATASTORE_LOCATION IS ONLY FOR THE HOSTS AND *NOT*
|
||||
# THE FRONT-END. It defaults to /var/lib/one/datastores (or
|
||||
# THE FRONT-END. It defaults to /var/lib/one/datastores (or
|
||||
# $ONE_LOCATION/var/datastores in self-contained mode)
|
||||
#
|
||||
# DEFAULT_IMAGE_TYPE: This can take values
|
||||
@ -201,7 +201,7 @@ IM_MAD = [
|
||||
# KVM Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate,poll=poll_ganglia,save"
|
||||
@ -218,7 +218,7 @@ VM_MAD = [
|
||||
# XEN Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate,poll=poll_ganglia,save"
|
||||
@ -281,7 +281,7 @@ VM_MAD = [
|
||||
|
||||
TM_MAD = [
|
||||
executable = "one_tm",
|
||||
arguments = "-t 15 -d dummy,lvm,shared,ssh,vmware,iscsi" ]
|
||||
arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmware,iscsi" ]
|
||||
|
||||
#*******************************************************************************
|
||||
# Datastore Driver Configuration
|
||||
@ -412,7 +412,7 @@ HM_MAD = [
|
||||
# --authz: authorization module
|
||||
#
|
||||
# SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as
|
||||
# valid. During this time, the driver is not used. Use 0 to disable session
|
||||
# valid. During this time, the driver is not used. Use 0 to disable session
|
||||
# caching
|
||||
#
|
||||
# ENABLE_OTHER_PERMISSIONS: Whether or not to enable the permissions for
|
||||
|
67
src/tm_mad/qcow2/clone
Executable file
67
src/tm_mad/qcow2/clone
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# clone fe:SOURCE host:remote_system_ds/disk.i size
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}"
|
||||
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clone (cp) SRC into DST
|
||||
#-------------------------------------------------------------------------------
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC into $DST_PATH"
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"$WGET -O $DST_PATH $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Cloning $SRC_PATH in $DST"
|
||||
|
||||
CLONE_CMD="cd $DST_DIR; qemu-img create -b $SRC_PATH -f qcow2 $DST_PATH"
|
||||
ssh_exec_and_log "$DST_HOST" "$CLONE_CMD" "Error copying $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
1
src/tm_mad/qcow2/context
Symbolic link
1
src/tm_mad/qcow2/context
Symbolic link
@ -0,0 +1 @@
|
||||
../common/context
|
1
src/tm_mad/qcow2/delete
Symbolic link
1
src/tm_mad/qcow2/delete
Symbolic link
@ -0,0 +1 @@
|
||||
../common/delete
|
83
src/tm_mad/qcow2/ln
Executable file
83
src/tm_mad/qcow2/ln
Executable file
@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# ln fe:SOURCE host:remote_system_ds/disk.i
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}"
|
||||
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Link (ln) SRC into DST
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Is it a file or a folder (VMware)?
|
||||
if [ -d `arg_path $SRC` ]; then
|
||||
ssh_make_path $DST_HOST $DST_PATH
|
||||
|
||||
# It's a folder, make links for all elements
|
||||
SRC_FOLDER_NAME=`basename $SRC_PATH`
|
||||
SRC_WITH_NO_FOLDER=`dirname $SRC_PATH`
|
||||
SRC_DS_NAME=`basename $SRC_WITH_NO_FOLDER`
|
||||
REL_SRC_PATH="../../../$SRC_DS_NAME/$SRC_FOLDER_NAME"
|
||||
|
||||
log "Link all files in $SRC_PATH to $DST_PATH"
|
||||
|
||||
LINK_SCRIPT=$(cat <<EOF
|
||||
for file in \$(cd $DST_DIR ; find $SRC_PATH -type f); do
|
||||
FNAME=\$(basename \$file)
|
||||
(cd $DST_PATH ; ln -sf $REL_SRC_PATH/\$FNAME $DST_PATH/$FNAME)
|
||||
done
|
||||
EOF
|
||||
)
|
||||
ssh_exec_and_log $DST_HOST "$LINK_SCRIPT" "Could not link dir files from source DS to system DS"
|
||||
else
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
# Just link a file
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
1
src/tm_mad/qcow2/mkimage
Symbolic link
1
src/tm_mad/qcow2/mkimage
Symbolic link
@ -0,0 +1 @@
|
||||
../common/mkimage
|
1
src/tm_mad/qcow2/mkswap
Symbolic link
1
src/tm_mad/qcow2/mkswap
Symbolic link
@ -0,0 +1 @@
|
||||
../common/mkswap
|
1
src/tm_mad/qcow2/mv
Symbolic link
1
src/tm_mad/qcow2/mv
Symbolic link
@ -0,0 +1 @@
|
||||
../common/dummy.sh
|
69
src/tm_mad/qcow2/mvds
Executable file
69
src/tm_mad/qcow2/mvds
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# mvds host:remote_system_ds/disk.i fe:SOURCE
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
set_ds_location
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
|
||||
DST_PATH="$RMT_DS_DIR/${DST_PATH##"$DS_DIR/"}"
|
||||
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Move the image back to the datastore
|
||||
#-------------------------------------------------------------------------------
|
||||
MVSCRIPT=$(cat <<EOF
|
||||
umask 0007
|
||||
SRC_READLN=\$($READLINK -f $SRC_PATH)
|
||||
DST_READLN=\$($READLINK -f $DST_PATH)
|
||||
|
||||
if [ \( -L $SRC \) -a \( "\$SRC_READLN" = "\$DST_READLN" \) ] ; then
|
||||
echo "Not moving files to image repo, they are the same"
|
||||
else
|
||||
qemu-img convert $SRC_PATH -O qcow2 $DST_PATH
|
||||
rm $SRC_PATH
|
||||
fi
|
||||
EOF
|
||||
)
|
||||
|
||||
log "Moving $SRC_PATH to datastore as $DST_PATH"
|
||||
|
||||
ssh_exec_and_log $SRC_HOST "$MVSCRIPT" "Could not move image $DST_PATH"
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user