The default cluster can be renamed

* dicos/29_one-master.xml: “one_cluster_name” store the name of the
  default cluster.

* postservice/30-one-mng: take care of the customizable cluster name.

* postservice/31-one-netmng: ditoo.

* scripts/onehost_create_all: ditoo.

Ref: #23553
This commit is contained in:
Daniel Dehennin 2018-04-09 10:23:41 +02:00
parent 1a911bd9fc
commit 939f1b7591
4 changed files with 38 additions and 49 deletions

View File

@ -23,6 +23,9 @@
<variable name='activer_onesinglenode' type='oui/non' description="Activer le serveur de virtualisation" mode='expert'>
<value>oui</value>
</variable>
<variable name='one_cluster_name' type='string' description="Nom de la grappe OpenNebula par défaut" mode='expert'>
<value>default</value>
</variable>
<variable name='vnet_pilote' type='string' description='Pilote réseau' hidden='True' />
<variable name='vnets' type='string' description='Réseaux virtuels Niveau 3' multi='True'/>
<variable name='vnet_network_addr' type='ip' description='Adresse du réseau'/>

View File

@ -21,44 +21,35 @@ function get_one_auth()
${CMD} ${FILE}
}
# ref https://dev-eole.ac-dijon.fr/issues/16797
#function check_cluster()
#{
# name="${1}"
# cmd="onecluster"
# opt="list"
# auth=$(get_one_auth)
#
# res=0
# clst_list=$(${cmd} ${opt} --user ${auth%:*} --password ${auth#*:} | tail -n +2 | awk -F ' ' '{print $2}')
# for hst in ${clst_list}
# do
# [[ "${NAME}" = "${hst}" ]] && res=$((res+1))
# done
# return ${res}
#}
function check_default_cluster()
{
name="${1}"
cmd="onecluster show 0"
auth=$(get_one_auth)
# ref https://dev-eole.ac-dijon.fr/issues/16797
#function manage_cluster()
#{
# NAME="${1}"
# CMD="onecluster create"
# AUTH=$(get_one_auth)
#
# check_cluster ${clst_name}
# if [[ ${?} -eq 0 ]]
# then
# crt=$(${CMD} --user ${AUTH%:*} --password ${AUTH#*:} ${NAME})
# if [[ ${?} -ne 0 ]]
# then
# error "Cluster create failed"
# else
# echo "Cluster ${NAME} created"
# fi
# else
# echo "Cluster \"${NAME}\" already exist"
# fi
#}
DEFAULT_NAME=$(${cmd} --user ${auth%:*} --password ${auth#*:} | awk '/^NAME/ {print $3}')
[[ "${name}" = "${DEFAULT_NAME}" ]]
}
function rename_default_cluster()
{
NAME="${1}"
CMD="onecluster rename 0 ${NAME}"
AUTH=$(get_one_auth)
if ! check_default_cluster "${NAME}"
then
if ${CMD} --user ${AUTH%:*} --password ${AUTH#*:}
then
echo "The default cluster name is now '${NAME}'"
else
error "The default cluster can not be renamed"
fi
else
echo "The default cluster name is already \"${NAME}\""
fi
}
function check_host()
{
@ -437,10 +428,9 @@ function manage_datastores()
function main()
{
#
# Creating Cluster
# ref https://dev-eole.ac-dijon.fr/issues/16797
#clst_name=$(CreoleGet one_cluster_name)
#manage_cluster ${clst_name}
# Rename default cluster
clst_name=$(CreoleGet one_cluster_name)
rename_default_cluster "${clst_name}"
#
# Creating Host
@ -454,12 +444,12 @@ function main()
#
# Attaching Host to the Cluster
#
attach_host ${host} "default"
attach_host ${host} "${clst_name}"
#
# Création des Datastores
#
manage_datastores ${clst_name}
manage_datastores "${clst_name}"
}
main

View File

@ -289,9 +289,7 @@ def main():
client = CreoleClient()
one_client = OneClient('oneadmin')
networks = []
# ref https://dev-eole.ac-dijon.fr/issues/16797
# cluster = client.get_creole('one_cluster_name')
cluster = "default"
cluster = client.get_creole('one_cluster_name')
swname = client.get_creole('ovs_sw_name')
zones = client.get_creole('vnets')
vlans = client.get_creole('vnet_vlan_tag')

View File

@ -24,9 +24,7 @@ function copy_ssh_id()
#
function register_node()
{
# ref https://dev-eole.ac-dijon.fr/issues/16797
#cmd="onehost create -i kvm -v kvm -n ovswitch -c \"$(CreoleGet one_cluster_name)\" ${1}"
cmd="onehost create -i kvm -v kvm -n ovswitch -c \"default\" ${1}"
cmd="onehost create -i kvm -v kvm -n ovswitch -c 0 ${1}"
ret=$(su - ${ONEUSER} -c -- "${cmd}")
return $?
}