diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 9b939eb2ed..9201d919a9 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -187,6 +187,10 @@ function mkfs_command { echo "" return 0 ;; + "swap") + echo "$MKSWAP $DST" + return 0 + ;; *) OPTS="" ;; diff --git a/src/tm_mad/shared/mkimage b/src/tm_mad/shared/mkimage index 7f1ccc11cd..d651075dcc 100755 --- a/src/tm_mad/shared/mkimage +++ b/src/tm_mad/shared/mkimage @@ -60,6 +60,6 @@ MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST_PATH" -if [ -n $MKFS_CMD ]; then +if [ -n "$MKFS_CMD" ]; then exec_and_log "$MKFS_CMD" "Unable to create filesystem $FSTYPE in $DST_PATH" fi \ No newline at end of file diff --git a/src/tm_mad/shared/mkswap b/src/tm_mad/shared/mkswap index bde0ea0b9f..51ac4d96a1 100755 --- a/src/tm_mad/shared/mkswap +++ b/src/tm_mad/shared/mkswap @@ -16,36 +16,13 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +# mkswap size host:remote_system_ds/disk.i size +# - size in MB of 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 DST=$2 -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 - -DST_PATH=`arg_path $DST` - -fix_dst_path - -DST_DIR=`dirname $DST_PATH` - -log_debug "Creating directory $DST_DIR" -exec_and_log "mkdir -p $DST_DIR" -exec_and_log "chmod a+w $DST_DIR" - -log_debug "Creating ${SIZE}Mb image in $DST_PATH" -exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ - "Could not create image file $DST_PATH" - -log_debug "Initializing swap space" -exec_and_log "$MKSWAP $DST_PATH" \ - "Could not create swap on $DST_PATH" - -exec_and_log "chmod a+w $DST_PATH" - +CMD="`dirname $0`/mkimage $SIZE swap $DST" +`$CMD`