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
48 if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
49 echo "------ Recover Juju environment to use MAAS ------"
50 cp $LAB_CONFIG/environments.yaml .
51 cp $LAB_CONFIG/deployment.yaml .
52 if [ -e $LAB_CONFIG/deployconfig.yaml ]; then
53 cp $LAB_CONFIG/deployconfig.yaml .
56 echo "------ Redeploy MAAS ------"
57 ./00-maasdeploy.sh $POD_NAME
58 exit_on_error $? "MAAS Deploy FAILED"
62 ## Configure Joid deployment
65 # Based on scenario naming we can get joid options
67 # os-<controller>-<nfvfeature>-<mode>[-<extrastuff>]
69 # controller=(nosdn|odl_l3|odl_l2|onos|ocl)
71 # nfvfeature=(kvm|ovs|dpdk|nofeature)
75 # Optional field - Not used today
77 IFS='-' read -r -a DEPLOY_OPTIONS <<< "${DEPLOY_SCENARIO}--"
78 #last -- need to avoid nounset error
80 SDN_CONTROLLER=${DEPLOY_OPTIONS[1]}
81 NFV_FEATURES=${DEPLOY_OPTIONS[2]}
82 HA_MODE=${DEPLOY_OPTIONS[3]}
83 EXTRA=${DEPLOY_OPTIONS[4]}
85 if [ "$SDN_CONTROLLER" == 'odl_l2' ] || [ "$SDN_CONTROLLER" == 'odl_l3' ]; then
88 if [ "$HA_MODE" == 'noha' ]; then
92 # Add extra to features
93 if [ "$EXTRA" != "" ];then
94 NFV_FEATURES="${NFV_FEATURES}_${EXTRA}"
97 # temporary sfc feature is availble only on onos and trusty
98 if [ "$NFV_FEATURES" == 'sfc' ] && [ "$SDN_CONTROLLER" == 'onos' ];then
103 ## Configure Joid deployment
106 echo "------ Deploy with juju ------"
107 echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES"
109 ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES
110 exit_on_error $? "Main deploy FAILED"
115 JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
116 echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
119 case "$SDN_CONTROLLER" in
121 SDN_CONTROLLER_IP=$(juju status odl-controller/0 |grep public-address|sed -- 's/.*\: //')
124 SDN_CONTROLLER_IP=$(juju status onos-controller/0 |grep public-address|sed -- 's/.*\: //')
127 SDN_CONTROLLER_IP='none'
132 # export the openrc file by getting the one generated by joid and add SDN
133 # controller for Functest
134 cp ./cloud/admin-openrc $JOID_ADMIN_OPENRC
135 cat << EOF >> $JOID_ADMIN_OPENRC
136 export SDN_CONTROLLER=$SDN_CONTROLLER_IP
137 export SDN_PASSWORD=$SDN_PASSWORD
141 ## Backup local juju env
144 echo "------ Backup Juju environment ------"
145 cp environments.yaml $LAB_CONFIG/
146 cp deployment.yaml $LAB_CONFIG/
147 if [ -e deployconfig.yaml ]; then
148 cp deployconfig.yaml $LAB_CONFIG
155 echo "Deploy success"