This commit is contained in:
Emmanuel Garette 2019-02-15 16:51:53 +01:00
parent 09389489f2
commit 5eeb4d6832
4 changed files with 92 additions and 39 deletions

View File

@ -10,9 +10,10 @@
</family>
<family name='Haute disponibilité' icon='cloud'>
<variable name="one_ha_role" description="Rôle initial dans la grappe OpenNebula" type="string" mandatory="True"/>
<variable name="one_host_id" description="Identififiant unique de l'hôte dans la grappe" type="number" mandatory="True"/>
<variable name="one_server_index" description="Index du serveur dans la liste des orchestrateurs follower" type="number" mandatory="True"/>
<variable name='one_followers_domain' description='Nom de domaine des orchestrateurs follower' multi="True" type="domain_strict" mandatory="True" auto_freeze="True"/>
<variable name="one_vip" description="Adresse IP de la VIP OpenNebula" type="ip" mandatory="True"/>
<variable name="one_vip_mask" description="Masque de sous-réseau de la VIP OpenNebula (format CIDR)" type="number" mandatory="True"/>
<variable name="one_vip_mask" description="Masque de sous-réseau de la VIP OpenNebula" type="netmask" mandatory="True"/>
</family>
<separators>
<separator name='one_ha_role'>Rôle du nœud de virtualisation</separator>
@ -29,14 +30,41 @@
<param>non</param>
<target type='family'>Haute disponibilité</target>
</condition>
<condition name='disabled_if_in' source='one_ha_role'>
<param>follower</param>
<target type='variable'>one_followers_domain</target>
<target type='variable'>one_vip</target>
<target type='variable'>one_vip_mask</target>
</condition>
<condition name='frozen_if_in' source='one_ha_role'>
<param>leader</param>
<target type='variable'>one_server_index</target>
</condition>
<auto name='calc_multi_condition' target='one_server_index'>
<param>leader</param>
<param type='eole' name='condition_1'>one_ha_role</param>
<param name='match' type='number'>0</param>
<param name='default_mismatch'>None</param>
</auto>
<fill name='calc_val' target='one_vip_mask'>
<param type='eole' name='valeur'>adresse_netmask_eth0</param>
</fill>
<check name="valid_differ" target="one_vip">
<param type='eole'>adresse_ip_eth0</param>
</check>
<check name="valid_differ" target="one_vip">
<param type='eole'>adresse_ip_gw</param>
</check>
<check name="valid_ipnetmask" target="one_vip_mask" level="warning">
<param type='eole'>one_vip</param>
</check>
</constraints>
<help>
<variable name='enable_one_ha'>Active la possibilité d'intégrer Hâpy dans une grappe de haute disponibilité OpenNebula</variable>
<family name='Haute disponibilité'>Configuration du comportement du noeud dans la grappe</family>
<variable name="one_ha_role">Rôle initial du noeud dans la grappe, permet de déterminer comment le serveur commence sa vie dans la grappe</variable>
<variable name="one_host_id">Identifiant unique du serveur dans la grappe, cet identifiant est un entier (0,1,2,3...)</variable>
<variable name="one_vip">Adresse IP virtuelle (VIP) utilisée pour joindre le "Leader" de la grappe, les clients utiliseront cette IP pour contacter la grappe</variable>
<variable name="one_vip_mask">Masque de sous réseau du réseau de la VIP au format CIDR (ex: 24 pour 255.255.255.0)</variable>
</help>

View File

