mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
parent
63eb2447db
commit
163d900e63
@ -577,23 +577,6 @@ set -e -o pipefail
|
||||
if [ ! -d $2 ]; then
|
||||
mkdir -p $2
|
||||
fi
|
||||
|
||||
MONITOR_FN="\$(dirname $2)/.monitor"
|
||||
|
||||
# create or update .monitor content
|
||||
if [ -n "$3" ]; then
|
||||
MONITOR=''
|
||||
if [ -f "\\${MONITOR_FN}" ]; then
|
||||
MONITOR="\\$(cat "\\${MONITOR_FN}" 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [ "x\\${MONITOR}" != "x$3" ]; then
|
||||
echo "$3" > "\\${MONITOR_FN}"
|
||||
fi
|
||||
else
|
||||
# remove .monitor file (to avoid errors on driver change)
|
||||
rm -f "\\${MONITOR_FN}"
|
||||
fi
|
||||
EOF`
|
||||
SSH_EXEC_RC=$?
|
||||
|
||||
@ -604,6 +587,58 @@ EOF`
|
||||
fi
|
||||
}
|
||||
|
||||
# Enables local monitoring for host $2 and DS $1, by creating the corresponding
|
||||
# .monitor file containing the $3 ( the driver name) (e.g ssh)
|
||||
function enable_local_monitoring
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
MONITOR_FN="\$(dirname $2)/.monitor"
|
||||
|
||||
# create or update .monitor content
|
||||
MONITOR=''
|
||||
if [ -f "\\${MONITOR_FN}" ]; then
|
||||
MONITOR="\\$(cat "\\${MONITOR_FN}" 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [ "x\\${MONITOR}" != "x$3" ]; then
|
||||
echo "$3" > "\\${MONITOR_FN}"
|
||||
fi
|
||||
EOF`
|
||||
|
||||
SSH_EXEC_RC=$?
|
||||
|
||||
if [ $SSH_EXEC_RC -ne 0 ]; then
|
||||
error_message "Error creating $2/.monitor at $1: $SSH_EXEC_ERR"
|
||||
|
||||
exit $SSH_EXEC_RC
|
||||
fi
|
||||
}
|
||||
|
||||
# Disables local monitoring for host $2 and DS $1, by removing the corresponding
|
||||
# .monitor file
|
||||
function disable_local_monitoring
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
MONITOR_FN="\$(dirname $2)/.monitor"
|
||||
|
||||
# remove .monitor file
|
||||
rm -f "\\${MONITOR_FN}"
|
||||
|
||||
EOF`
|
||||
|
||||
SSH_EXEC_RC=$?
|
||||
|
||||
if [ $SSH_EXEC_RC -ne 0 ]; then
|
||||
error_message "Error creating $2/.monitor at $1: $SSH_EXEC_ERR"
|
||||
|
||||
exit $SSH_EXEC_RC
|
||||
fi
|
||||
}
|
||||
|
||||
# Escape characters which could be interpreted as XML markup
|
||||
function xml_esc
|
||||
{
|
||||
|
@ -95,6 +95,8 @@ done < <(onedatastore show -x $DST_DS_ID | $XPATH \
|
||||
|
||||
EC_POOL_NAME="${XPATH_ELEMENTS[j++]}"
|
||||
|
||||
disable_local_monitoring $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clone the image and create @snap if it does not exists
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -98,7 +98,8 @@ if [ -n "$CEPH_CONF" ]; then
|
||||
fi
|
||||
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR 'ssh'
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR 'ssh'
|
||||
|
||||
CLONE_CMD=$(cat <<EOF
|
||||
RBD="${RBD}"
|
||||
|
@ -91,7 +91,8 @@ if [ -n "$CEPH_CONF" ]; then
|
||||
RBD="$RBD --conf ${CEPH_CONF}"
|
||||
fi
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR 'ssh'
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR 'ssh'
|
||||
|
||||
LN_CMD=$(cat <<EOF
|
||||
RBD="${RBD}"
|
||||
|
@ -56,6 +56,8 @@ SRC_PATH="${DST_DS_PATH}${SRC_ARG_PATH##$SRC_DS_PATH}"
|
||||
|
||||
DS_SYS_ID=$(echo $DST_DIR | $AWK -F '/' '{print $(NF-1)}')
|
||||
|
||||
disable_local_monitoring $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -58,6 +58,8 @@ SRC_HOST=`arg_host $SRC`
|
||||
|
||||
DS_SYS_ID=$(echo $DST_DIR | $AWK -F '/' '{print $(NF-1)}')
|
||||
|
||||
disable_local_monitoring $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -74,6 +74,7 @@ FORMAT="${XPATH_ELEMENTS[j++]}"
|
||||
ORIGINAL_SIZE="${XPATH_ELEMENTS[j++]}"
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
disable_local_monitoring $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clone (cp) SRC into DST
|
||||
|
@ -48,7 +48,8 @@ DST_PATH=$(arg_path $DST)
|
||||
DST_HOST=$(arg_host $DST)
|
||||
DST_DIR=$(dirname $DST_PATH)
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR "ssh"
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR "ssh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
|
@ -56,7 +56,8 @@ SRC_FORMAT=$(image_format "$SRC_PATH")
|
||||
# Create DST path
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR 'ssh'
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR "ssh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copy SRC into DST
|
||||
|
@ -63,7 +63,8 @@ DST_FILE="$(basename $DST_PATH)"
|
||||
SRC_DIR="$(dirname $SRC_PATH)"
|
||||
DST_DIR="$(dirname $DST_PATH)"
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR "ssh"
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR "ssh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
|
@ -97,9 +97,10 @@ if [ -z "$REPLICA_HOST" ]; then
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create DST path
|
||||
# Create DST path and enable local monitoring
|
||||
#-------------------------------------------------------------------------------
|
||||
ssh_make_path $DST_HOST $DST_DIR "ssh"
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR "ssh"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Get REPLICA_STORAGE_IP from host template
|
||||
|
@ -79,7 +79,8 @@ EOF
|
||||
|
||||
MONITOR=$(ssh_monitor_and_log "$SRC_HOST" "$MONITOR_CMD" 'Get .monitor')
|
||||
|
||||
ssh_make_path "$DST_HOST" "$DST_PATH" "$MONITOR"
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
enable_local_monitoring $DST_HOST $DST_DIR "$MONITOR"
|
||||
|
||||
RANDOM_FILE=$(ssh "$DST_HOST" "mktemp -p \"$DST_DIR\"")
|
||||
trap "ssh $DST_HOST \"rm -f $RANDOM_FILE\"" EXIT
|
||||
|
Loading…
Reference in New Issue
Block a user