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

Merge remote-tracking branch 'upstream/feature-1112' into feature-1112

This commit is contained in:
Hector Sanjuan 2012-03-07 13:10:47 +01:00
commit 9c3dfe7a41
14 changed files with 420 additions and 80 deletions

View File

@ -237,6 +237,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/datastore \
$VAR_LOCATION/remotes/datastore/fs \
$VAR_LOCATION/remotes/datastore/vmware \
$VAR_LOCATION/remotes/datastore/iscsi \
$VAR_LOCATION/remotes/auth \
$VAR_LOCATION/remotes/auth/plain \
$VAR_LOCATION/remotes/auth/ssh \
@ -390,6 +391,7 @@ INSTALL_FILES=(
DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/
DATASTORE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/datastore/fs
DATASTORE_DRIVER_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmware
DATASTORE_DRIVER_ISCSI_SCRIPTS:$VAR_LOCATION/remotes/datastore/iscsi
NETWORK_FILES:$VAR_LOCATION/remotes/vnm
NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
@ -820,6 +822,11 @@ DATASTORE_DRIVER_VMWARE_SCRIPTS="src/datastore_mad/remotes/vmware/cp \
src/datastore_mad/remotes/vmware/mkfs \
src/datastore_mad/remotes/vmware/rm"
DATASTORE_DRIVER_ISCSI_SCRIPTS="src/datastore_mad/remotes/iscsi/cp \
src/datastore_mad/remotes/iscsi/mkfs \
src/datastore_mad/remotes/iscsi/rm \
src/datastore_mad/remotes/iscsi/iscsi.conf"
#-------------------------------------------------------------------------------
# Migration scripts for onedb command, to be installed under $LIB_LOCATION
#-------------------------------------------------------------------------------
@ -1088,8 +1095,7 @@ ETC_CLIENT_FILES="src/cli/etc/group.default"
# Sunstone files
#-----------------------------------------------------------------------------
SUNSTONE_FILES="src/sunstone/config.ru \
src/sunstone/sunstone-server.rb \
SUNSTONE_FILES="src/sunstone/sunstone-server.rb \
src/sunstone/OpenNebulaVNC.rb"
SUNSTONE_BIN_FILES="src/sunstone/bin/sunstone-server"
@ -1234,8 +1240,7 @@ src/sunstone/public/locale/ru/ru_datatable.txt"
# Ozones files
#-----------------------------------------------------------------------------
OZONES_FILES="src/ozones/Server/config.ru \
src/ozones/Server/ozones-server.rb"
OZONES_FILES="src/ozones/Server/ozones-server.rb"
OZONES_BIN_FILES="src/ozones/Server/bin/ozones-server"

View File

@ -83,9 +83,9 @@ class DatastoreDriver < OpenNebulaDriver
register_action(ACTION[:mkfs].to_sym, method("mkfs"))
end
############################################################################
############################################################################
# Image Manager Protocol Actions (generic implementation)
############################################################################
############################################################################
# TODO: Integrate this with TM
# def mv(id, ds, src, dst)
# do_image_action(id, ds, :mv, "'#{src}' '#{dst}' '#{id}'")
@ -112,7 +112,7 @@ class DatastoreDriver < OpenNebulaDriver
if @types.include?(ds)
return true
else
send_message(ACTION[action], RESULT[:failure], id,
send_message(ACTION[action], RESULT[:failure], id,
"Datastore driver '#{ds}' not available")
return false
end
@ -130,6 +130,8 @@ class DatastoreDriver < OpenNebulaDriver
result, info = get_info_from_execution(rc)
PP.pp([ACTION[action], result, id, info],STDERR)
send_message(ACTION[action], result, id, info)
end

View File

@ -57,6 +57,7 @@ SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
SRC="${XPATH_ELEMENTS[4]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
DST=`generate_image_path`

View File

@ -49,7 +49,6 @@ 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/IMAGE/PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
@ -58,10 +57,10 @@ BASE_PATH="${XPATH_ELEMENTS[0]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
SRC="${XPATH_ELEMENTS[4]}"
FSTYPE="${XPATH_ELEMENTS[5]}"
SIZE="${XPATH_ELEMENTS[6]}"
FSTYPE="${XPATH_ELEMENTS[4]}"
SIZE="${XPATH_ELEMENTS[5]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
DST=`generate_image_path`
@ -82,7 +81,4 @@ exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
exec_and_log "$MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST"
# ---------------- Get the size of the image ------------
SIZE=`fs_du $DST`
echo "$DST $SIZE"

View File

@ -0,0 +1,112 @@
#!/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
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.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/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_TID \
/DS_DRIVER_ACTION_DATA/IMAGE/PATH)
BASE_PATH="${XPATH_ELEMENTS[0]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
DST_HOST="${XPATH_ELEMENTS[4]}"
VG_NAME="${XPATH_ELEMENTS[5]:-$VG_NAME}"
BASE_IQN="${XPATH_ELEMENTS[6]:-$BASE_IQN}"
BASE_TID="${XPATH_ELEMENTS[7]:-$BASE_TID}"
SRC="${XPATH_ELEMENTS[8]}"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
SIZE=`fs_du $SRC`
LV_NAME="lv-one-${ID}"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
DEV="/dev/$VG_NAME/$LV_NAME"
let TID=ID+BASE_TID
REGISTER_CMD=$(cat <<EOF
set -e
$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
$SUDO $(iscsi_target_new "$TID" "$IQN")
$SUDO $(iscsi_logicalunit_new "$TID" "$DEV")
EOF
)
case $SRC in
http://*)
log "Downloading $SRC to the image repository"
DUMP="$WGET $SRC -O-"
;;
*)
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 image $SRC to the image repository"
DUMP="cat $SRC"
;;
esac
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" "Error registering $DST_HOST:$DEV"
exec_and_log "eval $DUMP | $SSH $DST_HOST $SUDO $DD of=$DEV bs=64k" \
"Error dumping $SRC to $DST_HOST:$DEV"
echo "$IQN $SIZE"

