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

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