From d62afe545f987e2191c8416003b64d2d26cd731e Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Wed, 19 Jun 2013 14:44:26 +0200 Subject: [PATCH] Feature #2097: Get rid of VMware DS Get rid of VMware specific code in TM shared --- src/datastore_mad/remotes/vmware/clone | 1 - src/datastore_mad/remotes/vmware/cp | 112 ------------------------- src/datastore_mad/remotes/vmware/mkfs | 88 ------------------- src/datastore_mad/remotes/vmware/rm | 75 ----------------- src/datastore_mad/remotes/vmware/stat | 1 - src/tm_mad/common/context | 7 +- src/tm_mad/common/delete | 2 +- src/tm_mad/common/mkimage | 12 +-- src/tm_mad/shared/clone | 19 ++--- src/tm_mad/shared/cpds | 2 - src/tm_mad/shared/ln | 43 ++-------- src/tm_mad/shared/mvds | 2 - src/tm_mad/tm_common.sh | 19 ----- 13 files changed, 18 insertions(+), 365 deletions(-) delete mode 120000 src/datastore_mad/remotes/vmware/clone delete mode 100755 src/datastore_mad/remotes/vmware/cp delete mode 100755 src/datastore_mad/remotes/vmware/mkfs delete mode 100755 src/datastore_mad/remotes/vmware/rm delete mode 120000 src/datastore_mad/remotes/vmware/stat diff --git a/src/datastore_mad/remotes/vmware/clone b/src/datastore_mad/remotes/vmware/clone deleted file mode 120000 index 305cd254d4..0000000000 --- a/src/datastore_mad/remotes/vmware/clone +++ /dev/null @@ -1 +0,0 @@ -../common/clone \ No newline at end of file diff --git a/src/datastore_mad/remotes/vmware/cp b/src/datastore_mad/remotes/vmware/cp deleted file mode 100755 index 5aad7abfef..0000000000 --- a/src/datastore_mad/remotes/vmware/cp +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # -# # -# 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to copy a VM image (SRC) to the image repository as DST -# Several SRC types are supported -############################################################################### - -# -------- Set up the environment to source common tools & conf ------------ - -if [ -z "${ONE_LOCATION}" ]; then - LIB_LOCATION=/usr/lib/one -else - LIB_LOCATION=$ONE_LOCATION/lib -fi - -. $LIB_LOCATION/sh/scripts_common.sh - -DRIVER_PATH=$(dirname $0) -source ${DRIVER_PATH}/../libfs.sh - -# -------- Get cp and datastore arguments from OpenNebula core ------------ - -DRV_ACTION=$1 -ID=$2 - -UTILS_PATH="${DRIVER_PATH}/.." - -XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION" - -unset i XPATH_ELEMENTS - -while IFS= read -r -d '' element; do - XPATH_ELEMENTS[i++]="$element" -done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ - /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ - /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ - /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW) - -BASE_PATH="${XPATH_ELEMENTS[0]}" -RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}" -SAFE_DIRS="${XPATH_ELEMENTS[2]}" -SRC="${XPATH_ELEMENTS[3]}" -MD5="${XPATH_ELEMENTS[4]}" -SHA1="${XPATH_ELEMENTS[5]}" -NO_DECOMPRESS="${XPATH_ELEMENTS[6]}" -LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[7]}" - -mkdir -p "$BASE_PATH" -set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" - -DST=`generate_image_path` - -DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" "$DST"` - -COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS" - -# ------------ Copy the image to the repository ------------- - -case $SRC in -http://*|https://* ) - log "Downloading $SRC to the image repository" - - exec_and_log "$COPY_COMMAND" "Error downloading $SRC" - ;; - -*) - if [ `check_restricted $SRC` -eq 1 ]; then - log_error "Not allowed to copy images from $RESTRICTED_DIRS" - error_message "Not allowed to copy image file $SRC" - exit -1 - fi - - log "Copying local disk folder $SRC to the image repository" - - if [ -d "$SRC" ]; then - exec_and_log "cp -rf $SRC $DST" "Error copying $SRC to $DST" - else - exec_and_log "$COPY_COMMAND" "Error copying $SRC to $DST" - fi - ;; -esac - -if [ -d "$DST" -a ! -f "$DST/disk.vmdk" ]; then - BASE_DISK_FILE=`ls $DST | grep '\.vmdk$' | grep -v '\-\(flat\|delta\|s[0-9]*\)\.vmdk$'` - - exec_and_log "mv -f $DST/$BASE_DISK_FILE $DST/disk.vmdk" \ - "Error renaming disk file $BASE_DISK_FILE to disk.vmdk" -fi - -# ---------------- Get the size of the image ------------ - -echo "$DST" diff --git a/src/datastore_mad/remotes/vmware/mkfs b/src/datastore_mad/remotes/vmware/mkfs deleted file mode 100755 index 209cf771dd..0000000000 --- a/src/datastore_mad/remotes/vmware/mkfs +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # -# # -# 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to create a VM image (SRC) of size (SIZE) and formatted -# as (FS) -############################################################################### - -# -------- Set up the environment to source common tools & conf ------------ - -if [ -z "${ONE_LOCATION}" ]; then - LIB_LOCATION=/usr/lib/one -else - LIB_LOCATION=$ONE_LOCATION/lib -fi - -. $LIB_LOCATION/sh/scripts_common.sh - -DRIVER_PATH=$(dirname $0) -source ${DRIVER_PATH}/../libfs.sh - -# -------- Get mkfs and datastore arguments from OpenNebula core ------------ - -DRV_ACTION=$1 -ID=$2 - -XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" - -unset i XPATH_ELEMENTS - -while IFS= read -r -d '' element; do - XPATH_ELEMENTS[i++]="$element" -done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ - /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \ - /DS_DRIVER_ACTION_DATA/IMAGE/SIZE) - -BASE_PATH="${XPATH_ELEMENTS[0]}" -RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}" -SAFE_DIRS="${XPATH_ELEMENTS[2]}" -FSTYPE="${XPATH_ELEMENTS[3]}" -SIZE="${XPATH_ELEMENTS[4]}" - -mkdir -p "$BASE_PATH" -set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" - -DST=`generate_image_path` - -# ------------ Image to save_as disk, no need to create a FS ------------ - -if [ "$FSTYPE" = "save_as" ]; then - echo "$DST" - exit 0 -fi - -# ------------ Create the image to the repository ------------ - -DISK=$DST/disk.vmdk -DISK_TMP=$DISK.tmp - -IMAGE_FORMAT=vmdk - -exec_and_log "mkdir -p $DST" \ - "Could not create disk directory $DST" -exec_and_log "$DD if=/dev/zero of=$DISK_TMP bs=1 count=1 seek=${SIZE}M" \ - "Could not create temporary image $DISK_TMP" -exec_and_log "$QEMU_IMG convert -O $IMAGE_FORMAT $DISK_TMP $DISK" \ - "Unable to convert to $IMAGE_FORMAT in $DISK_TMP" -exec_and_log "rm -f $DISK_TMP" \ - "Unable to remove temporary disk $DISK_TMP" - -echo "$DST" diff --git a/src/datastore_mad/remotes/vmware/rm b/src/datastore_mad/remotes/vmware/rm deleted file mode 100755 index 622de290c0..0000000000 --- a/src/datastore_mad/remotes/vmware/rm +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs # -# # -# 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to remove a VM image (SRC) from the image repository -############################################################################### - -# ------------ Set up the environment to source common tools ------------ - -if [ -z "${ONE_LOCATION}" ]; then - LIB_LOCATION=/usr/lib/one -else - LIB_LOCATION=$ONE_LOCATION/lib -fi - -. $LIB_LOCATION/sh/scripts_common.sh - -DRIVER_PATH=$(dirname $0) -source ${DRIVER_PATH}/../libfs.sh - -# -------- Get rm and datastore arguments from OpenNebula core ------------ - -DRV_ACTION=$1 -ID=$2 - -XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" - -unset i XPATH_ELEMENTS - -while IFS= read -r -d '' element; do - XPATH_ELEMENTS[i++]="$element" -done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \ - /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH) - -SRC="${XPATH_ELEMENTS[0]}" -BASE_PATH="${XPATH_ELEMENTS[1]}" - -BASENAME_SRC=`basename "${SRC##$BASE_PATH}"` - -# ------------ Remove the image from the repository ------------ - -if [ -d "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ] -then - log "Removing disk $SRC from the image repository" - - exec_and_log "rm -r $SRC" \ - "Error deleting $SRC" - -else - if [ -f "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ] - then - log "Removing CDROM $SRC from the image repository" - - exec_and_log "rm $SRC" \ - "Error deleting $SRC" - else - log_error "Bad formed or unavailable Image source: ${SRC}" - exit 1 - fi -fi diff --git a/src/datastore_mad/remotes/vmware/stat b/src/datastore_mad/remotes/vmware/stat deleted file mode 120000 index 65583e827b..0000000000 --- a/src/datastore_mad/remotes/vmware/stat +++ /dev/null @@ -1 +0,0 @@ -../common/stat \ No newline at end of file diff --git a/src/tm_mad/common/context b/src/tm_mad/common/context index 08a1f33f3c..dfcf5d1715 100755 --- a/src/tm_mad/common/context +++ b/src/tm_mad/common/context @@ -52,6 +52,10 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +#------------------------------------------------------------------------------- +# Create DST path +#------------------------------------------------------------------------------- + ssh_make_path $DST_HOST $DST_DIR #------------------------------------------------------------------------------- @@ -96,9 +100,6 @@ exec_and_set_error "$MKISOFS -o $ISO_FILE -J -R $ISO_DIR" \ exec_and_set_error "$SCP $ISO_FILE $DST" "Error copying context ISO to $DST" [ -n "$ERROR" ] && exit_error -# Creates symbolic link to add a .iso suffix, needed for VMware CDROMs -ssh_exec_and_log $DST_HOST "$LN -s $DST_PATH $DST_PATH.iso" "Error creating ISO symbolic link" - rm -rf $ISO_DIR > /dev/null 2>&1 exit 0 diff --git a/src/tm_mad/common/delete b/src/tm_mad/common/delete index c997810b38..73cc054e65 100755 --- a/src/tm_mad/common/delete +++ b/src/tm_mad/common/delete @@ -43,6 +43,6 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` log "Deleting $DST_PATH" -ssh_exec_and_log $DST_HOST "rm -rf $DST_PATH" "Error deleting $DST_PATH" +ssh_exec_and_log $DST_HOST "rm -f $DST_PATH" "Error deleting $DST_PATH" exit 0 diff --git a/src/tm_mad/common/mkimage b/src/tm_mad/common/mkimage index 08263bfd71..c61734b18f 100755 --- a/src/tm_mad/common/mkimage +++ b/src/tm_mad/common/mkimage @@ -49,17 +49,9 @@ DST_DIR=`dirname $DST_PATH` #------------------------------------------------------------------------------- # Make the new image (file-based) #------------------------------------------------------------------------------- -case "$FSTYPE" in - "vmdk_"*) - ssh_make_path $DST_HOST $DST_PATH - CREATE_IMAGE="" - ;; - *) - ssh_make_path $DST_HOST $DST_DIR - CREATE_IMAGE="$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" - ;; -esac +ssh_make_path $DST_HOST $DST_DIR +CREATE_IMAGE="$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE $SIZE` MKSCRIPT=$(cat <