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

Merge branch 'master' of git.opennebula.org:one

This commit is contained in:
Ruben S. Montero 2012-04-04 11:29:33 +02:00
commit 6bf554d4e0
9 changed files with 3 additions and 454 deletions

View File

@ -185,7 +185,6 @@ SHARE_DIRS="$SHARE_LOCATION/examples \
ETC_DIRS="$ETC_LOCATION/im_ec2 \
$ETC_LOCATION/vmm_ec2 \
$ETC_LOCATION/vmm_exec \
$ETC_LOCATION/tm \
$ETC_LOCATION/hm \
$ETC_LOCATION/auth \
$ETC_LOCATION/auth/certificates \
@ -227,7 +226,6 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/vnm/vmware \
$VAR_LOCATION/remotes/tm/ \
$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 \
@ -392,7 +390,6 @@ INSTALL_FILES=(
TM_VMWARE_FILES:$VAR_LOCATION/remotes/tm/vmware
TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi
TM_DUMMY_FILES:$VAR_LOCATION/remotes/tm/dummy
TM_LVM_FILES:$VAR_LOCATION/remotes/tm/lvm
DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/
DATASTORE_DRIVER_DUMMY_SCRIPTS:$VAR_LOCATION/remotes/datastore/dummy
DATASTORE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/datastore/fs
@ -539,7 +536,6 @@ INSTALL_ETC_FILES=(
VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2
TM_LVM_ETC_FILES:$ETC_LOCATION/tm/
HM_ETC_FILES:$ETC_LOCATION/hm
AUTH_ETC_FILES:$ETC_LOCATION/auth
ECO_ETC_FILES:$ETC_LOCATION
@ -766,8 +762,9 @@ NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \
# - 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
# - DUMMY TM, $VAR_LOCATION/tm/dummy
# - VMWARE TM, $VAR_LOCATION/tm/vmware
# - ISCSI TM, $VAR_LOCATION/tm/iscsi
#-------------------------------------------------------------------------------
TM_FILES="src/tm_mad/tm_common.sh"
@ -808,14 +805,6 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \
src/tm_mad/dummy/context \
src/tm_mad/dummy/mvds"
TM_LVM_FILES="src/tm_mad/lvm/clone \
src/tm_mad/lvm/delete \
src/tm_mad/lvm/ln \
src/tm_mad/lvm/mkswap \
src/tm_mad/lvm/mkimage \
src/tm_mad/lvm/mv \
src/tm_mad/lvm/context"
TM_VMWARE_FILES="src/tm_mad/vmware/clone \
src/tm_mad/vmware/delete
src/tm_mad/vmware/ln \
@ -905,16 +894,6 @@ VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \
IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \
src/im_mad/ec2/im_ec2.conf"
#-------------------------------------------------------------------------------
# Storage drivers config. files, to be installed under $ETC_LOCATION
# - shared, $ETC_LOCATION/tm_shared
# - ssh, $ETC_LOCATION/tm_ssh
# - dummy, $ETC_LOCATION/tm_dummy
# - lvm, $ETC_LOCATION/tm_lvm
#-------------------------------------------------------------------------------
TM_LVM_ETC_FILES="src/tm_mad/lvm/lvm.conf"
#-------------------------------------------------------------------------------
# Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm
#-------------------------------------------------------------------------------

View File

@ -1,87 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
SRC=$1
DST=$2
SIZE=$3
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
LVMRC=/etc/one/tm_lvm/tm_lvmrc
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
fi
. $TMCOMMON
. $LVMRC
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
SRC_HOST=`arg_host $SRC`
DST_HOST=`arg_host $DST`
if [ -z $SIZE ] ; then
SIZE=$DEFAULT_LV_SIZE
fi
LV_NAME=`get_lv_name $DST_PATH`
log "$1 $2"
log "DST: $DST_PATH"
DST_DIR=`dirname $DST_PATH`
log "Creating directory $DST_DIR"
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
case $SRC in
#------------------------------------------------------------------------------
#Get the image from http repository and dump it to a new LV
#------------------------------------------------------------------------------
http://*)
log "Creating LV $LV_NAME"
exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -L$SIZE -n $LV_NAME $VG_NAME"
exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
log "Dumping Image into /dev/$VG_NAME/$LV_NAME"
exec_and_log "eval $SSH $DST_HOST '$WGET $SRC -q -O- | $SUDO $DD of=/dev/$VG_NAME/$LV_NAME bs=64k'"
;;
#------------------------------------------------------------------------------
#Make a snapshot from the given dev (already in DST_HOST)
#------------------------------------------------------------------------------
*:/dev/*)
log "Cloning LV $LV_NAME"
exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -s -L$SIZE -n $LV_NAME $SRC_PATH"
exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
;;
#------------------------------------------------------------------------------
#Get the image from SRC_HOST and dump it to a new LV
#------------------------------------------------------------------------------
*)
log "Creating LV $LV_NAME"
exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -L$SIZE -n $LV_NAME $VG_NAME"
exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
log "Dumping Image"
exec_and_log "eval cat $SRC_PATH | $SSH $DST_HOST $SUDO $DD of=/dev/$VG_NAME/$LV_NAME bs=64k"
;;
esac

View File

@ -1,67 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
while (( "$#" )); do
if [ "$#" == "1" ]; then
DST=$1
else
SRC="$SRC $1"
fi
shift
done
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
fi
. $TMCOMMON
DST_PATH=`arg_path $DST`
DST_DIR=`dirname $DST_PATH`
DST_FILE=`basename $DST_PATH`
DST_HASH=`echo -n $DST | $MD5SUM | $AWK '{print $1}'`
if [ -z "$ONE_LOCATION" ]; then
TMP_DIR="/var/lib/one/$DST_HASH"
else
TMP_DIR="$ONE_LOCATION/var/$DST_HASH"
fi
ISO_DIR="$TMP_DIR/isofiles"
exec_and_log "mkdir -p $ISO_DIR"
for f in $SRC; do
case $f in
http://*)
exec_and_log "$WGET -P $ISO_DIR $f"
;;
*)
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"

View File

@ -1,42 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
SRC=$1
DST=$2
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
LVMRC=/etc/one/tm_lvm/tm_lvmrc
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
fi
. $TMCOMMON
. $LVMRC
SRC_PATH=`arg_path $SRC`
SRC_HOST=`arg_host $SRC`
VID=`get_vid $SRC_PATH`
log "Deleting remote LVs"
exec_and_log "$SSH $SRC_HOST $SUDO $LVREMOVE -f \$(echo $VG_NAME/\$($SUDO $LVS --noheadings $VG_NAME|$AWK '{print \$1}'|grep lv-one-$VID))"
log "Deleting $SRC_PATH"
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH"

View File

@ -1,34 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
SRC=$1
DST=$2
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
TM_COMMANDS_LOCATION=/usr/lib/one/tm_commands/
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
TM_COMMANDS_LOCATION=$ONE_LOCATION/lib/tm_commands/
fi
. $TMCOMMON
log "Link $SRC_PATH (non shared dir, will clone)"
#exec_and_log "ln -s $SRC_PATH $DST_PATH"
exec $TM_COMMANDS_LOCATION/ssh/tm_clone.sh $SRC $DST

View File

@ -1,38 +0,0 @@
# -------------------------------------------------------------------------- #
# 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. #
#--------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# Volume Group to create logical volumes or snapshots in the cluster nodes #
VG_NAME=
# Default size for logical volumes if not specified
DEFAULT_LV_SIZE="1G"
# -------------------------------------------------------------------------- #
# Helper functions for the LVM plugin #
# -------------------------------------------------------------------------- #
function get_vid {
echo $1 |$SED -e 's%^.*/([^/]*)/images.*$%\1%'
}
function get_lv_name {
VID=`get_vid $1`
DISK=`echo $1|$AWK -F. '{printf $NF}'`
echo "lv-one-$VID-$DISK"
}

View File

@ -1,40 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
fi
. $TMCOMMON
SIZE=$1
FSTYPE=$2
DST=$3
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
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_CMD"
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"

View File

@ -1,43 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
SIZE=$1
DST=$2
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
fi
. $TMCOMMON
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
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"
log "Initializing swap space"
exec_and_log "$SSH $DST_HOST $MKSWAP $DST_PATH"
exec_and_log "$SSH $DST_HOST chmod a+w $DST_PATH"

View File

@ -1,79 +0,0 @@
#!/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. #
#--------------------------------------------------------------------------- #
SRC=$1
DST=$2
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/usr/lib/one/mads/tm_common.sh
LVMRC=/etc/one/tm_lvm/tm_lvmrc
else
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
fi
. $TMCOMMON
. $LVMRC
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
SRC_HOST=`arg_host $SRC`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
VID=`get_vid $SRC_PATH`
if [ -z $SIZE ] ; then
SIZE=$DEFAULT_LV_SIZE
fi
# Check that we are not stopping, migrating or resuming
if echo `basename $SRC_PATH`|grep -vq '^disk'; then
log_error "This TM does not support stop, migrating or resuming."
exit 1
fi
if [ "$SRC_HOST" != "$HOSTNAME" ]; then
log "Dumping LV to disk image"
echo "if [ -L "$SRC_PATH" ]; then
lv=\$(readlink $SRC_PATH)
rm $SRC_PATH
touch $SRC_PATH
$SUDO $DD if=\$lv of=$SRC_PATH bs=64k
else
exit 1
fi" | $SSH $SRC_HOST "$BASH -s"
[ "$?" != "0" ] && log_error "Error dumping LV to disk image"
log "Deleting remote LVs"
exec_and_log "$SSH $SRC_HOST $SUDO $LVREMOVE -f \$(echo $VG_NAME/\$($SUDO $LVS --noheadings $VG_NAME|$AWK '{print \$1}'|grep lv-one-$VID))"
fi
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 $SRC_HOST rm -rf $SRC_PATH"
if [ "$DST_HOST" != "$HOSTNAME" ]; then
log_error "This TM does not support resuming."
fi