mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B #4781: move ssh_exec_and_log_no_exit to library
This commit is contained in:
parent
33b96e7357
commit
098fe29463
@ -330,8 +330,8 @@ function mkfs_command {
|
||||
fi
|
||||
}
|
||||
|
||||
#This function executes $2 at $1 host and report error $3
|
||||
function ssh_exec_and_log
|
||||
#This function executes $2 at $1 host and report error $3 but does not exit
|
||||
function ssh_exec_and_log_no_error
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
export LANG=C
|
||||
@ -349,7 +349,20 @@ EOF`
|
||||
error_message "Error executing $2: $SSH_EXEC_ERR"
|
||||
fi
|
||||
|
||||
exit $SSH_EXEC_RC
|
||||
return $SSH_EXEC_RC
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#This function executes $2 at $1 host and report error $3
|
||||
function ssh_exec_and_log
|
||||
{
|
||||
ssh_exec_and_log "$@"
|
||||
rc=$?
|
||||
|
||||
if [ $rc !=0 ]; then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -24,28 +24,6 @@
|
||||
# - vmid is the id of the VM
|
||||
# - dsid is the target datastore (0 is the system datastore)
|
||||
|
||||
function ssh_exec_and_log_no_exit
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
$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
|
||||
|
||||
return $SSH_EXEC_RC
|
||||
fi
|
||||
}
|
||||
|
||||
SIZE=$1
|
||||
FSTYPE=$2
|
||||
DST=$3
|
||||
|
Loading…
x
Reference in New Issue
Block a user