| 1 | #!/bin/bash
|
| 2 |
|
| 3 | # -------------------------------------------------------------------------- #
|
| 4 | # Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
| 5 | # Complutense de Madrid (dsa-research.org) #
|
| 6 | # #
|
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
| 8 | # not use this file except in compliance with the License. You may obtain #
|
| 9 | # a copy of the License at #
|
| 10 | # #
|
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 #
|
| 12 | # #
|
| 13 | # Unless required by applicable law or agreed to in writing, software #
|
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, #
|
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
| 16 | # See the License for the specific language governing permissions and #
|
| 17 | # limitations under the License. #
|
| 18 | #--------------------------------------------------------------------------- #
|
| 19 |
|
| 20 | # Modified by Sebastien Goasguen <sebgoa@clemson.edu>
|
| 21 |
|
| 22 | SRC=$1
|
| 23 | DST=$2
|
| 24 |
|
| 25 | if [ -z "${ONE_LOCATION}" ]; then
|
| 26 | TMCOMMON=/usr/lib/one/mads/tm_common.sh
|
| 27 | else
|
| 28 | TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
| 29 | fi
|
| 30 |
|
| 31 | . $TMCOMMON
|
| 32 |
|
| 33 | SRC_PATH=`arg_path $SRC`
|
| 34 | DST_PATH=`arg_path $DST`
|
| 35 |
|
| 36 | SRC_HOST=`arg_host $SRC`
|
| 37 | DST_HOST=`arg_host $DST`
|
| 38 |
|
| 39 | log "$1 $2"
|
| 40 | log "DST: $DST_PATH"
|
| 41 |
|
| 42 | DST_DIR=`dirname $DST_PATH`
|
| 43 | VOL_NAME=`echo $DST_PATH | awk -F/ '{print $4"-"$6}' | sed s/disk.//g`
|
| 44 |
|
| 45 | log "VOL_NAME: $VOL_NAME"
|
| 46 |
|
| 47 | log "Creating volume $DST_PATH and directory $DST_DIR"
|
| 48 | exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
|
| 49 | exec_and_log "ssh $DST_HOST sudo /usr/sbin/lvcreate -L25G -n $VOL_NAME xen_vg"
|
| 50 |
|
| 51 | log "Creating a link from $DST_PATH to the $VOL_NAME volume"
|
| 52 | exec_and_log "ssh $DST_HOST ln -s /dev/xen_vg/$VOL_NAME $DST_PATH"
|
| 53 |
|
| 54 | case $SRC in
|
| 55 | http://*)
|
| 56 | log "Downloading $SRC"
|
| 57 | exec_and_log "ssh $DST_HOST wget -O /tmp/$VOL_NAME.img.gz $SRC"
|
| 58 | ;;
|
| 59 |
|
| 60 | *)
|
| 61 | log "Cloning $SRC"
|
| 62 | exec_and_log "scp $SRC $DST"
|
| 63 | ;;
|
| 64 | esac
|
| 65 |
|
| 66 | #exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH"
|
| 67 | exec_and_log "ssh $DST_HOST gunzip -c /tmp/$VOL_NAME.img.gz | sudo dd
|
| 68 | of=/dev/xen_vg/$VOL_NAME bs=64k"
|
| 69 | exec_and_log "ssh $DST_HOST rm -f /tmp/$VOL_NAME.img.gz"
|