mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Initial commit of ssh-based VMWare TM MAD.
git-svn-id: http://svn.opennebula.org/one/trunk@492 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
fdbf6a74c6
commit
34c11ea6c3
60
src/tm_mad/vmware/tm_clone.sh
Executable file
60
src/tm_mad/vmware/tm_clone.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
|
||||
# Get rid of path/images, we don't need it
|
||||
DST_PATH=`dirname $DST_PATH`
|
||||
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
log "$1 $2"
|
||||
log "DST: $DST_PATH"
|
||||
|
||||
BASE_SRC=`basename $SRC_PATH`
|
||||
BASE_DST=`basename $DST_PATH`
|
||||
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC"
|
||||
exec_and_log "ssh $DST_HOST wget -O $DST_PATH $SRC_PATH"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Cloning $SRC"
|
||||
scp -r $SRC $DST_HOST:/vmfs/volumes/$DATASTORE/
|
||||
ssh $DST_HOST "cd /vmfs/volumes/$DATASTORE ; mv $BASE_SRC $BASE_DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
ssh $DST_HOST chmod a+w /vmfs/volumes/$DATASTORE/$BASE_DST
|
||||
|
69
src/tm_mad/vmware/tm_context.sh
Executable file
69
src/tm_mad/vmware/tm_context.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# Parameters: a b c d e f g h
|
||||
# SRC: a b c d e f g
|
||||
# DST: h
|
||||
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_FILE=`basename $DST_PATH`
|
||||
DST_PATH=`dirname $DST_PATH`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
DST_HASH=`echo -n $DST | md5sum | awk '{print $1}'`
|
||||
TMP_DIR="$ONE_LOCATION/var/$DST_HASH"
|
||||
ISO_DIR="$TMP_DIR/isofiles"
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_ONEID_FOLDER=`dirname $DST_PATH`
|
||||
DST_ONEID_FOLDER=`basename $DST_ONEID_FOLDER`
|
||||
|
||||
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 "cp -R $f $ISO_DIR"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exec_and_log "mkisofs -o $TMP_DIR/$DST_FILE -J -R $ISO_DIR"
|
||||
scp $TMP_DIR/$DST_FILE $DST_HOST:/vmfs/volumes/$DATASTORE/$DST_ONEID_FOLDER
|
||||
exec_and_log "rm -rf $TMP_DIR"
|
38
src/tm_mad/vmware/tm_delete.sh
Executable file
38
src/tm_mad/vmware/tm_delete.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
|
||||
# We just need the <vid> bit
|
||||
SRC_PATH=`basename $SRC_PATH`
|
||||
|
||||
log "Deleting $SRC_PATH"
|
||||
exec_and_log "ssh $SRC_HOST rm -rf /vmfs/volumes/$DATASTORE/$SRC_PATH"
|
35
src/tm_mad/vmware/tm_ln.sh
Executable file
35
src/tm_mad/vmware/tm_ln.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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
|
50
src/tm_mad/vmware/tm_mkimage.sh
Executable file
50
src/tm_mad/vmware/tm_mkimage.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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`
|
||||
# Get rid of path/images, we don't need it
|
||||
DST_DIR=`dirname $DST_DIR`
|
||||
|
||||
DST_HASH=`echo -n $DST | md5sum | awk '{print $1}'`
|
||||
TMP_DIR="$ONE_LOCATION/var/$DST_HASH"
|
||||
NAME_OF_CONTEXT_FILE=`basename $DST_PATH`
|
||||
|
||||
DST_ONEID_FOLDER=`basename $DST_DIR`
|
||||
|
||||
exec_and_log "mkdir -p $TMP_DIR"
|
||||
|
||||
ssh $DST_HOST \"cd /vmfs/volumes/$DATASTORE; mkdir $DST_DIR\"
|
||||
exec_and_log "dd if=/dev/zero of=$TMP_DIR/$NAME_OF_CONTEXT_FILE bs=1 count=1 seek=${SIZE}M"
|
||||
exec_and_log "mkfs -t $FSTYPE -F $TMP_DIR/$NAME_OF_CONTEXT_FILE"
|
||||
scp $TMP_DIR/$NAME_OF_CONTEXT_FILE $DST_HOST:/vmfs/volumes/$DATASTORE/$DST_ONEID_FOLDER
|
||||
ssh $DST_HOST chmod a+rw $DST_PATH
|
69
src/tm_mad/vmware/tm_mv.sh
Executable file
69
src/tm_mad/vmware/tm_mv.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
||||
# Complutense de Madrid (dsa-research.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
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
if [ $SRC_HOST -ne `hostname` ]; then
|
||||
$VM_ID=`sed -e 's/.*\/\([0-9]\+\)\/images\/.*/\1/`
|
||||
$VM_NAME=one-$VM_ID
|
||||
$LAST_BIT_OF_PATH=`basename $SRC_PATH`
|
||||
if [ $LAST_BIT_OF_PATH -eq "images" ]; then
|
||||
SRC_PATH="/vmfs/volumes/$DATASTORE/"$VM_NAME
|
||||
else
|
||||
SRC_PATH="/vmfs/volumes/$DATASTORE/"$VM_NAME"/$LAST_BIT_OF_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $DST_HOST -ne `hostname` ]; then
|
||||
$VM_ID=`sed -e 's/.*\/\([0-9]\+\)\/images\/.*/\1/`
|
||||
$VM_NAME=one-$VM_ID
|
||||
$LAST_BIT_OF_PATH=`basename $DST_PATH`
|
||||
if [ $LAST_BIT_OF_PATH -eq "images" ]; then
|
||||
DST_PATH="/vmfs/volumes/$DATASTORE/"$VM_NAME
|
||||
else
|
||||
DST_PATH="/vmfs/volumes/$DATASTORE/"$VM_NAME"/$LAST_BIT_OF_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
if [ -d $DST_PATH ]; then
|
||||
DST_ONEID_FOLDER=`basename `
|
||||
else
|
||||
fi
|
||||
|
||||
log "Moving $SRC_PATH"
|
||||
scp -r $SRC $DST_HOST:/vmfs/volumes/$DATASTORE/$
|
||||
ssh $SRC_HOST rm -rf $SRC_PATH
|
6
src/tm_mad/vmware/tm_vmware.conf
Normal file
6
src/tm_mad/vmware/tm_vmware.conf
Normal file
@ -0,0 +1,6 @@
|
||||
CLONE = vmware/tm_clone.sh
|
||||
LN = vmware/tm_ln.sh
|
||||
MKSWAP = dummy/tm_dymmy.sh
|
||||
MKIMAGE = vmware/tm_mkimage.sh
|
||||
DELETE = vmware/tm_delete.sh
|
||||
MV = vmware/tm_mv.sh
|
@ -15,11 +15,8 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
#VMWARE_TRUSTORE=<path_to_keystore>
|
||||
|
||||
# Uncomment the following line to active MAD debug
|
||||
#ONE_MAD_DEBUG=1
|
||||
|
||||
VMWARE_TRUSTORE=/home/tinova/.vmware-certs/vmware.keystore
|
||||
USERNAME=root
|
||||
PASSWORD=pantufla
|
||||
# Name of the ESX(i) datastore
|
||||
DATASTORE=datastore1
|
||||
|
Loading…
x
Reference in New Issue
Block a user