2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
16 function exit_on_error {
19 if [ $RES != 0 ]; then
26 ## Create LAB_CONFIG folder if not exists
32 ## Set Joid pod config name
41 export POD_NAME=${POD/-}
44 ## Redeploy MAAS or recover the previous config
49 if [ -e "$LAB_CONFIG/deployconfig.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
50 echo "------ Recover Juju environment to use MAAS ------"
51 if [ ! -e deployconfig.yaml ]; then
52 cp $LAB_CONFIG/deployconfig.yaml .
53 cp $LAB_CONFIG/deployment.yaml .
54 cp $LAB_CONFIG/labconfig.yaml .
57 if ["$NODE_NAME" == "default" ]; then
58 echo "------ Redeploy MAAS ------"
59 ./03-maasdeploy.sh default
60 exit_on_error $? "MAAS Deploy FAILED"
62 echo "------ Redeploy MAAS ------"
63 ./03-maasdeploy.sh custom $LAB_CONFIG/labconfig.yaml
64 exit_on_error $? "MAAS Deploy FAILED"
69 ## Configure Joid deployment
72 # Based on scenario naming we can get joid options
74 # <model>-<controller>-<nfvfeature>-<mode>[-<extrastuff>]
77 # controller=(nosdn|odl_l3|odl_l2|onos|ocl)
79 # nfvfeature=(kvm|ovs|dpdk|nofeature)
83 # Optional field - Not used today
85 IFS='-' read -r -a DEPLOY_OPTIONS <<< "${DEPLOY_SCENARIO}--"
86 #last -- need to avoid nounset error
88 JOID_MODEL=${DEPLOY_OPTIONS[0]}
89 SDN_CONTROLLER=${DEPLOY_OPTIONS[1]}
90 NFV_FEATURES=${DEPLOY_OPTIONS[2]}
91 HA_MODE=${DEPLOY_OPTIONS[3]}
92 EXTRA=${DEPLOY_OPTIONS[4]}
94 if [ "$SDN_CONTROLLER" == 'odl_l2' ] || [ "$SDN_CONTROLLER" == 'odl_l3' ]; then
98 # Add extra to features
99 if [ "$EXTRA" != "" ];then
100 NFV_FEATURES="${NFV_FEATURES}_${EXTRA}"
103 # temporary sfc feature is availble only on onos and trusty
104 if [ "$NFV_FEATURES" == 'sfc' ] && [ "$SDN_CONTROLLER" == 'onos' ];then
109 ## Configure Joid deployment
112 if [ "$JOID_MODEL" == 'k8' ]; then
113 echo "------ Deploy with juju ------"
114 echo "Execute: ./deploy.sh -m $JOID_MODEL -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES"
116 ./deploy.sh -m kubernetes -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES
117 exit_on_error $? "Main deploy FAILED"
123 if [ "$JOID_MODEL" == 'os' ]; then
124 echo "------ Deploy with juju ------"
125 echo "Execute: ./deploy.sh -m $JOID_MODEL -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES"
127 ./deploy.sh -m openstack -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES
128 exit_on_error $? "Main deploy FAILED"
130 JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
131 echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
134 case "$SDN_CONTROLLER" in
136 SDN_CONTROLLER_IP=$(juju status odl-controller/0 |grep public-address|sed -- 's/.*\: //')
139 SDN_CONTROLLER_IP=$(juju status onos-controller/0 |grep public-address|sed -- 's/.*\: //')
142 SDN_CONTROLLER_IP='none'
147 # export the openrc file by getting the one generated by joid and add SDN
148 # controller for Functest
149 # cp ./cloud/admin-openrc $JOID_ADMIN_OPENRC
150 echo export SDN_CONTROLLER=$SDN_CONTROLLER_IP >> $JOID_ADMIN_OPENRC
151 echo export SDN_PASSWORD=$SDN_PASSWORD >> $JOID_ADMIN_OPENRC
159 echo "Deploy success"