mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
B #1136 Avoid using disabled/off hosts
This commit is contained in:
parent
a9d43e9f3a
commit
fad4a1c454
@ -450,6 +450,31 @@ function check_restricted {
|
||||
echo 0
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Filter out hosts which are not ON
|
||||
# @param $1 - space separated list of hosts
|
||||
# @return - space separated list of hosts which are in ON state
|
||||
#-------------------------------------------------------------------------------
|
||||
function get_only_on_hosts {
|
||||
INPUT_ARRAY=($1)
|
||||
|
||||
ONEHOST_LIST_ON_CMD='onehost list --no-pager --csv --filter="STAT=on" --list=NAME,STAT'
|
||||
ON_HOSTS_STR=$(eval "$ONEHOST_LIST_ON_CMD 2>/dev/null")
|
||||
|
||||
if [[ $? = 0 ]]; then
|
||||
ON_HOSTS_ARRAY=($( echo "$ON_HOSTS_STR" | $AWK -F, '{ if (NR>1) print $1 }'))
|
||||
for A in "${INPUT_ARRAY[@]}"; do
|
||||
for B in "${ON_HOSTS_ARRAY[@]}"; do
|
||||
[[ $A == $B ]] && { echo $A; break; }
|
||||
done
|
||||
done
|
||||
else
|
||||
# onehost cmd failed, can't filter anything, better return unchanged
|
||||
echo $1
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Gets the host to be used as bridge to talk to the storage system
|
||||
# Implements a round robin for the bridges
|
||||
@ -458,6 +483,7 @@ function check_restricted {
|
||||
# @return host to be used as bridge
|
||||
#-------------------------------------------------------------------------------
|
||||
function get_destination_host {
|
||||
BRIDGE_LIST=$(get_only_on_hosts "$BRIDGE_LIST")
|
||||
HOSTS_ARRAY=($BRIDGE_LIST)
|
||||
N_HOSTS=${#HOSTS_ARRAY[@]}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user