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

This commit is contained in:
vincent 2019-02-18 14:10:15 +01:00
commit fc7b2409b8
5 changed files with 93 additions and 40 deletions

View File

@ -59,7 +59,7 @@
<variable name="one_database_user" description="Utilisateur pour se connecter à la base de données" type="string" mandatory="True">
<value>one</value>
</variable>
<variable name="one_database_pass" description="Mot de passe pour se connecter à la base de données" type="string" mandatory="True"/>
<variable name="one_database_pass" description="Mot de passe pour se connecter à la base de données" type="password" mandatory="True"/>
<!-- VNETS -->
<variable name='vnet_pilote' type='string' description='Pilote utilisé pour le réseau virtuel' hidden='True' />

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="adresse_ip_eth0">
<param type='eole' hidden='False'>one_vip</param>
</check>
<check name="valid_differ" target="adresse_ip_gw">
<param type='eole' hidden='False'>one_vip</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

@ -427,9 +427,40 @@ 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)

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