diff --git a/install.sh b/install.sh index 3215a0d39b..a8fa3f8afe 100755 --- a/install.sh +++ b/install.sh @@ -228,7 +228,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/tm/shared \ $VAR_LOCATION/remotes/tm/qcow2 \ $VAR_LOCATION/remotes/tm/ssh \ - $VAR_LOCATION/remotes/tm/vmware \ + $VAR_LOCATION/remotes/tm/vmfs \ $VAR_LOCATION/remotes/tm/iscsi \ $VAR_LOCATION/remotes/tm/lvm \ $VAR_LOCATION/remotes/hooks \ @@ -237,6 +237,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/datastore/dummy \ $VAR_LOCATION/remotes/datastore/fs \ $VAR_LOCATION/remotes/datastore/vmware \ + $VAR_LOCATION/remotes/datastore/vmfs \ $VAR_LOCATION/remotes/datastore/iscsi \ $VAR_LOCATION/remotes/datastore/lvm \ $VAR_LOCATION/remotes/auth \ @@ -416,7 +417,7 @@ INSTALL_FILES=( TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared TM_QCOW2_FILES:$VAR_LOCATION/remotes/tm/qcow2 TM_SSH_FILES:$VAR_LOCATION/remotes/tm/ssh - TM_VMWARE_FILES:$VAR_LOCATION/remotes/tm/vmware + TM_VMFS_FILES:$VAR_LOCATION/remotes/tm/vmfs TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi TM_LVM_FILES:$VAR_LOCATION/remotes/tm/lvm TM_DUMMY_FILES:$VAR_LOCATION/remotes/tm/dummy @@ -424,6 +425,7 @@ INSTALL_FILES=( DATASTORE_DRIVER_DUMMY_SCRIPTS:$VAR_LOCATION/remotes/datastore/dummy DATASTORE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/datastore/fs DATASTORE_DRIVER_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmware + DATASTORE_DRIVER_VMFS_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmfs DATASTORE_DRIVER_ISCSI_SCRIPTS:$VAR_LOCATION/remotes/datastore/iscsi DATASTORE_DRIVER_LVM_SCRIPTS:$VAR_LOCATION/remotes/datastore/lvm NETWORK_FILES:$VAR_LOCATION/remotes/vnm @@ -877,16 +879,17 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \ src/tm_mad/dummy/postmigrate \ src/tm_mad/dummy/mvds" -TM_VMWARE_FILES="src/tm_mad/vmware/clone \ - src/tm_mad/vmware/delete - src/tm_mad/vmware/ln \ - src/tm_mad/vmware/mkswap \ - src/tm_mad/vmware/mkimage \ - src/tm_mad/vmware/mv \ - src/tm_mad/vmware/context \ - src/tm_mad/vmware/premigrate \ - src/tm_mad/vmware/postmigrate \ - src/tm_mad/vmware/mvds" +TM_VMFS_FILES="src/tm_mad/vmfs/clone \ + src/tm_mad/vmfs/delete + src/tm_mad/vmfs/ln \ + src/tm_mad/vmfs/mkswap \ + src/tm_mad/vmfs/mkimage \ + src/tm_mad/vmfs/mv \ + src/tm_mad/vmfs/context \ + src/tm_mad/vmfs/mvds \ + src/tm_mad/vmfs/tm_vmfs.conf \ + src/tm_mad/vmfs/postmigrate \ + src/tm_mad/vmfs/premigrate" TM_ISCSI_FILES="src/tm_mad/iscsi/clone \ src/tm_mad/iscsi/ln \ @@ -909,6 +912,7 @@ TM_LVM_FILES="src/tm_mad/lvm/clone \ # - Dummy Image Repository, $REMOTES_LOCATION/datastore/dummy # - FS based Image Repository, $REMOTES_LOCATION/datastore/fs # - VMware based Image Repository, $REMOTES_LOCATION/datastore/vmware +# - VMFS based Image Repository, $REMOTES_LOCATION/datastore/vmfs # - iSCSI based Image Repository, $REMOTES_LOCATION/datastore/iscsi # - LVM based Image Repository, $REMOTES_LOCATION/datastore/lvm #------------------------------------------------------------------------------- @@ -935,6 +939,13 @@ DATASTORE_DRIVER_VMWARE_SCRIPTS="src/datastore_mad/remotes/vmware/cp \ src/datastore_mad/remotes/vmware/clone \ src/datastore_mad/remotes/vmware/rm" +DATASTORE_DRIVER_VMFS_SCRIPTS="src/datastore_mad/remotes/vmfs/cp \ + src/datastore_mad/remotes/vmfs/mkfs \ + src/datastore_mad/remotes/vmfs/stat \ + src/datastore_mad/remotes/vmfs/clone \ + src/datastore_mad/remotes/vmfs/rm \ + src/datastore_mad/remotes/vmfs/vmfs.conf" + DATASTORE_DRIVER_ISCSI_SCRIPTS="src/datastore_mad/remotes/iscsi/cp \ src/datastore_mad/remotes/iscsi/mkfs \ src/datastore_mad/remotes/iscsi/stat \ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index dfb86a9984..a13a3e0156 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -286,7 +286,7 @@ VM_MAD = [ TM_MAD = [ executable = "one_tm", - arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmware,iscsi" ] + arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmfs,iscsi" ] #******************************************************************************* # Datastore Driver Configuration @@ -303,7 +303,7 @@ TM_MAD = [ DATASTORE_MAD = [ executable = "one_datastore", - arguments = "-t 15 -d fs,vmware,iscsi,lvm" + arguments = "-t 15 -d fs,vmware,vmfs,iscsi,lvm" ] #******************************************************************************* diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index 98256594d4..6a67129b83 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -894,20 +894,18 @@ function popUpCreateVMDialog(){ $('#network_box,#disk_box',dialog).change(function(){ - $(this).val(""); - return false; - }); - - $('#network_box option,#disk_box option',dialog).click(function(){ - var clicked = $(this).attr('clicked'); + var option = $('option:selected', this); + var clicked = option.attr('clicked'); if (clicked){//unbold, unmark - $(this).text($(this).text().replace(/☒/g,'☐')); - $(this).removeAttr('clicked'); + option.text(option.text().replace(/☒/g,'☐')); + option.removeAttr('clicked'); } else {//bold,mark - $(this).text($(this).text().replace(/☐/g,'☒')); - $(this).attr('clicked','clicked'); + option.text(option.text().replace(/☐/g,'☒')); + option.attr('clicked','clicked'); } + + $(this).val(""); return false; }); diff --git a/src/datastore_mad/remotes/libfs.sh b/src/datastore_mad/remotes/libfs.sh index 394b7a3d3b..59c97f406f 100644 --- a/src/datastore_mad/remotes/libfs.sh +++ b/src/datastore_mad/remotes/libfs.sh @@ -152,3 +152,15 @@ function check_restricted { echo 0 } + +#------------------------------------------------------------------------------- +# Gets the ESX host to be used as bridge to register a VMware disk +# Implements a round robin for the bridges +# @param $1 - Path to the list of ESX hosts to be used as bridges +# @return host to be used as bridge +#------------------------------------------------------------------------------- +function get_destination_host { + HOSTS_ARRAY=($BRIDGE_LIST) + ARRAY_INDEX=`expr $1 % ${#HOSTS_ARRAY[@]}` + echo ${HOSTS_ARRAY[$ARRAY_INDEX]} +} diff --git a/src/datastore_mad/remotes/vmfs/clone b/src/datastore_mad/remotes/vmfs/clone new file mode 100755 index 0000000000..bed2c43de7 --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/clone @@ -0,0 +1,89 @@ +#!/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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# 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 + VMWARERC=/etc/one/vmwarerc +else + LIB_LOCATION=$ONE_LOCATION/lib + VMWARERC=$ONE_LOCATION/etc/vmwarerc +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/vmfs.conf + +# -------- Get cp 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/UMASK \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DS_USE_SSH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/ID \ + /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ + /DS_DRIVER_ACTION_DATA/IMAGE/ID) + +BASE_PATH="${XPATH_ELEMENTS[0]}" +UMASK="${XPATH_ELEMENTS[1]}" +BRIDGE_LIST="${XPATH_ELEMENTS[2]}" +USE_SSH="${XPATH_ELEMENTS[3]:-$DS_USE_SSH}" +DS_ID="${XPATH_ELEMENTS[4]}" +SRC="${XPATH_ELEMENTS[5]}" +IMAGE_ID="${XPATH_ELEMENTS[6]}" + +SRC_FOLDER=`basename $SRC` +DST=`generate_image_path` +DST_FOLDER=`basename $DST` +DST_HOST=`get_destination_host $IMAGE_ID` + +# ------------ Set up datastore ------------- + +set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" + +vmfs_set_up + +# ------------ Copy the image to the repository ------------- + +log "Copying local image $SRC to the image repository" + +if [ "$USE_SSH" == "yes" ]; then + ssh_exec_and_log "$VMKFSTOOLS $VI_PARAMS $SRC $DST" "Error copying $SRC to $DST" +else + exec_and_log "vifs $VI_PARAMS --copy [$DS_ID]$SRC_FOLDER [$DS_ID]$DST_FOLDER" \ + "Error copying $SRC to $DST" +fi + +echo "$DST" diff --git a/src/datastore_mad/remotes/vmfs/cp b/src/datastore_mad/remotes/vmfs/cp new file mode 100755 index 0000000000..f0d49bfc0f --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/cp @@ -0,0 +1,162 @@ +#!/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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# 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 + VMWARERC=/etc/one/vmwarerc +else + LIB_LOCATION=$ONE_LOCATION/lib + VMWARERC=$ONE_LOCATION/etc/vmwarerc +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/vmfs.conf + +# -------- 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/ID \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DS_USE_SSH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DS_TMP_DIR \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \ + /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ + /DS_DRIVER_ACTION_DATA/IMAGE/ID) + +BASE_PATH="${XPATH_ELEMENTS[0]}" +DS_ID="${XPATH_ELEMENTS[1]}" +RESTRICTED_DIRS="${XPATH_ELEMENTS[2]}" +SAFE_DIRS="${XPATH_ELEMENTS[3]}" +BRIDGE_LIST="${XPATH_ELEMENTS[4]}" +USE_SSH="${XPATH_ELEMENTS[5]:-$DS_USE_SSH}" +TMP_DIR="${XPATH_ELEMENTS[6]:-$DS_TMP_DIR}" +UMASK="${XPATH_ELEMENTS[7]}" +SRC="${XPATH_ELEMENTS[8]}" +MD5="${XPATH_ELEMENTS[9]}" +SHA1="${XPATH_ELEMENTS[10]}" +IMAGE_ID="${XPATH_ELEMENTS[11]}" + +FE_DST=`generate_image_path` +DST_FOLDER=`basename $FE_DST` +DST="/vmfs/volumes/$DS_ID/$DST_FOLDER" +DST_HOST=`get_destination_host $IMAGE_ID` + + +# ------------ Set up datastore ------------- + +set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" + +vmfs_set_up + +vmfs_create_remote_path $DS_ID + +# ------------ Prepare for a possible download in the front-end ------------- + +if [ ! -d $TMP_DIR ]; then + mkdir -p $TMP_DIR +fi + +HASHES="" + +if [ -n "$MD5" ]; then + HASHES="$HASHES --md5 $MD5" +fi + +if [ -n "$SHA1" ]; then + HASHES="$HASHES --sha1 $SHA1" +fi + +COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC $TMP_DIR/$IMAGE_HASH" + +# ------------ 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" + + SRC="$TMP_DIR/$IMAGE_HASH" + ;; + +*) + 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 "$COPY_COMMAND" "Error copying $SRC to $TMP_DIR/$IMAGE_HASH" + SRC="$TMP_DIR/$IMAGE_HASH" + fi + ;; +esac + +# Rename the disk filename to disk.vmdk (warning: it does so in SRC) +if [ ! -f $SRC/disk.vmdk ]; then + BASE_DISK_FILE=`ls $SRC | grep -v '\-\(flat\|delta\|s[0-9]*\)\.vmdk$'` + + exec_and_log "mv -f $SRC/$BASE_DISK_FILE $SRC/disk.vmdk" \ + "Error renaming disk file $SRC/$BASE_DISK_FILE to $SRC/disk.vmdk" +fi + +# Make the final hop, front-end -> VMFS Datastore +if [ "$USE_SSH" == "yes" ]; then + exec_and_log "$SCP -r $SRC/* $DST_HOST:$DST" "Error copying $SRC to $DST through SCP" +else + cd $SRC + for file in $(find . -type f); do + FNAME=$(basename $file) + exec_and_log "vifs $VI_PARAMS -p $file [$DS_ID]$DST_FOLDER/$FNAME" \ + "Cannot upload $file to $DST/$FNAME on $DST_HOST" + done +fi + +if [ -d "$TMP_DIR/$IMAGE_HASH" -a -n "$IMAGE_HASH" ]; then + rm -rf "$TMP_DIR/$IMAGE_HASH" > /dev/null 2>&1 +fi + +echo "$DST" diff --git a/src/datastore_mad/remotes/vmfs/mkfs b/src/datastore_mad/remotes/vmfs/mkfs new file mode 100755 index 0000000000..63a6784738 --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/mkfs @@ -0,0 +1,107 @@ +#!/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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# 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 + VMWARERC=/etc/one/vmwarerc +else + LIB_LOCATION=$ONE_LOCATION/lib + VMWARERC=$ONE_LOCATION/etc/vmwarerc +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/vmfs.conf + +# -------- 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/DATASTORE/TEMPLATE/UMASK \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DS_USE_SSH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/ID \ + /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \ + /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \ + /DS_DRIVER_ACTION_DATA/IMAGE/ID) + +BASE_PATH="${XPATH_ELEMENTS[0]}" +RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}" +SAFE_DIRS="${XPATH_ELEMENTS[2]}" +UMASK="${XPATH_ELEMENTS[3]}" +USE_SSH="${XPATH_ELEMENTS[4]:-$DS_USE_SSH}" +DS_ID="${XPATH_ELEMENTS[5]}" +FSTYPE="${XPATH_ELEMENTS[6]}" +SIZE="${XPATH_ELEMENTS[7]}" +IMAGE_ID="${XPATH_ELEMENTS[8]}" +DST=`generate_image_path` +DST_DIR=`dirname $DST` +DST_FOLDER=`basename $DST` +DST_HOST=`get_destination_host $IMAGE_ID` + +# ------------ Set up datastore ------------- + +set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" + +vmfs_set_up + +vmfs_create_remote_path $DS_ID + +# ------------ Image to save_as disk, no need to create a FS ------------ + +if [ "$FSTYPE" = "save_as" ]; then + echo "$DST" + exit 0 +fi + +# ------------ Create the image within the image datastore ------------ + +log "Making filesystem of ${SIZE}M (with no format) at [$DS_ID]$DST_FOLDER on $DST_HOST" + +IMAGE_FORMAT=vmdk +VMWARE_DISK_TYPE=`echo $FSTYPE|cut -d'_' -f 2` + +if [ "$USE_SSH" == "yes" ]; then + $SSH $DST_HOST $VMKFSTOOLS -U [$DS_ID]$DST_FOLDER/disk.vmdk &> /dev/null + ssh_exec_and_log $DST_HOST "$VMKFSTOOLS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} /vmfs/volumes/$DS_ID/$DST_FOLDER/disk.vmdk" \ + "Cannot create [$DS_ID] $DST_FOLDER/disk.vmdk on $DST_HOST" +else + $VMKFSTOOLS $VI_PARAMS -U [$DS_ID]$DST_FOLDER/disk.vmdk &> /dev/null + exec_and_log "$VMKFSTOOLS $VI_PARAMS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} [$DS_ID]$DST_FOLDER/disk.vmdk" \ + "Cannot create $DS_ID]$DST_FOLDER/disk.vmdk on $DST_HOST" +fi + +echo "/vmfs/volumes/$DS_ID/$DST_FOLDER" diff --git a/src/datastore_mad/remotes/vmfs/rm b/src/datastore_mad/remotes/vmfs/rm new file mode 100755 index 0000000000..a5a6b1eed2 --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/rm @@ -0,0 +1,87 @@ +#!/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. # +#--------------------------------------------------------------------------- # + +############################################################################### +# 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 + VMWARERC=/etc/one/vmwarerc +else + LIB_LOCATION=$ONE_LOCATION/lib + VMWARERC=$ONE_LOCATION/etc/vmwarerc +fi + +. $LIB_LOCATION/sh/scripts_common.sh + +DRIVER_PATH=$(dirname $0) +source ${DRIVER_PATH}/../libfs.sh +source ${DRIVER_PATH}/vmfs.conf + +# -------- 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/ID \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/DS_USE_SSH \ + /DS_DRIVER_ACTION_DATA/IMAGE/ID) + +SRC="${XPATH_ELEMENTS[0]}" +DS_ID="${XPATH_ELEMENTS[1]}" +USE_SSH="${XPATH_ELEMENTS[4]:-$DS_USE_SSH}" +IMAGE_ID="${XPATH_ELEMENTS[2]}" + +DST_HOST=`get_destination_host $IMAGE_ID` +DST_FOLDER=`basename $SRC` + +# ------------ Set up datastore ------------ + +vmfs_set_up + +# ------------ Remove the image from the repository ------------ + +log "Removing $SRC from the image repository" + +if [ "$USE_SSH" == "yes" ]; then + if [ -n $DS_ID -a -n $DST_FOLDER ]; then + ssh_exec_and_log $DST_HOST "rm -rf /vmfs/volumes/$DS_ID/$DST_FOLDER" \ + "Error deleting $SRC" + fi +else + # We have to erase the contents of the folder one by one + FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DS_ID]$DST_FOLDER|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"` + for file in $FILES_TO_ERASE; do + exec_and_log "vifs $VI_PARAMS --force --rm [$DS_ID]$DST_FOLDER/$file" \ + "Cannot delete $DST_FOLDER/$file in $DST_HOST" + done + exec_and_log "vifs $VI_PARAMS --force --rm [$DS_ID]$DST_FOLDER" \ + "Cannot delete $DST_FOLDER in $DST_HOST" +fi + +exit 0 diff --git a/src/datastore_mad/remotes/vmfs/stat b/src/datastore_mad/remotes/vmfs/stat new file mode 120000 index 0000000000..65583e827b --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/stat @@ -0,0 +1 @@ +../common/stat \ No newline at end of file diff --git a/src/datastore_mad/remotes/vmfs/vmfs.conf b/src/datastore_mad/remotes/vmfs/vmfs.conf new file mode 100644 index 0000000000..34add2dd41 --- /dev/null +++ b/src/datastore_mad/remotes/vmfs/vmfs.conf @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- # +# 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. # +#--------------------------------------------------------------------------- # + +# Default values in case they are not defined in the Datastore template + +DS_TMP_DIR=/var/lib/one/tmp + +# Whether the VMFS Datastore driver should use to invoke the VMFS native commands +# * remote API calls (value set to "no") +# * ssh connection (value set to "yes") + +DS_USE_SSH=no diff --git a/src/im_mad/remotes/vmware.d/vmware.rb b/src/im_mad/remotes/vmware.d/vmware.rb index 661f7c304e..cd02f42fbe 100755 --- a/src/im_mad/remotes/vmware.d/vmware.rb +++ b/src/im_mad/remotes/vmware.d/vmware.rb @@ -99,7 +99,11 @@ conf = YAML::load(File.read(CONF_FILE)) @uri = conf[:libvirt_uri].gsub!('@HOST@', host) @user = conf[:username] -@pass = conf[:password] +if conf[:password] and !conf[:password].empty? + @pass=conf[:password] +else + @pass="\"\"" +end # Poll the VMware hypervisor diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index f0f346a82b..74ae5eb7e9 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -409,3 +409,37 @@ function iqn_get_host { VG_NAME=$(iqn_get_vg_name "$IQN") echo ${TARGET%%.$VG_NAME.$LV_NAME} } + +function vmfs_create_remote_path { + DS_ID=$1 + # Create DST in DST_HOST + if [ "$USE_SSH" == "yes" ]; then + exec_and_log "ssh_make_path $DST_HOST $DST" \ + "Cannot create $DST in $DST_HOST" + else + exec_and_log "vifs $VI_PARAMS --mkdir [$DS_ID]$DST_FOLDER" \ + "Cannot create [$DS_ID]$DST_FOLDER in $DST_HOST" + fi +} + +function vmfs_set_up { + if [ "$USE_SSH" != "yes" ]; then + USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')` + PASSWORD=`echo $(cat $VMWARERC |grep ":password:"|cut -d":" -f 3|tr -d '"')` + if [ -z $PASSWORD ]; then + VI_PARAMS="--server $DST_HOST --username $USERNAME --password \"\"" + else + VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD" + fi + fi +} + +function vmfs_create_double_path { + DS_ID=$1 + FIRST_FOLDER=$2 + SECOND_FOLDER=$3 + # Two calls needed since vifs cannot do a mkdir -p + vifs $VI_PARAMS --force --mkdir [$DS_ID]$FIRST_FOLDER &> /dev/null + vifs $VI_PARAMS --force --mkdir [$DS_ID]$FIRST_FOLDER/$SECOND_FOLDER &> /dev/null + +} diff --git a/src/sunstone/public/js/layout.js b/src/sunstone/public/js/layout.js index 7ebae4c5ad..049e895644 100644 --- a/src/sunstone/public/js/layout.js +++ b/src/sunstone/public/js/layout.js @@ -128,7 +128,7 @@ $(document).ready(function () { applyDefaultStyles: false , center__paneSelector: ".outer-center" , west__paneSelector: ".outer-west" - , west__size: 200 + , west__size: 210 , north__size: 26 , south__size: 26 , spacing_open: 0 // ALL panes diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index 6e9f886618..931de0179a 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -73,8 +73,8 @@ var create_datastore_tmpl = \ \ \ -
\ - \ +
\ + \