Utilisation du cluster par défaut ONE 5.0

Plutôt que de créer un cluster "par défaut" eole on utilise la
fonctionnalité incluse dans ONE 5.0

Toutes les resources sont automatiquement attachées au cluster défaut.

ref #16797 @2h
This commit is contained in:
Philippe Caseiro 2016-07-21 14:32:53 +02:00
parent 051136ac81
commit 1a911bd9fc
4 changed files with 89 additions and 78 deletions

View File

@ -24,9 +24,6 @@
<value>oui</value> <value>oui</value>
</variable> </variable>
<variable name='vnet_pilote' type='string' description='Pilote réseau' hidden='True' /> <variable name='vnet_pilote' type='string' description='Pilote réseau' hidden='True' />
<variable name='one_cluster_name' type='string' description="Nom de la grappe OpenNebula" mode='expert' auto_freeze='True' mandatory="True">
<value></value>
</variable>
<variable name='vnets' type='string' description='Réseaux virtuels Niveau 3' multi='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'/> <variable name='vnet_network_addr' type='ip' description='Adresse du réseau'/>
<variable name='vnet_network_mask' type='netmask' description='Masque du réseau'/> <variable name='vnet_network_mask' type='netmask' description='Masque du réseau'/>
@ -114,10 +111,6 @@
<param>openvswitch</param> <param>openvswitch</param>
<param type="eole" name="condition_1">vnet_pilote</param> <param type="eole" name="condition_1">vnet_pilote</param>
</auto> </auto>
<fill name='concat' target='one_cluster_name'>
<param>CL-</param>
<param type='eole'>numero_etab</param>
</fill>
<check name='valid_enum' target='one_video_driver'> <check name='valid_enum' target='one_video_driver'>
<param>['qxl','vga','std','cirrus']</param> <param>['qxl','vga','std','cirrus']</param>
@ -127,7 +120,6 @@
<condition name='disabled_if_in' source='activer_onesinglenode'> <condition name='disabled_if_in' source='activer_onesinglenode'>
<param>non</param> <param>non</param>
<target type='filelist'>onesinglenode</target> <target type='filelist'>onesinglenode</target>
<target type='variable'>one_cluster_name</target>
<target type='variable'>one_ds_system_prefix</target> <target type='variable'>one_ds_system_prefix</target>
<target type='variable'>one_ds_iso_name</target> <target type='variable'>one_ds_iso_name</target>
<target type='variable'>one_ds_image_name</target> <target type='variable'>one_ds_image_name</target>

View File

