Merge branch 'feature/manage-default-cluster-name'

This commit is contained in:
Daniel Dehennin 2018-04-09 11:13:15 +02:00
commit 151ce345e7
4 changed files with 38 additions and 49 deletions

View File

@ -27,6 +27,9 @@
</variable>
</family>
<family name='Virtualisation' icon='cloud'>
<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 utilisé pour le réseau virtuel' hidden='True' />
<variable name='vnets' type='string' description="Nom du réseau virtuel à plage d'adresse IP" multi='True'/>
<variable name='vnet_range_start' type='ip' description='Première IP de la plage' mandatory="True"/>

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}"
# Wait 4 seconds for service (ref #16848)
sleep 4
@ -457,12 +447,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

@ -34,9 +34,7 @@ EOF
#
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 -c \"default\" ${1}"
cmd="onehost create -i kvm -v kvm -c 0 ${1}"
ret=$(su - ${ONEUSER} -c -- "${cmd}")
return $?
}