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:
parent
051136ac81
commit
1a911bd9fc
@ -24,9 +24,6 @@
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
<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='vnet_network_addr' type='ip' description='Adresse du réseau'/>
|
||||
<variable name='vnet_network_mask' type='netmask' description='Masque du réseau'/>
|
||||
@ -114,10 +111,6 @@
|
||||
<param>openvswitch</param>
|
||||
<param type="eole" name="condition_1">vnet_pilote</param>
|
||||
</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'>
|
||||
<param>['qxl','vga','std','cirrus']</param>
|
||||
@ -127,7 +120,6 @@
|
||||
<condition name='disabled_if_in' source='activer_onesinglenode'>
|
||||
<param>non</param>
|
||||
<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_iso_name</target>
|
||||
<target type='variable'>one_ds_image_name</target>
|
||||
|
@ -21,42 +21,44 @@ function get_one_auth()
|
||||
${CMD} ${FILE}
|
||||
}
|
||||
|
||||
function check_cluster()
|
||||
{
|
||||
name="${1}"
|
||||
cmd="onecluster"
|
||||
opt="list"
|
||||
auth=$(get_one_auth)
|
||||
# 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}
|
||||
#}
|
||||
|
||||
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 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
|
||||
}
|
||||
# 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
|
||||
#}
|
||||
|
||||
function check_host()
|
||||
{
|
||||
@ -190,7 +192,9 @@ function attach_host()
|
||||
{
|
||||
HOST=${1}
|
||||
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})
|
||||
AUTH=$(get_one_auth)
|
||||
CMD="onecluster"
|
||||
@ -226,32 +230,34 @@ function attach_host()
|
||||
#
|
||||
# Attach a datastore to a cluster
|
||||
#
|
||||
function attach_ds_to_cluster()
|
||||
{
|
||||
DS=${1}
|
||||
CLST=${2}
|
||||
CLST_ID=$(get_cluster_id_by_name ${CLST})
|
||||
DS_ID=$(get_ds_id_by_name ${ds_name})
|
||||
AUTH=$(get_one_auth)
|
||||
CMD="onecluster"
|
||||
OPT="adddatastore ${CLST_ID} ${DS_ID}"
|
||||
|
||||
RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Attaching ${DS} to ${CLST} failed."
|
||||
else
|
||||
echo "Datastore ${DS} attached to ${CLST}."
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
# ref https://dev-eole.ac-dijon.fr/issues/16797
|
||||
#function attach_ds_to_cluster()
|
||||
#{
|
||||
# DS=${1}
|
||||
# CLST=${2}
|
||||
# CLST_ID=$(get_cluster_id_by_name ${CLST})
|
||||
# DS_ID=$(get_ds_id_by_name ${ds_name})
|
||||
# AUTH=$(get_one_auth)
|
||||
# CMD="onecluster"
|
||||
# OPT="adddatastore ${CLST_ID} ${DS_ID}"
|
||||
#
|
||||
# RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
|
||||
# if [[ ${?} -ne 0 ]]
|
||||
# then
|
||||
# error "Attaching ${DS} to ${CLST} failed."
|
||||
# else
|
||||
# echo "Datastore ${DS} attached to ${CLST}."
|
||||
# return 0
|
||||
# fi
|
||||
# return 0
|
||||
#}
|
||||
|
||||
function create_datastore()
|
||||
{
|
||||
ds_type="${1}"
|
||||
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' ]]
|
||||
then
|
||||
@ -297,12 +303,12 @@ __EOF__
|
||||
|
||||
auth=$(get_one_auth)
|
||||
cmd="onedatastore"
|
||||
#opt="create --user ${AUTH%:*} --password ${AUTH#*:} -c ${ds_cluster} ${TMPL_FILE}"
|
||||
opt="create --user ${AUTH%:*} --password ${AUTH#*:} ${TMPL_FILE}"
|
||||
RUN=$(${cmd} ${opt})
|
||||
if [[ ${?} -eq 0 ]]
|
||||
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}
|
||||
return 0
|
||||
else
|
||||
@ -385,10 +391,13 @@ __EOF__
|
||||
|
||||
function manage_datastores()
|
||||
{
|
||||
cluster=${1}
|
||||
# ref https://dev-eole.ac-dijon.fr/issues/16797
|
||||
#cluster=${1}
|
||||
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')
|
||||
IMAGE_DS=$(CreoleGet 'one_ds_image_name')
|
||||
|
||||
@ -396,7 +405,9 @@ function manage_datastores()
|
||||
sid=$(get_ds_id_by_name ${SYSTEM_DS})
|
||||
if [[ ${sid} = "ERR" ]]
|
||||
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
|
||||
update_datastore ${AUTH} ${sid}
|
||||
fi
|
||||
@ -404,7 +415,9 @@ function manage_datastores()
|
||||
imgid=$(get_ds_id_by_name ${IMAGE_DS})
|
||||
if [[ ${imgid} = "ERR" ]]
|
||||
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
|
||||
update_datastore ${AUTH} ${imgid}
|
||||
fi
|
||||
@ -412,7 +425,9 @@ function manage_datastores()
|
||||
isoid=$(get_ds_id_by_name ${ISO_DS})
|
||||
if [[ ${isoid} = "ERR" ]]
|
||||
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
|
||||
update_datastore ${AUTH} ${isoid}
|
||||
fi
|
||||
@ -423,9 +438,9 @@ function main()
|
||||
{
|
||||
#
|
||||
# Creating Cluster
|
||||
#
|
||||
clst_name=$(CreoleGet one_cluster_name)
|
||||
manage_cluster ${clst_name}
|
||||
# ref https://dev-eole.ac-dijon.fr/issues/16797
|
||||
#clst_name=$(CreoleGet one_cluster_name)
|
||||
#manage_cluster ${clst_name}
|
||||
|
||||
#
|
||||
# Creating Host
|
||||
@ -439,7 +454,7 @@ function main()
|
||||
#
|
||||
# Attaching Host to the Cluster
|
||||
#
|
||||
attach_host ${host} ${clst_name}
|
||||
attach_host ${host} "default"
|
||||
|
||||
#
|
||||
# Création des Datastores
|
||||
|
@ -289,7 +289,9 @@ def main():
|
||||
client = CreoleClient()
|
||||
one_client = OneClient('oneadmin')
|
||||
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')
|
||||
zones = client.get_creole('vnets')
|
||||
vlans = client.get_creole('vnet_vlan_tag')
|
||||
|
@ -24,7 +24,9 @@ function copy_ssh_id()
|
||||
#
|
||||
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}")
|
||||
return $?
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user