View File

@ -0,0 +1,24 @@
# -------------------------------------------------------------------------- #
# 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 IQN path
BASE_IQN=iqn.2012-02.org.opennebula
# Default volume group
VG_NAME=vg-one
# Starting TID for iSCSI targets
BASE_TID=1

View File

@ -0,0 +1,101 @@
#!/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
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.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/HOST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_TID \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
BASE_PATH="${XPATH_ELEMENTS[0]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
DST_HOST="${XPATH_ELEMENTS[4]}"
VG_NAME="${XPATH_ELEMENTS[5]:-$VG_NAME}"
BASE_IQN="${XPATH_ELEMENTS[6]:-$BASE_IQN}"
BASE_TID="${XPATH_ELEMENTS[7]:-$BASE_TID}"
FSTYPE="${XPATH_ELEMENTS[8]}"
SIZE="${XPATH_ELEMENTS[9]:-0}"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
LV_NAME="lv-one-${ID}"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
DEV="/dev/$VG_NAME/$LV_NAME"
let TID=ID+BASE_TID
REGISTER_CMD=$(cat <<EOF
set -e
$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
$SUDO $(iscsi_target_new "$TID" "$IQN")
$SUDO $(iscsi_logicalunit_new "$TID" "$DEV")
$SUDO $(mkfs_command "$DEV" "$FSTYPE")
EOF
)
# ------------ Image to save_as disk, no need to create a FS ------------
if [ "$FSTYPE" = "save_as" ]; then
echo "$DST $SIZE"
exit 0
fi
# ------------ Create the image to the repository ------------
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" \
"Error registering $DST_HOST:$DEV"
echo "$IQN $SIZE"

View File

@ -0,0 +1,81 @@
#!/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
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.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/TEMPLATE/HOST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_TID)
SRC="${XPATH_ELEMENTS[0]}"
DST_HOST="${XPATH_ELEMENTS[1]}"
BASE_TID="${XPATH_ELEMENTS[2]:-$BASE_TID}"
BASE_IQN=`echo $SRC|$CUT -d: -f1`
TARGET=`echo $SRC|$CUT -d: -f2`
LV_NAME=`echo $TARGET|$AWK -F. '{print $(NF)}'`
VG_NAME=`echo $TARGET|$AWK -F. '{print $(NF-1)}'`
DEV="/dev/$VG_NAME/$LV_NAME"
let TID=ID+BASE_TID
RM_COMMAND=$(cat <<EOF
n_snapshots=\$($SUDO $LVS --noheadings -o name,origin $VG_NAME | \
$AWK '{if(\$2 == "$LV_NAME"){print \$1}}'|wc -l)
if [ "\$n_snapshots" = "0" ]; then
$SUDO $(iscsi_target_delete "$TID")
$SUDO $LVREMOVE -f $VG_NAME/$LV_NAME
else
echo "Error: \$n_snapshots active snapshots for $VG_NAME/$LV_NAME" >&2
exit 1
fi
EOF
)
log "Removing $DST_HOST:$DEV from the image repository"
ssh_exec_and_log "$DST_HOST" "$RM_COMMAND" \
"Error removing $DST_HOST:$DEV"
exit 0

View File

