onehost_create_all

This commit is contained in:
Emmanuel Garette 2019-02-25 12:11:30 +01:00
parent 4c7ebd5d27
commit 42dfb0cdaa
3 changed files with 32 additions and 31 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,12 @@ 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
@ -44,12 +49,12 @@ function sync_host()
{
CMD="onehost"
OPT="sync -f --rsync"
res=$(su - oneadmin -c "${CMD} ${OPT}")
res=$(su - ${ONEUSER} -c "${CMD} ${OPT}")
if [[ ${?} -ne 0 ]]
then
error "Hosts sync failed"
EchoRouge "Hosts sync failed $res"
else
echo "Hosts sync OK"
EchoVert "Hosts sync OK"
fi
}
@ -87,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
#
@ -117,10 +133,14 @@ then
exit 1
fi
if [ "$(CreoleGet activer_one_ha)" = "oui" ] && [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
follower=0
else
follower=1
follower=1
master=1
if [ "$(CreoleGet activer_one_ha)" = "oui" ];
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
follower=0
else
master=0
fi
fi
for host in ${HAPY_SLV}; do
echo -e "\n"
@ -144,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é"