From 8fe27e0f48e894be563598d70148f6376489cc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Font=C3=A1n=20Mui=C3=B1os?= Date: Mon, 26 Oct 2009 15:39:04 +0000 Subject: [PATCH] tm_nfs now fixes urls that point to VM_DIR remotelly git-svn-id: http://svn.opennebula.org/one/trunk@894 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/tm_mad/nfs/tm_clone.sh | 4 ++++ src/tm_mad/nfs/tm_context.sh | 4 ++++ src/tm_mad/nfs/tm_delete.sh | 4 ++++ src/tm_mad/nfs/tm_ln.sh | 4 ++++ src/tm_mad/nfs/tm_mkimage.sh | 5 +++++ src/tm_mad/nfs/tm_mkswap.sh | 5 +++++ src/tm_mad/nfs/tm_mv.sh | 4 ++++ src/tm_mad/tm_common.sh | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 65 insertions(+) diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/nfs/tm_clone.sh index f1a453c6f4..320c5ee88d 100755 --- a/src/tm_mad/nfs/tm_clone.sh +++ b/src/tm_mad/nfs/tm_clone.sh @@ -28,9 +28,13 @@ fi . $TMCOMMON +get_vmdir + SRC_PATH=`arg_path $SRC` DST_PATH=`arg_path $DST` +fix_paths + log "$1 $2" log "DST: $DST_PATH" diff --git a/src/tm_mad/nfs/tm_context.sh b/src/tm_mad/nfs/tm_context.sh index 291c5fb35c..84fb4c5bf9 100755 --- a/src/tm_mad/nfs/tm_context.sh +++ b/src/tm_mad/nfs/tm_context.sh @@ -38,8 +38,12 @@ fi . $TMCOMMON +get_vmdir DST_PATH=`arg_path $DST` + +fix_dst_path + DST_DIR=`dirname $DST_PATH` ISO_DIR=$DST_DIR/isofiles diff --git a/src/tm_mad/nfs/tm_delete.sh b/src/tm_mad/nfs/tm_delete.sh index 876ed473a4..406d982b00 100755 --- a/src/tm_mad/nfs/tm_delete.sh +++ b/src/tm_mad/nfs/tm_delete.sh @@ -28,7 +28,11 @@ fi . $TMCOMMON +get_vmdir + SRC_PATH=`arg_path $SRC` +fix_src_path + log "Deleting $SRC_PATH" exec_and_log "rm -rf $SRC_PATH" diff --git a/src/tm_mad/nfs/tm_ln.sh b/src/tm_mad/nfs/tm_ln.sh index f5c8bf98b0..bddebb973b 100755 --- a/src/tm_mad/nfs/tm_ln.sh +++ b/src/tm_mad/nfs/tm_ln.sh @@ -28,9 +28,13 @@ fi . $TMCOMMON +get_vmdir + SRC_PATH=`arg_path $SRC` DST_PATH=`arg_path $DST` +fix_dst_path + DST_DIR=`dirname $DST_PATH` log "Creating directory $DST_DIR" diff --git a/src/tm_mad/nfs/tm_mkimage.sh b/src/tm_mad/nfs/tm_mkimage.sh index 8dd7a18b24..07b1f668c8 100755 --- a/src/tm_mad/nfs/tm_mkimage.sh +++ b/src/tm_mad/nfs/tm_mkimage.sh @@ -25,11 +25,16 @@ fi . $TMCOMMON +get_vmdir + SIZE=$1 FSTYPE=$2 DST=$3 DST_PATH=`arg_path $DST` + +fix_dst_path + DST_DIR=`dirname $DST_PATH` exec_and_log "mkdir -p $DST_DIR" diff --git a/src/tm_mad/nfs/tm_mkswap.sh b/src/tm_mad/nfs/tm_mkswap.sh index aab637d8a3..9c3a2338c9 100755 --- a/src/tm_mad/nfs/tm_mkswap.sh +++ b/src/tm_mad/nfs/tm_mkswap.sh @@ -28,7 +28,12 @@ fi . $TMCOMMON +get_vmdir + DST_PATH=`arg_path $DST` + +fix_dst_path + DST_DIR=`dirname $DST_PATH` log "Creating directory $DST_DIR" diff --git a/src/tm_mad/nfs/tm_mv.sh b/src/tm_mad/nfs/tm_mv.sh index 9be2dcc247..42b09d65da 100755 --- a/src/tm_mad/nfs/tm_mv.sh +++ b/src/tm_mad/nfs/tm_mv.sh @@ -30,9 +30,13 @@ fi . $TMCOMMON +get_vmdir + SRC_PATH=`arg_path $SRC` DST_PATH=`arg_path $DST` +fix_paths + if [ "$SRC_PATH" == "$DST_PATH" ]; then log "Will not move, source and destination are equal" else diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh index d9b0c28401..42450e8ff2 100644 --- a/src/tm_mad/tm_common.sh +++ b/src/tm_mad/tm_common.sh @@ -15,6 +15,41 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +if [ -z "$ONE_LOCATION" ]; then + ONE_CONF=/etc/one/oned.conf + ONE_LOCAL_VAR=/var/lib/one +else + ONE_CONF=$ONE_LOCATION/etc/oned.conf + ONE_LOCAL_VAR=$ONE_LOCATION/var +fi + +function get_vmdir +{ + VMDIR=`cat $ONE_CONF | grep ^VM_DIR= | cut -d= -f2` +} + +function fix_paths +{ + if [ -n "$VMDIR" ]; then + SRC_PATH=${SRC_PATH/$VMDIR/$ONE_LOCAL_VAR} + DST_PATH=${DST_PATH/$VMDIR/$ONE_LOCAL_VAR} + fi +} + +function fix_src_path +{ + if [ -n "$VMDIR" ]; then + SRC_PATH=${SRC_PATH/$VMDIR/$ONE_LOCAL_VAR} + fi +} + +function fix_dst_path +{ + if [ -n "$VMDIR" ]; then + DST_PATH=${DST_PATH/$VMDIR/$ONE_LOCAL_VAR} + fi +} + # Used for log messages SCRIPT_NAME=`basename $0`