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

B #2767: Fixes into create/update of .monitor for local DS monitoring (#2873)

This commit is contained in:
Vlastimil Holer 2019-01-31 20:35:38 +01:00 committed by Ruben S. Montero
parent ab053e3c83
commit 7390124654
4 changed files with 30 additions and 8 deletions

View File

@ -460,12 +460,23 @@ function ssh_make_path
{
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
set -e -o pipefail
if [ ! -d $2 ]; then
mkdir -p $2
if [ -n "$3" ]; then
echo "$3" > "\$(dirname $2)/.monitor"
fi
if [ ! -d $2 ]; then
mkdir -p $2
fi
# create or update .monitor content
if [ -n "$3" ]; then
MONITOR_FN="\$(dirname $2)/.monitor"
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
fi
EOF`
SSH_EXEC_RC=$?

View File

@ -118,7 +118,7 @@ if [ -n "$EC_POOL_NAME" ]; then
fi
if [ "${TYPE}" = 'FILE' ]; then
ssh_make_path $DST_HOST $DST_DIR
ssh_make_path $DST_HOST $DST_DIR 'ssh'
CLONE_CMD=$(cat <<EOF
RBD="${RBD}"

View File

@ -94,7 +94,7 @@ if [ -n "$CEPH_CONF" ]; then
fi
if [ "${TYPE}" = 'FILE' ]; then
ssh_make_path $DST_HOST $DST_DIR
ssh_make_path $DST_HOST $DST_DIR 'ssh'
LN_CMD=$(cat <<EOF
RBD="${RBD}"

View File

@ -50,6 +50,7 @@ DST_PATH=`arg_path $DST`
SRC_HOST=`arg_host $SRC`
DST_HOST=`arg_host $DST`
SRC_DIR=`dirname $SRC_PATH`
DST_DIR=`dirname $DST_PATH`
SRC_DS_DIR=`dirname $SRC_PATH`
@ -69,7 +70,17 @@ if [ `lcm_state` -eq 60 ]; then
exit 0
fi
ssh_make_path "$DST_HOST" "$DST_DIR" "ssh"
# preserve .monitor content (if any)
MONITOR_CMD=$(cat <<EOF
if [ -r '${SRC_DIR}/.monitor' ]; then
cat '${SRC_DIR}/.monitor' 2>/dev/null || :
fi
EOF
)
MONITOR=$(ssh_monitor_and_log "$SRC_HOST" "$MONITOR_CMD" 'Get .monitor')
ssh_make_path "$DST_HOST" "$DST_PATH" "$MONITOR"
log "Moving $SRC to $DST"