mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Added sample tm scripts
git-svn-id: http://svn.opennebula.org/one/trunk@272 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
38ee9466e1
commit
9ef3ea451d
16
install.sh
16
install.sh
@ -30,7 +30,7 @@ if [ -z "$SRC_DIR" -o -z "$DST_DIR" ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
DIRS="/bin /include /etc /etc/im_kvm /etc/im_xen /etc/vmm_kvm /etc/vmm_xen /libexec /lib/ruby /var /share/examples /lib/im_probes /lib/tm_commands/nfs /lib/tm_commands/ssh /lib/tm_commands/dummy /etc/vmm_ec2 /etc/im_ec2 /etc/tm_nfs /etc/tm_ssh"
|
||||
DIRS="/bin /include /etc /etc/im_kvm /etc/im_xen /etc/vmm_kvm /etc/vmm_xen /libexec /lib/ruby /var /share/examples /share/examples/tm /lib/im_probes /lib/tm_commands/nfs /lib/tm_commands/ssh /lib/tm_commands/dummy /etc/vmm_ec2 /etc/im_ec2 /etc/tm_nfs /etc/tm_ssh"
|
||||
|
||||
for d in $DIRS; do
|
||||
mkdir -p $DST_DIR$d
|
||||
@ -153,8 +153,14 @@ inst_ln src/tm_mad/dummy/tm_dummy.sh lib/tm_commands/dummy
|
||||
|
||||
# --- Examples ---
|
||||
|
||||
inst_cp share/examples/vm.template share/examples
|
||||
inst_cp share/examples/vm.schema share/examples
|
||||
inst_cp share/examples/private.net share/examples
|
||||
inst_cp share/examples/public.net share/examples
|
||||
inst_cp share/examples/vm.template share/examples
|
||||
inst_cp share/examples/vm.schema share/examples
|
||||
inst_cp share/examples/private.net share/examples
|
||||
inst_cp share/examples/public.net share/examples
|
||||
|
||||
inst_cp share/examples/tmp/tm_clone.sh share/examples/tm
|
||||
inst_cp share/examples/tmp/tm_delete.sh share/examples/tm
|
||||
inst_cp share/examples/tmp/tm_ln.sh share/examples/tm
|
||||
inst_cp share/examples/tmp/tm_mkimage.sh share/examples/tm
|
||||
inst_cp share/examples/tmp/tm_mkswap.sh share/examples/tm
|
||||
inst_cp share/examples/tmp/tm_mv.sh share/examples/tm
|
||||
|
34
share/examples/tm/tm_clone.sh
Executable file
34
share/examples/tm/tm_clone.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
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"
|
||||
exec_and_log "ssh $DST_HOST chmod a+w $DST_DIR"
|
||||
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC"
|
||||
exec_and_log "ssh $DST_HOST wget -O $DST_PATH $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Cloning $SRC_PATH"
|
||||
exec_and_log "ssh $DST_HOST cp $SRC_PATH $DST_PATH"
|
||||
;;
|
||||
esac
|
||||
|
||||
exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH"
|
||||
|
12
share/examples/tm/tm_delete.sh
Executable file
12
share/examples/tm/tm_delete.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
|
||||
log "Deleting $SRC_PATH"
|
||||
exec_and_log "ssh $SRC_HOST rm -rf $SRC_PATH"
|
19
share/examples/tm/tm_ln.sh
Executable file
19
share/examples/tm/tm_ln.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Creating directory $DST_DIR"
|
||||
exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
|
||||
|
||||
|
||||
log "Link $SRC_PATH"
|
||||
exec_and_log "ssh $DST_HOST ln -s $SRC_PATH $DST_PATH"
|
5
share/examples/tm/tm_mkimage.sh
Executable file
5
share/examples/tm/tm_mkimage.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
log "mkimage placeholder"
|
18
share/examples/tm/tm_mkswap.sh
Executable file
18
share/examples/tm/tm_mkswap.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
SIZE=$1
|
||||
DST=$2
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
log "Creating ${SIZE}Mb image in $DST_PATH"
|
||||
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"
|
||||
|
24
share/examples/tm/tm_mv.sh
Executable file
24
share/examples/tm/tm_mv.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
|
||||
. $ONE_LOCATION/libexec/tm_common.sh
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
if [ "$SRC_PATH" == "$DST_PATH" ]; then
|
||||
log "Will not move, source and destination are equal"
|
||||
else
|
||||
# Is saving a disk image?
|
||||
echo "$DST_PATH" | egrep -e "^$ONE_LOCATION/var/.+/disk\..+$"
|
||||
if [ "x$?" == "x0" ]; then
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "ssh $DST_HOST mv $SRC_PATH $DST_PATH"
|
||||
else
|
||||
log "Will not move, is not saving image"
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user