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

Feature #3574: Improve error message reporting

in ssh_monitor_and_log
This commit is contained in:
Jaime Melis 2015-02-20 20:28:07 +01:00
parent 697fd4e3f8
commit 2420cf3aa7

View File

@ -358,7 +358,9 @@ EOF`
fi
}
#This function executes $2 at $1 host and returns stdout
# This function executes $2 at $1 host and returns stdout
# If $3 is present, it is used as the error message when
# the command fails
function ssh_monitor_and_log
{
SSH_EXEC_OUT=`$SSH $1 sh -s 2>/dev/null <<EOF
@ -369,8 +371,12 @@ EOF`
SSH_EXEC_RC=$?
if [ $SSH_EXEC_RC -ne 0 ]; then
log_error "Command \"$2\" failed: $SSH_EXEC_OUT"
error_message "Cannot monitor $1"
if [ -n "$3" ]; then
log_error "Command \"$3\" failed: $SSH_EXEC_OUT"
else
log_error "Command \"$2\" failed: $SSH_EXEC_OUT"
fi
exit $SSH_EXEC_RC
fi