mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1112: clone, ln, mkimage, delete are now functional for tm_shared. Added none fs type for images
This commit is contained in:
parent
c58dd74666
commit
1da7f89f5e
@ -36,6 +36,7 @@ SED=sed
|
||||
SSH=ssh
|
||||
SUDO=sudo
|
||||
WGET=wget
|
||||
GREP=grep
|
||||
|
||||
# Used for log messages
|
||||
SCRIPT_NAME=`basename $0`
|
||||
@ -182,6 +183,10 @@ function mkfs_command {
|
||||
"jfs")
|
||||
OPTS="-q"
|
||||
;;
|
||||
"none")
|
||||
echo ""
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
OPTS=""
|
||||
;;
|
||||
|
@ -16,23 +16,36 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
# DELETE <host:remote_system_ds/disk.i|host:remote_system_ds/>
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
DST=$1
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/usr/lib/one/mads/tm_common.sh
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
get_vmdir
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
# Return if deleting a disk, we will delete them when removing the
|
||||
# remote_system_ds directory for the VM
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
DST_PATH=`arg_path $DST`
|
||||
|
||||
fix_src_path
|
||||
if [ `is_disk $DST_PATH` -eq 1 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log "Deleting $SRC_PATH"
|
||||
exec_and_log "rm -rf $SRC_PATH" \
|
||||
"Error deleting $SRC_PATH"
|
||||
set_ds_location
|
||||
|
||||
REL_DST_PATH=${DST_PATH##"$DS_LOCATION/"}
|
||||
DST_PATH="$ONE_LOCAL_VAR/datastores/$REL_DST_PATH"
|
||||
|
||||
log "Deleting $DST_PATH"
|
||||
exec_and_log "rm -rf $DST_PATH" "Error deleting $DST_PATH"
|
||||
|
@ -16,33 +16,50 @@
|
||||
# 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
|
||||
|
||||
get_vmdir
|
||||
# mkimage size format host:remote_system_ds/disk.i size
|
||||
# - size in MB of the image
|
||||
# - format for the image
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SIZE=$1
|
||||
FSTYPE=$2
|
||||
DST=$3
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
DST_PATH=`arg_path $DST`
|
||||
|
||||
fix_dst_path
|
||||
set_ds_location
|
||||
|
||||
REL_DST_PATH=${DST_PATH##"$DS_LOCATION/"}
|
||||
DST_PATH="$ONE_LOCAL_VAR/datastores/$REL_DST_PATH"
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
if [ ! -d $DST_DIR ]; then
|
||||
log "Creating directory $DST_DIR"
|
||||
exec_and_log "mkdir -p $DST_DIR"
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Make the new image (file-based)
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
|
||||
|
||||
exec_and_log "mkdir -p $DST_DIR" \
|
||||
"Error creating directory $DST_DIR"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST_PATH"
|
||||
exec_and_log "$MKFS_CMD" \
|
||||
"Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
exec_and_log "chmod a+rw $DST_PATH"
|
||||
|
||||
if [ -n $MKFS_CMD ]; then
|
||||
exec_and_log "$MKFS_CMD" "Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
fi
|
@ -1,50 +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
|
||||
VAR_LOCATION=/var/lib/one/
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
||||
VAR_LOCATION=$ONE_LOCATION/var/
|
||||
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
|
||||
if [ -d "$SRC_PATH" ]; then
|
||||
log "Will not move, is not saving image"
|
||||
else
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH" \
|
||||
"Could not move $SRC_PATH to $DST_PATH"
|
||||
fi
|
||||
fi
|
||||
|
1
src/tm_mad/shared/mv
Symbolic link
1
src/tm_mad/shared/mv
Symbolic link
@ -0,0 +1 @@
|
||||
../dummy/dummy.sh
|
@ -56,6 +56,18 @@ function arg_path
|
||||
#Return the DATASTORE_LOCATION from OpenNebula configuration
|
||||
function set_ds_location
|
||||
{
|
||||
DS_LOCATION=`grep '^DATASTORE_LOCATION=' $ONE_LOCAL_VAR/config | cut -d= -f2`
|
||||
DS_LOCATION=`$GREP '^DATASTORE_LOCATION=' $ONE_LOCAL_VAR/config | cut -d= -f2`
|
||||
DS_LOCATION=`fix_dir_slashes $DS_LOCATION`
|
||||
}
|
||||
|
||||
#Return 1 if the first argument is a disk
|
||||
function is_disk
|
||||
{
|
||||
echo "$1" | $GREP '/disk\.[0-9]\+' > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user