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

This commit is contained in:
vincent 2019-02-19 09:53:53 +01:00
commit 4d46c6c38c
4 changed files with 49 additions and 39 deletions

View File

@ -433,7 +433,7 @@ function init_ha() {
# server 0 not displayed with onezone # server 0 not displayed with onezone
SERVER=$(CreoleGet one_master) SERVER=$(CreoleGet one_master)
DOMAIN=$(CreoleGet nom_domaine_machine) DOMAIN=$(CreoleGet nom_domaine_machine)
FOLLOWER=$(CreoleGet one_follower_servername) FOLLOWER=$(CreoleGet one_followers_domain)
onezone server-add 0 --name $SERVER --rpc http://$DOMAIN:2633/RPC2 onezone server-add 0 --name $SERVER --rpc http://$DOMAIN:2633/RPC2
for $follower in $FOLLOWER; do for $follower in $FOLLOWER; do
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2 onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
@ -441,26 +441,12 @@ function init_ha() {
fi 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() function main()
{ {
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null"
if [ $(CreoleGet one_ha_role) = "leader" ]; then if [ $(CreoleGet one_ha_role) = "leader" ]; then
init_ha init_ha
fi fi
to_mysql
# #
# Rename default cluster # Rename default cluster
clst_name=$(CreoleGet one_cluster_name) clst_name=$(CreoleGet one_cluster_name)

View File

@ -6,6 +6,7 @@
# #
. /usr/lib/eole/ihm.sh . /usr/lib/eole/ihm.sh
script="$1"
function clean_backups() function clean_backups()
{ {
@ -41,9 +42,25 @@ function updateDB()
fi fi
} }
function to_mysql() {
if [ "$script" = 'instance' ] && [ $(CreoleGet one_database_type) = "mysql" ] && [ $(CreoleGet one_ha_role leader) = "leader" ]; then
Question_ouinon "Voulez-vous migrer de SQLite à Mysql ?" "True" "non" "warn"
rep=$(echo "$?")
if [ "$rep" == "0" ]; 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
fi
fi
}
echo echo
EchoGras "Mise à jour de la base de données ONE" EchoGras "Mise à jour de la base de données ONE"
echo echo
updateDB updateDB
echo echo
to_mysql
exit ${?} exit ${?}

View File

@ -8,3 +8,10 @@ if [ -z "${auth_mode}" ]; then
else else
ln -s /var/lib/one/remotes/auth/{${auth_mode},default} ln -s /var/lib/one/remotes/auth/{${auth_mode},default}
fi fi
# creation de la base /var/lib/one/one.db
if [ ! -e /var/lib/one/one.db ]; then
systemctl daemon-reload
systemctl start opennebula.service
fi
exit 0

View File

@ -170,7 +170,7 @@ RAFT = [
XMLRPC_TIMEOUT_MS = 450 XMLRPC_TIMEOUT_MS = 450
] ]
%if %%enable_one_ha == 'oui' and one_ha_role == 'leader' %if %%enable_one_ha == 'oui' and %%one_ha_role == 'leader'
# Executed when a server transits from follower->leader # Executed when a server transits from follower->leader
RAFT_LEADER_HOOK = [ RAFT_LEADER_HOOK = [
COMMAND = "raft/vip.sh", COMMAND = "raft/vip.sh",