@ -53,8 +53,6 @@ function set_up_datastore {
export RESTRICTED_DIRS
export SAFE_DIRS
mkdir -p $BASE_PATH
if [ -n "$UMASK" ]; then
umask $UMASK
else
@ -94,7 +92,7 @@ function fs_du {
if [ $error -ne 0 ]; then
SIZE=0
else
SIZE=$(($SIZE/1048576))
SIZE=$((($SIZE+1048575)/1048576))
fi
echo "$SIZE"
@ -111,7 +109,7 @@ function qemu_size {
SIZE=`$QEMU_IMG info $DISK|grep "^virtual size:"|\
sed 's/^.*(\([0-9]\+\) bytes.*$/\1/g'`
SIZE=$(($SIZE/1048576))
SIZE=$((($SIZE+1048575)/1048576))
echo "$SIZE"
}
@ -138,3 +136,37 @@ function check_restricted {
echo 0
}
# ------------------------------------------------------------------------------
# iSCSI functions
# ------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Returns the command to create a new target
# @param $1 - ID of the image
# @param $2 - Target Host
# @param $3 - Device
# @return the command to create a new target
#-------------------------------------------------------------------------------
function iscsi_target_new {
ID="$1"
IQN="$2"
echo "$TGTADM --lld iscsi --op new --mode target --tid $ID "\
"--targetname $IQN"
}
function iscsi_logicalunit_new {
ID="$1"
DEV="$2"
echo "$TGTADM --lld iscsi --op new --mode logicalunit --tid $ID "\
"--lun 1 --backing-store $DEV"
}
function iscsi_target_delete {
ID="$1"
echo "$TGTADM --lld iscsi --op delete --mode target --tid $ID"
}

View File

@ -57,6 +57,7 @@ SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
SRC="${XPATH_ELEMENTS[4]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
DST=`generate_image_path`

View File

@ -49,7 +49,6 @@ 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/IMAGE/PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
@ -57,10 +56,10 @@ BASE_PATH="${XPATH_ELEMENTS[0]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
UMASK="${XPATH_ELEMENTS[3]}"
SRC="${XPATH_ELEMENTS[4]}"
FSTYPE="${XPATH_ELEMENTS[5]}"
SIZE="${XPATH_ELEMENTS[6]}"
FSTYPE="${XPATH_ELEMENTS[4]}"
SIZE="${XPATH_ELEMENTS[5]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
DST=`generate_image_path`

View File

@ -22,6 +22,7 @@ CUT=cut
DATE=date
DD=dd
DU=du
GREP=grep
LVCREATE=lvcreate
LVREMOVE=lvremove
LVS=lvs
@ -35,8 +36,8 @@ SCP=scp
SED=sed
SSH=ssh
SUDO=sudo
TGTADM=tgtadm
WGET=wget
GREP=grep
if [ "x$(uname -s)" = "xLinux" ]; then
SED="$SED -r"
@ -115,7 +116,7 @@ function error_message
function exec_and_log
{
message=$2
EXEC_LOG_ERR=`$1 2>&1 1>/dev/null`
EXEC_LOG_RC=$?
@ -192,7 +193,7 @@ function mkfs_command {
;;
"raw")
echo ""
return 0
return 0
;;
"swap")
echo "$MKSWAP $DST"
@ -205,3 +206,41 @@ function mkfs_command {
echo "$MKFS -t $FSTYPE $OPTS $DST"
}
#This function executes $2 at $1 host and report error $3
function ssh_exec_and_log
{
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
$2
EOF`
SSH_EXEC_RC=$?
if [ $SSH_EXEC_RC -ne 0 ]; then
log_error "Command \"$2\" failed: $SSH_EXEC_ERR"
if [ -n "$3" ]; then
error_message "$3"
else
error_message "Error executing $2: $SSH_EXEC_ERR"
fi
exit $SSH_EXEC_RC
fi
}
#Creates path ($2) at $1
function ssh_make_path
{
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
if [ ! -d $2 ]; then
mkdir -p $2
fi
EOF`
SSH_EXEC_RC=$?
if [ $? -ne 0 ]; then
error_message "Error creating directory $2 at $1: $SSH_EXEC_ERR"
exit $SSH_EXEC_RC
fi
}

View File

@ -62,7 +62,7 @@ function set_ds_location
#Return 1 if the first argument is a disk
function is_disk
{
echo "$1" | $GREP '/disk\.[0-9]\+' > /dev/null 2>&1
echo "$1" | $GREP '/disk\.[0-9]\+' > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "1"
@ -70,56 +70,3 @@ function is_disk
echo "0"
fi
}
# ------------------------------------------------------------------------------
# Function to get hosts and paths from arguments
# ------------------------------------------------------------------------------
#This function executes $2 at $1 host and report error $3
function ssh_exec_and_log
{
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
$2
EOF`
SSH_EXEC_RC=$?
if [ $SSH_EXEC_RC -ne 0 ]; then
log_error "Command \"$2\" failed: $SSH_EXEC_ERR"
if [ -n "$3" ]; then
error_message "$3"
else
error_message "Error executing $2: $SSH_EXEC_ERR"
fi
exit $SSH_EXEC_RC
fi
}
#Creates path ($2) at $1
function ssh_make_path
{
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
if [ ! -d $2 ]; then
mkdir -p $2
fi
EOF`
SSH_EXEC_RC=$?
if [ $? -ne 0 ]; then
error_message "Error creating directory $2 at $1: $SSH_EXEC_ERR"
exit $SSH_EXEC_RC
fi
}
#Transform a system data store path from its remote location to the local one
#$1 remote path
function remote2local_path
{
if [ -z "$RMT_DS_DIR" ]; then
set_ds_location
fi
echo "$ONE_LOCAL_VAR/datastores/${1##"$RMT_DS_DIR/"}"
}

View File

@ -1216,7 +1216,7 @@ error_saved:
goto error_common;
error_image_id:
oss << "The DISK " << disk_id << "does not have a valid IMAGE_ID.";
oss << "The DISK " << disk_id << " does not have a valid IMAGE_ID.";
goto error_common;
error_not_found: