Merge branch 'develop' into dist/eole/2.7.0/develop

This commit is contained in:
vincent 2019-02-25 12:16:25 +01:00
commit 574e04ce9b
3 changed files with 45 additions and 29 deletions

View File

@ -462,9 +462,7 @@ function main()
#
# Creating Host
#
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
/usr/share/eole/sbin/onehost_create_all
else
if [ ! "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
function init_ha_leader() {
# server with index 1 exists if already instanciate
onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 "
if [ ! $? = 0 ]; then
FOLLOWER=$(CreoleGet one_nodes)
for follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
done
fi
}
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then
init_ha_leader
fi
fi
exit 0

View File

@ -36,7 +36,26 @@ function register_node()
{
cmd="onehost create -i kvm -v kvm -c 0 ${1}"
ret=$(su - ${ONEUSER} -c -- "${cmd}")
return $?
if [[ ${?} -ne 0 ]]
then
EchoRouge "Hosts register failed $res"
else
EchoVert "Hosts register OK"
fi
}
# Fix host creation error from 5.6.1 with sync methode rsync
function sync_host()
{
CMD="onehost"
OPT="sync -f --rsync"
res=$(su - ${ONEUSER} -c "${CMD} ${OPT}")
if [[ ${?} -ne 0 ]]
then
EchoRouge "Hosts sync failed $res"
else
EchoVert "Hosts sync OK"
fi
}
#
@ -58,7 +77,7 @@ function wait_node_ok()
[[ ${st} == '' ]] && break
if [[ ${st} == "ERROR" ]]
then
RET=2
RET=50
break
fi
@ -73,6 +92,17 @@ function wait_node_ok()
return ${RET}
}
function init_ha_leader() {
# server with index 1 exists if already instanciate
onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 "
if [ ! $? = 0 ]; then
FOLLOWER=$(CreoleGet one_nodes)
for follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
done
fi
}
#
# MAIN
#
@ -103,10 +133,14 @@ then
exit 1
fi
if [ "$(CreoleGet activer_one_ha)" = "oui" ] && [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
follower=1
master=1
if [ "$(CreoleGet activer_one_ha)" = "oui" ];
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
follower=0
else
follower=1
else
master=0
fi
fi
for host in ${HAPY_SLV}; do
echo -e "\n"
@ -122,6 +156,7 @@ for host in ${HAPY_SLV}; do
EchoVert " * Enregistrement du noeud"
register_node ${host}
sync_host ${host}
wait_node_ok ${host}
if [[ ${?} -ne 0 ]]
then
@ -129,5 +164,8 @@ for host in ${HAPY_SLV}; do
fi
done
if [ $master = 0 ]; then
init_ha_leader
fi
echo -e "\n"
EchoVert "Enregistrement des noeuds terminé"