1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #1437: fix vifs command not wrapping nicely with exec_and_log

This commit is contained in:
Tino Vazquez 2012-09-13 11:49:06 +02:00
parent e554d5cd26
commit 1624deaf5f
10 changed files with 31 additions and 27 deletions

View File

@ -78,7 +78,7 @@ log "Copying local image $SRC to the image repository"
if [ "$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"
exec_and_log "vifs $VI_PARAMS --copy [$DS_ID]$SRC_FOLDER [$DS_ID]$DST_FOLDER" "Error copying $SRC to $DST"
fi
echo "$DST"

View File

@ -71,8 +71,8 @@ SHA1="${XPATH_ELEMENTS[7]}"
# Set up the datastore
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
DST=`generate_image_path`
DST_FOLDER=`basename $DST`
FE_DST=`generate_image_path`
DST_FOLDER=`basename $FE_DST`
DST="/vmfs/volumes/$DS_ID/$DST_FOLDER"
DST_HOST=`get_destination_host $(dirname $0)`
@ -86,7 +86,7 @@ fi
if [ "$SSH" == "yes" ]; then
ssh_make_path $DST_HOST $DST
else
exec_and_log "vifs $VI_PARAMS --mkdir \"[$DS_ID] $DST_FOLDER\"" "Cannot create $DST in $DST_HOST"
exec_and_log "vifs $VI_PARAMS --mkdir [$DS_ID]$DST_FOLDER" "Cannot create $DST in $DST_HOST"
fi
# Prepare for a possible download in the front-end
@ -126,9 +126,8 @@ http://*|https://* )
if [ ! -d $SRC ]; then
exec_and_log "$COPY_COMMAND" "Error copying $SRC to $TMP_DIR/$IMAGE_HASH"
SRC="$TMP_DIR/$IMAGE_HASH"
fi
SRC="$TMP_DIR/$IMAGE_HASH"
;;
esac
@ -136,7 +135,7 @@ esac
if [ ! -f $SRC/disk.vmdk ]; then
BASE_DISK_FILE=`ls $SRC | grep -v '\-\(flat\|delta\|s[0-9]*\)\.vmdk$'`
exec_and_log "mv -f $DST/$BASE_DISK_FILE $DST/disk.vmdk" \
exec_and_log "mv -f $FE_DST/$BASE_DISK_FILE $DST/disk.vmdk" \
"Error renaming disk file $BASE_DISK_FILE to disk.vmdk"
fi
@ -147,7 +146,7 @@ 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"
exec_and_log "vifs $VI_PARAMS -p $file [$DS_ID]$DST_FOLDER/$FNAME" "Cannot upload $file to $DST/$FNAME on $DST_HOST"
done
fi

View File

@ -74,7 +74,6 @@ DST_HOST=`get_destination_host $(dirname $0)`
if [ "$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 '"')`
REMOTE_DS_ROUTE="$IMAGE_DS_ID]$DST_FOLDER_NAME"
VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD"
fi
@ -97,7 +96,7 @@ if [ "$SSH" == "yes" ]; then
ssh_exec_and_log $DST_HOST "$VMKFSTOOLS -U $DST/disk.vmdk"
ssh_exec_and_log $DST_HOST "$VMKFSTOOLS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST/disk.vmdk" "Cannot create $DST/disk.vmdk on $DST_HOST"
else
exec_and_log 'vifs $VI_PARAMS --mkdir "[$IMAGE_DS_ID] $DST_FOLDER_NAME"' "Cannot create [$IMAGE_DS_ID] $DST_FOLDER_NAME on $DST_HOST"
exec_and_log 'vifs $VI_PARAMS --mkdir [$IMAGE_DS_ID]$DST_FOLDER_NAME' "Cannot create [$IMAGE_DS_ID] $DST_FOLDER_NAME on $DST_HOST"
exec_and_log "$VMKFSTOOLS $VI_PARAMS -U $DST_PATH/disk.vmdk"
exec_and_log "$VMKFSTOOLS $VI_PARAMS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST/disk.vmdk" "Cannot create $DST/disk.vmdk on $DST_HOST"

View File

@ -73,11 +73,11 @@ if [ "$SSH" == "yes" ]; then
fi
else
# We have to erase the contents of the folder one by one
FILES_TO_ERASE=`vifs $VI_PARAMS --dir "[$DS_NAME] $FOLDER_TO_ERASE"|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"`
FILES_TO_ERASE=`vifs $VI_PARAMS --dir [$DS_NAME]$FOLDER_TO_ERASE|grep -v "Content Listing"|grep -v "\-\-\-\-\-\-\-\-"|egrep -v "^[[:space:]]*$"`
for file in $FILES_TO_ERASE; do
exec_and_log "vifs $VI_PARAMS --rm \"[$DS_NAME] $FOLDER_TO_ERASE/$file\"" "Cannot delete $FOLDER_TO_ERASE/$file in $DST_HOST"
exec_and_log "vifs $VI_PARAMS --rm [$DS_NAME]$FOLDER_TO_ERASE/$file" "Cannot delete $FOLDER_TO_ERASE/$file in $DST_HOST"
done
exec_and_log "vifs $VI_PARAMS --rm \"[$DS_NAME] $FOLDER_TO_ERASE\"" "Cannot delete $FOLDER_TO_ERASE in $DST_HOST"
exec_and_log "vifs $VI_PARAMS --rm [$DS_NAME]$FOLDER_TO_ERASE" "Cannot delete $FOLDER_TO_ERASE in $DST_HOST"
fi
exit 0

View File

@ -51,13 +51,14 @@ SRC_PATH="../../${SRC_PATH##"$DS_DIR/"}"
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
DST_FOLDER=`basename $DST_PATH`
if [ "$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/"}"
DST_DIR_WITHOUT_DS_PATH="[$SYSTEM_DS_NAME]${DST_PATH##"$DS_DIR/$SYSTEM_DS_NAME/"}"
VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD"
fi
@ -65,8 +66,9 @@ if [ "$SSH" == "yes" ]; then
ssh_make_path $DST_HOST $DST_PATH
else
# Two calls needed since vifs cannot do a mkdir -p
exec_and_log "vifs $VI_PARAMS --mkdir \"[$SYSTEM_DS_NAME] $VMID\"" "Cannot create [$SYSTEM_DS_NAME] $VMID in $DST_HOST"
exec_and_log "vifs $VI_PARAMS --mkdir \"$DST_DIR_WITHOUT_DS_PATH\"" "Cannot create $DST_DIR_WITHOUT_DS_PATH in $DST_HOST"
vifs $VI_PARAMS --mkdir [$SYSTEM_DS_NAME]$VMID
exec_and_log "vifs $VI_PARAMS --mkdir [$SYSTEM_DS_NAME]$VMID/$DST_FOLDER" \
"Cannot create [$SYSTEM_DS_NAME]$VMID/$DST_FOLDER in $DST_HOST"
fi
#-------------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@ source $(dirname $0)/tm_vmwarerc
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
DST_FOLDER=`basename $DST_PATH`
if [ "$SSH" != "yes" ]; then
USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')`
@ -58,7 +59,9 @@ fi
if [ "$SSH" == "yes" ]; then
ssh_make_path $DST_HOST $DST_DIR
else
exec_and_log "vifs $VI_PARAMS --mkdir \"$DST_DIR\"" "Cannot create $DST_DIR on %DST_HOST"
vifs $VI_PARAMS --mkdir [$DS_ID]$VM_ID
exec_and_log "vifs $VI_PARAMS --mkdir [$DS_ID]$VM_ID/$DST_FOLDER" \
"Cannot create [$DS_ID]$VM_ID/$DST_FOLDER on %DST_HOST"
fi
#-------------------------------------------------------------------------------
@ -66,7 +69,6 @@ fi
#-------------------------------------------------------------------------------
log "Generating context block device at $DST"
VM_ID=`basename $DST_DIR`
ISO_DIR="$DS_DIR/.isofiles/$VM_ID"
ISO_FILE="$ISO_DIR/$VM_ID.iso"

View File

@ -57,7 +57,8 @@ if [ "$SSH" == "yes" ]; then
else
USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')`
PASSWORD=`echo $(cat $VMWARERC |grep ":password:"|cut -d":" -f 3|tr -d '"')`
exec_and_log "$VMKFSTOOLS --server $DST_HOST --username $USERNAME --password $PASSWORD -U $DST_PATH" "Cannot delelete $DST"
exec_and_log "$VMKFSTOOLS --server $DST_HOST --username $USERNAME --password $PASSWORD -U $DST_PATH" \
"Cannot delelete $DST"
fi
exit 0

View File

@ -70,7 +70,8 @@ for file in \$(cd $DST_DIR ; find $SRC_PATH -type f); do
done
EOF
)
ssh_exec_and_log $DST_HOST "$LINK_SCRIPT" "Could not link dir files from source DS to system DS"
ssh_exec_and_log $DST_HOST "$LINK_SCRIPT" \
"Could not link dir files from source DS to system DS"
else
log "Cannot link files without SSH enabled on the ESX hosts"
exit 1

View File

@ -49,12 +49,12 @@ source $(dirname $0)/tm_vmwarerc
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
DST_FOLDER=`basename $DST_PATH`
if [ "$SSH" != "yes" ]; then
SYSTEM_DS_NAME=`basename $(dirname $(dirname $DST_PATH))`
USERNAME=`echo $(cat $VMWARERC |grep ":username:"|cut -d":" -f 3|tr -d '"')`
PASSWORD=`echo $(cat $VMWARERC |grep ":password:"|cut -d":" -f 3|tr -d '"')`
DST_DIR_WITHOUT_DS_PATH="[$SYSTEM_DS_NAME] ${DST_PATH##"$DS_DIR/$SYSTEM_DS_NAME/"}"
VI_PARAMS="--server $DST_HOST --username $USERNAME --password $PASSWORD"
fi
@ -77,12 +77,13 @@ EOF
ssh_exec_and_log $DST_HOST "$MKSCRIPT" "Could not create image $DST_PATH"
else
# Two calls needed since vifs cannot do a mkdir -p
exec_and_log "vifs $VI_PARAMS --mkdir \"[$SYSTEM_DS_NAME] $VMID\"" "Cannot create [$SYSTEM_DS_NAME] $VMID"
exec_and_log "vifs $VI_PARAMS --mkdir \"$DST_DIR_WITHOUT_DS_PATH\""
vifs $VI_PARAMS --mkdir [$SYSTEM_DS_NAME]$VMID
exec_and_log "vifs $VI_PARAMS --mkdir [$SYSTEM_DS_NAME]$VMID/$DST_FOLDER"
VMWARE_DISK_TYPE=`echo $FSTYPE|cut -d'_' -f 2`
exec_and_log "$VMKFSTOOLS $VI_PARAMS -U $DST_PATH/disk.vmdk"
exec_and_log "$VMKFSTOOLS $VI_PARAMS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST/disk.vmdk" "Cannot create $DST/disk.vmdk on $DST_HOST"
exec_and_log "$VMKFSTOOLS $VI_PARAMS -c ${SIZE}M -d ${VMWARE_DISK_TYPE} $DST/disk.vmdk" \
"Cannot create $DST/disk.vmdk on $DST_HOST"
fi
exit 0

View File

@ -55,9 +55,7 @@ set_ds_location
#-------------------------------------------------------------------------------
SRC_PATH=`arg_path $SRC`"/disk.vmdk"
DST_PATH=`arg_path $DST`
DST_PATH="$RMT_DS_DIR/${DST_PATH##"$DS_DIR/"}/disk.vmdk"
SRC_HOST=`arg_host $SRC`
#-------------------------------------------------------------------------------
@ -94,7 +92,8 @@ EOF
ssh_exec_and_log $SRC_HOST "$MVSCRIPT" "Could not move image $DST_PATH"
else
exec_and_log "$VMKFSTOOLS $VI_PARAMS -i $SRC_PATH -d thin $DST_PATH" "Could not move image $DST_PATH"
exec_and_log "$VMKFSTOOLS $VI_PARAMS -i $SRC_PATH -d thin $DST_PATH" \
"Could not move image $DST_PATH"
fi
exit 0