@ -21,42 +21,44 @@ function get_one_auth()
${CMD} ${FILE} ${CMD} ${FILE}
} }
function check_cluster() # ref https://dev-eole.ac-dijon.fr/issues/16797
{ #function check_cluster()
name="${1}" #{
cmd="onecluster" # name="${1}"
opt="list" # cmd="onecluster"
auth=$(get_one_auth) # 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}
#}
res=0 # ref https://dev-eole.ac-dijon.fr/issues/16797
clst_list=$(${cmd} ${opt} --user ${auth%:*} --password ${auth#*:} | tail -n +2 | awk -F ' ' '{print $2}') #function manage_cluster()
for hst in ${clst_list} #{
do # NAME="${1}"
[[ "${NAME}" = "${hst}" ]] && res=$((res+1)) # CMD="onecluster create"
done # AUTH=$(get_one_auth)
return ${res} #
} # check_cluster ${clst_name}
# if [[ ${?} -eq 0 ]]
function manage_cluster() # then
{ # crt=$(${CMD} --user ${AUTH%:*} --password ${AUTH#*:} ${NAME})
NAME="${1}" # if [[ ${?} -ne 0 ]]
CMD="onecluster create" # then
AUTH=$(get_one_auth) # error "Cluster create failed"
# else
check_cluster ${clst_name} # echo "Cluster ${NAME} created"
if [[ ${?} -eq 0 ]] # fi
then # else
crt=$(${CMD} --user ${AUTH%:*} --password ${AUTH#*:} ${NAME}) # echo "Cluster \"${NAME}\" already exist"
if [[ ${?} -ne 0 ]] # fi
then #}
error "Cluster create failed"
else
echo "Cluster ${NAME} created"
fi
else
echo "Cluster \"${NAME}\" already exist"
fi
}
function check_host() function check_host()
{ {
@ -190,7 +192,9 @@ function attach_host()
{ {
HOST=${1} HOST=${1}
CLST=${2} CLST=${2}
CLST_ID=$(get_cluster_id_by_name ${CLST}) # ref https://dev-eole.ac-dijon.fr/issues/16797
#CLST_ID=$(get_cluster_id_by_name ${CLST})
CLST_ID=0
HST_ID=$(get_host_id_by_name ${HOST}) HST_ID=$(get_host_id_by_name ${HOST})
AUTH=$(get_one_auth) AUTH=$(get_one_auth)
CMD="onecluster" CMD="onecluster"
@ -226,32 +230,34 @@ function attach_host()
# #
# Attach a datastore to a cluster # Attach a datastore to a cluster
# #
function attach_ds_to_cluster() # ref https://dev-eole.ac-dijon.fr/issues/16797
{ #function attach_ds_to_cluster()
DS=${1} #{
CLST=${2} # DS=${1}
CLST_ID=$(get_cluster_id_by_name ${CLST}) # CLST=${2}
DS_ID=$(get_ds_id_by_name ${ds_name}) # CLST_ID=$(get_cluster_id_by_name ${CLST})
AUTH=$(get_one_auth) # DS_ID=$(get_ds_id_by_name ${ds_name})
CMD="onecluster" # AUTH=$(get_one_auth)
OPT="adddatastore ${CLST_ID} ${DS_ID}" # CMD="onecluster"
# OPT="adddatastore ${CLST_ID} ${DS_ID}"
RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:}) #
if [[ ${?} -ne 0 ]] # RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
then # if [[ ${?} -ne 0 ]]
error "Attaching ${DS} to ${CLST} failed." # then
else # error "Attaching ${DS} to ${CLST} failed."
echo "Datastore ${DS} attached to ${CLST}." # else
return 0 # echo "Datastore ${DS} attached to ${CLST}."
fi # return 0
return 0 # fi
} # return 0
#}
function create_datastore() function create_datastore()
{ {
ds_type="${1}" ds_type="${1}"
ds_name="${2}" ds_name="${2}"
ds_cluster="${3}" # 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' ]]
then then
@ -297,12 +303,12 @@ __EOF__
auth=$(get_one_auth) auth=$(get_one_auth)
cmd="onedatastore" cmd="onedatastore"
#opt="create --user ${AUTH%:*} --password ${AUTH#*:} -c ${ds_cluster} ${TMPL_FILE}"
opt="create --user ${AUTH%:*} --password ${AUTH#*:} ${TMPL_FILE}" opt="create --user ${AUTH%:*} --password ${AUTH#*:} ${TMPL_FILE}"
RUN=$(${cmd} ${opt}) RUN=$(${cmd} ${opt})
if [[ ${?} -eq 0 ]] if [[ ${?} -eq 0 ]]
then then
attach_ds_to_cluster ${ds_name} ${ds_cluster} # ref https://dev-eole.ac-dijon.fr/issues/16797
#attach_ds_to_cluster ${ds_name} ${ds_cluster}
rm ${TMPL_FILE} rm ${TMPL_FILE}
return 0 return 0
else else
@ -385,10 +391,13 @@ __EOF__
function manage_datastores() function manage_datastores()
{ {
cluster=${1} # ref https://dev-eole.ac-dijon.fr/issues/16797
#cluster=${1}
AUTH=$(get_one_auth) AUTH=$(get_one_auth)
SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')${cluster}" # 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') ISO_DS=$(CreoleGet 'one_ds_iso_name')
IMAGE_DS=$(CreoleGet 'one_ds_image_name') IMAGE_DS=$(CreoleGet 'one_ds_image_name')
@ -396,7 +405,9 @@ function manage_datastores()
sid=$(get_ds_id_by_name ${SYSTEM_DS}) sid=$(get_ds_id_by_name ${SYSTEM_DS})
if [[ ${sid} = "ERR" ]] if [[ ${sid} = "ERR" ]]
then then
create_datastore "SYSTEM" "${SYSTEM_DS}" "${cluster}" # ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "SYSTEM" "${SYSTEM_DS}" "${cluster}"
create_datastore "SYSTEM" "${SYSTEM_DS}"
else else
update_datastore ${AUTH} ${sid} update_datastore ${AUTH} ${sid}
fi fi
@ -404,7 +415,9 @@ function manage_datastores()
imgid=$(get_ds_id_by_name ${IMAGE_DS}) imgid=$(get_ds_id_by_name ${IMAGE_DS})
if [[ ${imgid} = "ERR" ]] if [[ ${imgid} = "ERR" ]]
then then
create_datastore "IMAGE" "${IMAGE_DS}" "${cluster}" # ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "IMAGE" "${IMAGE_DS}" "${cluster}"
create_datastore "IMAGE" "${IMAGE_DS}"
else else
update_datastore ${AUTH} ${imgid} update_datastore ${AUTH} ${imgid}
fi fi
@ -412,7 +425,9 @@ function manage_datastores()
isoid=$(get_ds_id_by_name ${ISO_DS}) isoid=$(get_ds_id_by_name ${ISO_DS})
if [[ ${isoid} = "ERR" ]] if [[ ${isoid} = "ERR" ]]
then then
create_datastore "ISO" "${ISO_DS}" "${cluster}" # ref https://dev-eole.ac-dijon.fr/issues/16797
#create_datastore "ISO" "${ISO_DS}" "${cluster}"
create_datastore "ISO" "${ISO_DS}"
else else
update_datastore ${AUTH} ${isoid} update_datastore ${AUTH} ${isoid}
fi fi
@ -423,9 +438,9 @@ function main()
{ {
# #
# Creating Cluster # Creating Cluster
# # ref https://dev-eole.ac-dijon.fr/issues/16797
clst_name=$(CreoleGet one_cluster_name) #clst_name=$(CreoleGet one_cluster_name)
manage_cluster ${clst_name} #manage_cluster ${clst_name}
# #
# Creating Host # Creating Host
@ -439,7 +454,7 @@ function main()
# #
# Attaching Host to the Cluster # Attaching Host to the Cluster
# #
attach_host ${host} ${clst_name} attach_host ${host} "default"
# #
# Création des Datastores # Création des Datastores

View File

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

View File

@ -24,7 +24,9 @@ function copy_ssh_id()
# #
function register_node() function register_node()
{ {
cmd="onehost create -i kvm -v kvm -n ovswitch -c \"$(CreoleGet one_cluster_name)\" ${1}" # 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}"
ret=$(su - ${ONEUSER} -c -- "${cmd}") ret=$(su - ${ONEUSER} -c -- "${cmd}")
return $? return $?
} }