5 PWD_FILENAME="passwords.sh"
10 function exit_on_error {
13 if [ $RES != 0 ]; then
21 ## Create LAB_CONFIG folder if not exists
26 ## Override default passwords with local settings if needed
29 if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then
30 echo "------ Load local passwords ------"
31 source $LAB_CONFIG/$PWD_FILENAME
33 export MAAS_USER=ubuntu
34 export MAAS_PASSWORD=ubuntu
35 export OS_ADMIN_PASSWORD=openstack
39 ## Set Joid pod config name
41 # This part will be removed when pod names will be synced between jenkins and joid config
50 export POD_NAME=${POD/-}
53 ## Parse Network config
56 EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-}
57 # split EXTERNAL_NETWORK=name;type;first ip;last ip; gateway;network
58 IFS=';' read -r -a EXTNET <<< "$EXTERNAL_NETWORK"
59 EXTNET_NAME=${EXTNET[0]}
60 EXTNET_TYPE=${EXTNET[1]}
61 EXTNET_FIP=${EXTNET[2]}
62 EXTNET_LIP=${EXTNET[3]}
63 EXTNET_GW=${EXTNET[4]}
64 EXTNET_NET=${EXTNET[5]}
67 ## Redeploy MAAS or recover the previous config
71 if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
72 echo "------ Recover Juju environment to use MAAS ------"
73 cp $LAB_CONFIG/environments.yaml .
75 MAASCONFIG=$WORKSPACE/ci/maas/${POD/-*}/${POD/*-}/deployment.yaml
76 echo "------ Set MAAS password ------"
77 sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG
78 sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG
79 echo "------ Redeploy MAAS ------"
80 ./02-maasdeploy.sh $POD_NAME
81 exit_on_error $? "MAAS Deploy FAILED"
85 ## Configure Joid deployment
88 # Based on scenario naming we can get joid options
90 # os-<controller>-<nfvfeature>-<mode>[-<extrastuff>]
92 # controller=(nosdn|odl_l3|odl_l2|onos|ocl)
94 # nfvfeature=(kvm|ovs|dpdk|nofeature)
98 # Optional field - Not used today
100 IFS='-' read -r -a DEPLOY_OPTIONS <<< "${DEPLOY_SCENARIO}--"
101 #last -- need to avoid nounset error
103 SDN_CONTROLLER=${DEPLOY_OPTIONS[1]}
104 NFV_FEATURES=${DEPLOY_OPTIONS[2]}
105 HA_MODE=${DEPLOY_OPTIONS[3]}
106 EXTRA=${DEPLOY_OPTIONS[4]}
108 if [ "$SDN_CONTROLLER" == 'odl_l2' ] || [ "$SDN_CONTROLLER" == 'odl_l3' ]; then
111 if [ "$HA_MODE" == 'noha' ]; then
114 SRCBUNDLE="${WORKSPACE}/ci/${SDN_CONTROLLER}/juju-deployer/"
115 SRCBUNDLE="${SRCBUNDLE}/ovs-${SDN_CONTROLLER}-${HA_MODE}.yaml"
119 echo "------ Set openstack password ------"
120 sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE
122 if [ -n "$EXTNET_NAME" ]; then
123 echo "------ Set openstack default network ------"
124 sed -i -- "s/\"neutron-external-network\": ext_net/\"neutron-external-network\": $EXTNET_NAME/" $SRCBUNDLE
127 echo "------ Set ceph disks ------"
128 CEPH_DISKS_CONTROLLERS=${CEPH_DISKS_CONTROLLERS:-}
129 if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then
130 CEPH_DISKS_CONTROLLERS=$CEPH_DISKS
133 #Find the first line of osd-devices to change the one for ceph, then the other for ceph-osd
134 CEPH_DEV_LINE=$(grep -nr osd-devices $SRCBUNDLE |head -n1|cut -d: -f1)
135 sed -i -- "${CEPH_DEV_LINE}s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
136 sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS_CONTROLLERS@" $SRCBUNDLE
137 sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
140 ## Configure Joid deployment
143 echo "------ Deploy with juju ------"
144 echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME"
146 ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME
147 exit_on_error $? "Main deploy FAILED"
152 JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
153 echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
154 KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase2.services.keystone.options.vip)
156 # export the openrc file
157 cat << EOF > $JOID_ADMIN_OPENRC
158 export OS_USERNAME=admin
159 export OS_PASSWORD=$OS_ADMIN_PASSWORD
160 export OS_TENANT_NAME=admin
161 export OS_AUTH_URL=http://$KEYSTONE:5000/v2.0
162 export OS_REGION_NAME=Canonical
166 ## Backup local juju env
169 echo "------ Backup Juju environment ------"
170 cp environments.yaml $LAB_CONFIG/
173 ## Basic test to return a realistic result to jenkins
176 echo "------ Do basic test ------"
177 source $JOID_ADMIN_OPENRC
178 curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
181 \"methods\": [\"password\"],
185 \"domain\": { \"id\": \"default\" },
186 \"password\": \"$OS_ADMIN_PASSWORD\"
191 }" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null;
192 exit_on_error $? "Deploy FAILED to auth to openstack"
196 ## Create external network if needed
199 # If we have more information than only the name, try to create it
200 if [ -z "$EXTNET_TYPE" ]; then
201 echo "------ No data for external network creation, pass ------"
202 elif [[ "$DEPLOY_SCENARIO" =~ "onos" ]]; then
203 echo "------ ONOS have created the external network, pass ------"
205 echo "------ External network creation ------"
206 neutron net-create $EXTNET_NAME --router:external True \
207 --provider:physical_network external --provider:network_type $EXTNET_TYPE
208 exit_on_error $? "External network creation failed"
209 neutron subnet-create $EXTNET_NAME --name $EXTNET_NAME \
210 --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \
211 --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET
212 exit_on_error $? "External subnet creation failed"
213 neutron net-update $EXTNET_NAME --shared
214 exit_on_error $? "External network sharing failed"
221 echo "Deploy success"