mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-27 14:03:40 +03:00
feature #1437: Change USE_SSH retrieval in TM VMFS
This commit is contained in:
parent
f2c52b0b7a
commit
973bd016ab
@ -1,23 +0,0 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
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")
|
||||
|
||||
USE_SSH=no
|
@ -88,3 +88,25 @@ function make_relative {
|
||||
|
||||
echo $dots${src#$common/}
|
||||
}
|
||||
|
||||
# Gets wether the vmfs drivers should use ssh or not
|
||||
function get_tm_use_ssh {
|
||||
DATASTORE_ID=$1
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get datastore information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
XPATH="$(dirname 0)/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onedatastore show -x $DATASTORE_ID| $XPATH \
|
||||
/DATASTORE/TEMPLATE/TM_USE_SSH)
|
||||
|
||||
TM_USE_SSH="${XPATH_ELEMENTS[0]:-$TM_USE_SSH}"
|
||||
|
||||
echo $TM_USE_SSH
|
||||
}
|
||||
|
@ -39,11 +39,10 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
source $(dirname $0)/tm_vmfsrc
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
# Retrieve needed information, set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_FOLDER=`basename $SRC_PATH`
|
||||
@ -52,12 +51,14 @@ DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
DST_FOLDER=`basename $DST_PATH`
|
||||
IMAGE_DS_NAME=`basename $(dirname $SRC_PATH)`
|
||||
SYSTEM_DS_NAME=`basename $(dirname $(dirname $DST_PATH))`
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $IMAGE_DS_NAME)
|
||||
|
||||
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 '"')`
|
||||
IMAGE_DS_NAME=`basename $(dirname $SRC_PATH)`
|
||||
SYSTEM_DS_NAME=`basename $(dirname $(dirname $DST_PATH))`
|
||||
DST_DIR_WITHOUT_DS_PATH="[$SYSTEM_DS_NAME]${DST_PATH##"$DS_DIR/$SYSTEM_DS_NAME/"}"
|
||||
if [ -z $PASSWORD ]; then
|
||||
VI_PARAMS="--server $DST_HOST --username $USERNAME --password \"\""
|
||||
@ -66,6 +67,10 @@ if [ "$USE_SSH" != "yes" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create remote folder
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ "$USE_SSH" == "yes" ]; then
|
||||
ssh_make_path $DST_HOST $DST_PATH
|
||||
else
|
||||
|
@ -39,17 +39,18 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
source $(dirname $0)/tm_vmfsrc
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dirs
|
||||
# Retrieve needed information, set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
DST_FOLDER=`basename $DST_PATH`
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $DS_ID)
|
||||
|
||||
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 '"')`
|
||||
@ -60,6 +61,10 @@ if [ "$USE_SSH" != "yes" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create remote folder
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ "$USE_SSH" == "yes" ]; then
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
else
|
||||
|
@ -39,8 +39,13 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
source $(dirname $0)/tm_vmfsrc
|
||||
#-------------------------------------------------------------------------------
|
||||
# Retrieve needed information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $DSID)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Return if deleting a disk, we will delete them when removing the
|
||||
|
@ -37,9 +37,10 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
# Retrieve needed information, set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}"
|
||||
@ -48,6 +49,8 @@ DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $DSID)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Link (ln) SRC into DST
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -40,17 +40,18 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
source $(dirname $0)/tm_vmfsrc
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
# Retrieve needed information, set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
DST_FOLDER=`basename $DST_PATH`
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $DSID)
|
||||
|
||||
if [ "$USE_SSH" != "yes" ]; then
|
||||
SYSTEM_DS_NAME=`basename $(dirname $(dirname $DST_PATH))`
|
||||
USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')`
|
||||
|
@ -39,13 +39,12 @@ else
|
||||
fi
|
||||
|
||||
. $TMCOMMON
|
||||
|
||||
source $(dirname $0)/tm_vmfsrc
|
||||
source $(dirname $0)/tm_vmfs.conf
|
||||
|
||||
set_ds_location
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
# Retrieve needed information, set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
@ -54,7 +53,7 @@ SRC_FOLDER=`basename $SRC_PATH`
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_FOLDER=`basename $DST_PATH`
|
||||
|
||||
|
||||
USE_SSH=$(get_tm_use_ssh $DSID)
|
||||
|
||||
if [ "$USE_SSH" != "yes" ]; then
|
||||
IMAGE_DS_NAME=`basename $(dirname $DST_PATH)`
|
||||
@ -101,7 +100,8 @@ fi
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log $SRC_HOST "$MVSCRIPT" "Could not move image [$SYSTEM_DS_NAME]$VMID/$SRC_FOLDER/disk.vmdk to [$IMAGE_DS_NAME]$DST_FOLDER/disk.vmdk in $SRC_HOST"
|
||||
ssh_exec_and_log $SRC_HOST "$MVSCRIPT" \
|
||||
"Could not move image [$SYSTEM_DS_NAME]$VMID/$SRC_FOLDER/disk.vmdk to [$IMAGE_DS_NAME]$DST_FOLDER/disk.vmdk in $SRC_HOST"
|
||||
else
|
||||
$VMKFSTOOLS $VI_PARAMS -U [$IMAGE_DS_NAME]$DST_FOLDER/disk.vmdk &> /dev/null
|
||||
exec_and_log "$VMKFSTOOLS $VI_PARAMS -i [$SYSTEM_DS_NAME]$VMID/$SRC_FOLDER/disk.vmdk -d thin [$IMAGE_DS_NAME]$DST_FOLDER/disk.vmdk" \
|
||||
|
@ -17,4 +17,4 @@
|
||||
# Whether the TM VMware driver should use to invoke the VMFS native commands
|
||||
# * remote API calls (value set to "no")
|
||||
# * ssh connection (value set to "yes")
|
||||
USE_SSH=no
|
||||
TM_USE_SSH=no
|
Loading…
x
Reference in New Issue
Block a user