@ -185,9 +185,9 @@ function attach_host()
{
HOST=${1}
CLST=${2}
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#CLST_ID=$(get_cluster_id_by_name ${CLST})
CLST_ID=0
CLST_ID=0
HST_ID=$(get_host_id_by_name ${HOST})
AUTH=$(get_one_auth)
CMD="onecluster"
@ -249,7 +249,7 @@ function create_datastore()
{
ds_type="${1}"
ds_name="${2}"
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#ds_cluster="${3}"
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]]
@ -300,7 +300,7 @@ __EOF__
RUN=$(${cmd} ${opt})
if [[ ${?} -eq 0 ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#attach_ds_to_cluster ${ds_name} ${ds_cluster}
rm ${TMPL_FILE}
return 0
@ -384,11 +384,11 @@ __EOF__
function manage_datastores()
{
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#cluster=${1}
AUTH=$(get_one_auth)
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')${cluster}"
SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')default"
ISO_DS=$(CreoleGet 'one_ds_iso_name')
@ -398,7 +398,7 @@ function manage_datastores()
sid=$(get_ds_id_by_name ${SYSTEM_DS})
if [[ ${sid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "SYSTEM" "${SYSTEM_DS}" "${cluster}"
create_datastore "SYSTEM" "${SYSTEM_DS}"
else
@ -408,7 +408,7 @@ function manage_datastores()
imgid=$(get_ds_id_by_name ${IMAGE_DS})
if [[ ${imgid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "IMAGE" "${IMAGE_DS}" "${cluster}"
create_datastore "IMAGE" "${IMAGE_DS}"
else
@ -418,7 +418,7 @@ function manage_datastores()
isoid=$(get_ds_id_by_name ${ISO_DS})
if [[ ${isoid} = "ERR" ]]
then
# ref https://dev-eole.ac-dijon.fr/issues/16797
# ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "ISO" "${ISO_DS}" "${cluster}"
create_datastore "ISO" "${ISO_DS}"
else
@ -427,25 +427,56 @@ function manage_datastores()
return 0
}
function init_ha() {
onezone show 0 | grep -A 2 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 0 "
if [ ! $? = 0 ]; then
# server 0 not displayed with onezone
SERVER=$(CreoleGet one_master)
DOMAIN=$(CreoleGet nom_domaine_machine)
FOLLOWER=$(CreoleGet one_follower_servername)
onezone server-add 0 --name $SERVER --rpc http://$DOMAIN:2633/RPC2
for $follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
done
fi
}
function to_mysql() {
if [ $(CreoleGet one_database_type) = "mysql" && $(CreoleGet one_ha_role leader) = "leader" ]; then
# do not recover db on follower
HOST=$(CreoleGet one_database_host)
DB=$(CreoleGet one_database_name)
USER=$(CreoleGet one_database_user)
PASS=$(CreoleGet one_database_pass)
onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST
systemctl stop opennebula.service
systemctl start opennebula.service
fi
}
function main()
{
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null"
if [ $(CreoleGet one_ha_role) = "leader" ]; then
init_ha
fi
to_mysql
#
# Rename default cluster
clst_name=$(CreoleGet one_cluster_name)
rename_default_cluster "${clst_name}"
# Wait 4 seconds for service (ref #16848)
sleep 4
# Wait 4 seconds for service (ref #16848)
sleep 4
#
# Creating Host
#
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)
manage_host ${host}
fi
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)
manage_host ${host}
fi
#
# Attaching Host to the Cluster

View File

@ -1,12 +0,0 @@
SERVER=$(CreoleGet one_master)
IP=$(CreoleGet adresse_ip_eth0)
if [ $(CreoleGet one_database_type) = "mysql" && $(CreoleGet one_ha_role) = "leader" ]; then
HOST=$(CreoleGet one_database_host)
DB=$(CreoleGet one_database_name)
USER=$(CreoleGet one_database_user)
PASS=$(CreoleGet one_database_pass)
onedb sqlite2mysql -s /var/lib/one/one.db -u $USER -p $PASS -d $DB -S $HOST
systemctl stop opennebula
systemctl start opennebula
fi
onezone server-add 0 --name $SERVER --rpc http://$IP:2633/RPC2

View File

@ -153,7 +153,11 @@ VNC_PORTS = [
FEDERATION = [
MODE = "STANDALONE",
ZONE_ID = 0,
%if %%enable_one_ha == 'oui'
SERVER_ID = %%one_server_index,
%else
SERVER_ID = -1,
%end if
MASTER_ONED = ""
]
@ -166,17 +170,19 @@ RAFT = [
XMLRPC_TIMEOUT_MS = 450
]
%if %%enable_one_ha == 'oui' and one_ha_role == 'leader'
# Executed when a server transits from follower->leader
# RAFT_LEADER_HOOK = [
# COMMAND = "raft/vip.sh",
# ARGUMENTS = "leader <interface> <ip_cidr>"
# ]
RAFT_LEADER_HOOK = [
COMMAND = "raft/vip.sh",
ARGUMENTS = "leader %%nom_zone_eth0 %%one_vip/%%calc_classe(%%one_vip_mask)"
]
# Executed when a server transits from leader->follower
# RAFT_FOLLOWER_HOOK = [
# COMMAND = "raft/vip.sh",
# ARGUMENTS = "follower <interface> <ip_cidr>"
# ]
RAFT_FOLLOWER_HOOK = [
COMMAND = "raft/vip.sh",
ARGUMENTS = "follower %%nom_zone_eth0 %%one_vip/%%calc_classe(%%one_vip_mask)"
]
%end if
#*******************************************************************************
# Default showback cost