Merge branch 'develop' into dist/eole/2.7.0/develop
This commit is contained in:
commit
4d46c6c38c
@ -433,7 +433,7 @@ function init_ha() {
|
||||
# server 0 not displayed with onezone
|
||||
SERVER=$(CreoleGet one_master)
|
||||
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
|
||||
for $follower in $FOLLOWER; do
|
||||
onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2
|
||||
@ -441,26 +441,12 @@ function init_ha() {
|
||||
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)
|
||||
|
@ -6,39 +6,55 @@
|
||||
#
|
||||
|
||||
. /usr/lib/eole/ihm.sh
|
||||
script="$1"
|
||||
|
||||
function clean_backups()
|
||||
{
|
||||
file=${1}
|
||||
bcks=($(ls ${file}_*))
|
||||
nbbck=$(expr ${#bcks[@]} - 2)
|
||||
file=${1}
|
||||
bcks=($(ls ${file}_*))
|
||||
nbbck=$(expr ${#bcks[@]} - 2)
|
||||
|
||||
|
||||
if [[ ${nbbck} -gt 1 ]]
|
||||
then
|
||||
EchoGras "Cleaning up old backups !"
|
||||
for idx in `seq 0 ${nbbck}`
|
||||
do
|
||||
rm -f ${bcks[${idx}]}
|
||||
done
|
||||
fi
|
||||
if [[ ${nbbck} -gt 1 ]]
|
||||
then
|
||||
EchoGras "Cleaning up old backups !"
|
||||
for idx in `seq 0 ${nbbck}`
|
||||
do
|
||||
rm -f ${bcks[${idx}]}
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function updateDB()
|
||||
{
|
||||
local dbfile='/var/lib/one/one.db'
|
||||
local cmd="onedb"
|
||||
local res=0
|
||||
local dbfile='/var/lib/one/one.db'
|
||||
local cmd="onedb"
|
||||
local res=0
|
||||
|
||||
if [[ -f ${dbfile} ]]
|
||||
then
|
||||
$cmd upgrade -f -s ${dbfile}
|
||||
res=${?}
|
||||
clean_backups ${dbfile}
|
||||
return ${res}
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
if [[ -f ${dbfile} ]]
|
||||
then
|
||||
$cmd upgrade -f -s ${dbfile}
|
||||
res=${?}
|
||||
clean_backups ${dbfile}
|
||||
return ${res}
|
||||
else
|
||||
return 0
|
||||
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
|
||||
@ -46,4 +62,5 @@ EchoGras "Mise à jour de la base de données ONE"
|
||||
echo
|
||||
updateDB
|
||||
echo
|
||||
to_mysql
|
||||
exit ${?}
|
||||
|
@ -8,3 +8,10 @@ if [ -z "${auth_mode}" ]; then
|
||||
else
|
||||
ln -s /var/lib/one/remotes/auth/{${auth_mode},default}
|
||||
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
|
||||
|
@ -170,7 +170,7 @@ RAFT = [
|
||||
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
|
||||
RAFT_LEADER_HOOK = [
|
||||
COMMAND = "raft/vip.sh",
|
||||
|
Loading…
Reference in New Issue
Block a user