Ajout du support OpenNebula HA dans Hâpy
Ajouter la possibilité de créer une grappe haute disponibilité entre plusieurs Hâpy (https://docs.opennebula.org/5.6/advanced_components/ha/index.html) Pré-requis : Les datastores doivent être partagés entre tous les Hâpy via NFS ou tout autre système de fichiers accécibles de manière concurrente entre les serveurs (Glusterfs, Ceph, DRBD). Pour faire ce développement nous nous sommes basés sur eole-glusterfs qui permet de créer une grappe glusterfs (https://dev-eole.ac-dijon.fr/projects/eole-glusterfs)
This commit is contained in:
@ -69,6 +69,21 @@ function check_host()
|
||||
return ${res}
|
||||
}
|
||||
|
||||
# Fix host creation error from 5.6.1 with sync methode rsync
|
||||
function sync_host()
|
||||
{
|
||||
CMD="onehost"
|
||||
OPT="sync -f --rsync"
|
||||
AUTH=$(get_one_auth)
|
||||
res=$(su - oneadmin -c "${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:}")
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Hosts sync failed"
|
||||
else
|
||||
echo "Hosts sync OK"
|
||||
fi
|
||||
}
|
||||
|
||||
function manage_host()
|
||||
{
|
||||
NAME=${1}
|
||||
@ -185,9 +200,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,10 +264,11 @@ function create_datastore()
|
||||
{
|
||||
ds_type="${1}"
|
||||
ds_name="${2}"
|
||||
# ref https://dev-eole.ac-dijon.fr/issues/16797
|
||||
local ha=$(CreoleGet activer_one_ha)
|
||||
# ref https://dev-eole.ac-dijon.fr/issues/16797
|
||||
#ds_cluster="${3}"
|
||||
|
||||
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]]
|
||||
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]] && [[ ${ha} == "non" ]]
|
||||
then
|
||||
SYS_TM_MAD='ssh'
|
||||
ISO_TM_MAD='ssh'
|
||||
@ -300,7 +316,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
|
||||
@ -316,13 +332,14 @@ function update_datastore()
|
||||
local cmd="onedatastore"
|
||||
local opt="show"
|
||||
local multinode=$(CreoleGet activer_multinode 2>&1)
|
||||
local ha=$(CreoleGet activer_one_ha)
|
||||
ds_type=""
|
||||
ds_mad=""
|
||||
ds_name=""
|
||||
|
||||
TMPL_FILE=$(mktemp)
|
||||
|
||||
if [[ ${multinode} == 'oui' ]]
|
||||
if [[ ${multinode} == 'oui' ]] && [[ ${ha} == "non" ]]
|
||||
then
|
||||
SYS_TM_MAD='ssh'
|
||||
ISO_TM_MAD='ssh'
|
||||
@ -384,11 +401,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 +415,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 +425,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 +435,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
|
||||
@ -430,32 +447,48 @@ function manage_datastores()
|
||||
function main()
|
||||
{
|
||||
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null"
|
||||
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
|
||||
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
|
||||
# ne pas faire sur les followers
|
||||
return
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# 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 activer_one_ha)" = "oui" ]; then
|
||||
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
|
||||
then
|
||||
host=$(CreoleGet nom_machine)
|
||||
manage_host ${host}
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Attaching Host to the Cluster
|
||||
#
|
||||
attach_host ${host} "${clst_name}"
|
||||
|
||||
#
|
||||
# Force host synchronisation
|
||||
#
|
||||
sync_host
|
||||
|
||||
#
|
||||
# Création des Datastores
|
||||
#
|
||||
manage_datastores "${clst_name}"
|
||||
|
||||
}
|
||||
|
||||
main
|
||||
main $@
|
||||
|
||||
exit 0
|
||||
|
@ -303,6 +303,14 @@ def main():
|
||||
logger.debug(u"Configure OpenNebula networks")
|
||||
|
||||
client = CreoleClient()
|
||||
|
||||
mode_ha = client.get_creole('activer_one_ha')
|
||||
if mode_ha == "oui":
|
||||
indx = client.get_creole('one_ha_server_index')
|
||||
if indx != 0:
|
||||
# Mode HA is on and we are not in the Leader
|
||||
exit(0)
|
||||
|
||||
one_client = OneClient('oneadmin')
|
||||
networks = []
|
||||
cluster = client.get_creole('one_cluster_name')
|
||||
|
15
postservice/99-z-ha
Normal file
15
postservice/99-z-ha
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
ha=$(CreoleGet activer_one_ha non)
|
||||
if [[ ${ha} == "oui" ]]
|
||||
then
|
||||
indx=$(CreoleGet one_ha_server_index)
|
||||
else
|
||||
indx="0"
|
||||
fi
|
||||
|
||||
if [[ ${1} == "instance" ]] && [[ ${indx} == "0" ]]
|
||||
then
|
||||
/usr/share/eole/sbin/onehost_create_all
|
||||
fi
|
||||
exit 0
|
Reference in New Issue
Block a user