Skip to content

Commit

Permalink
Bug OpenNebula#1373: Volatile disks can now be created in VMware
Browse files Browse the repository at this point in the history
  • Loading branch information
tinova committed Jul 18, 2012
1 parent 228933c commit 2730056
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/mad/sh/scripts_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ function mkfs_command {
echo "$MKSWAP $DST"
return 0
;;
"vmdk_*")
VMWARE_DISK_TYPE=`echo $FSTYPE|cut -d'_' -f 1`
"vmdk_"*)
VMWARE_DISK_TYPE=`echo $FSTYPE|cut -d'_' -f 2`
echo "WHICH_SUDO=\$(which sudo) ; \
[ ! -z \"\$WHICH_SUDO\" -a -f \"\$WHICH_SUDO\" ] && SUDO=\"sudo\" ; \
$SUDO $VMKFSTOOLS -U $DST/disk.vmdk; \
$SUDO $VMKFSTOOLS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST_PATH/disk.vmdk"
\$SUDO $VMKFSTOOLS -U $DST/disk.vmdk; \
\$SUDO $VMKFSTOOLS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST/disk.vmdk"
return 0
;;
*)
Expand Down
1 change: 0 additions & 1 deletion src/tm_mad/vmware/mkimage

This file was deleted.

69 changes: 69 additions & 0 deletions src/tm_mad/vmware/mkimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/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. #
#--------------------------------------------------------------------------- #

# mkimage size format host:remote_system_ds/disk.i vmid dsid
# - 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
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)

SIZE=$1
FSTYPE=$2
DST=$3

VMID=$4
DSID=$5

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`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`

ssh_make_path $DST_HOST $DST_DIR

#-------------------------------------------------------------------------------
# Make the new image (file-based)
#-------------------------------------------------------------------------------
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE $SIZE`

CREATE_IMAGE="mkdir -p $DST_PATH"

MKSCRIPT=$(cat <<EOF
export PATH=/usr/sbin:/sbin:\$PATH
$CREATE_IMAGE
$MKFS_CMD
EOF
)

log "Making filesystem of ${SIZE}M and type $FSTYPE at $DST"

ssh_exec_and_log $DST_HOST "$MKSCRIPT" "Could not create image $DST_PATH"

exit 0

0 comments on commit 2730056

Please sign in to comment.