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 ##############################################################################
13 PWD_FILENAME="passwords.sh"
18 function exit_on_error {
21 if [ $RES != 0 ]; then
29 ## Create LAB_CONFIG folder if not exists
34 ## Override default passwords with local settings if needed
37 if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then
38 echo "------ Load local passwords ------"
39 source $LAB_CONFIG/$PWD_FILENAME
41 export MAAS_USER=ubuntu
42 export MAAS_PASSWORD=ubuntu
43 export OS_ADMIN_PASSWORD=openstack
47 ## Set Joid pod config name
49 # This part will be removed when pod names will be synced between jenkins and joid config
56 export POD_NAME=${POD/-}
59 ## Parse Network config
62 EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-}
63 # split EXTERNAL_NETWORK=name;type;first ip;last ip; gateway;network
64 IFS=';' read -r -a EXTNET <<< "$EXTERNAL_NETWORK"
65 EXTNET_NAME=${EXTNET[0]}
66 EXTNET_TYPE=${EXTNET[1]}
67 EXTNET_FIP=${EXTNET[2]}
68 EXTNET_LIP=${EXTNET[3]}
69 EXTNET_GW=${EXTNET[4]}
70 EXTNET_NET=${EXTNET[5]}
73 ## Redeploy MAAS or recover the previous config
77 if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then
78 echo "------ Recover Juju environment to use MAAS ------"
79 cp $LAB_CONFIG/environments.yaml .
81 MAASCONFIG=$WORKSPACE/ci/maas/${POD/-*}/${POD/*-}/deployment.yaml
82 echo "------ Set MAAS password ------"
83 sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG
84 sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG
85 echo "------ Redeploy MAAS ------"
86 ./02-maasdeploy.sh $POD_NAME
87 exit_on_error $? "MAAS Deploy FAILED"
91 ## Configure Joid deployment
94 # Based on scenario naming we can get joid options
96 # os-<controller>-<nfvfeature>-<mode>[-<extrastuff>]
98 # controller=(nosdn|odl_l3|odl_l2|onos|ocl)
100 # nfvfeature=(kvm|ovs|dpdk|nofeature)
101 # '_' list separated.
104 # Optional field - Not used today
106 IFS='-' read -r -a DEPLOY_OPTIONS <<< "${DEPLOY_SCENARIO}--"
107 #last -- need to avoid nounset error
109 SDN_CONTROLLER=${DEPLOY_OPTIONS[1]}
110 NFV_FEATURES=${DEPLOY_OPTIONS[2]}
111 HA_MODE=${DEPLOY_OPTIONS[3]}
112 EXTRA=${DEPLOY_OPTIONS[4]}
114 if [ "$SDN_CONTROLLER" == 'odl_l2' ] || [ "$SDN_CONTROLLER" == 'odl_l3' ]; then
117 if [ "$HA_MODE" == 'noha' ]; then
120 SRCBUNDLE="${WORKSPACE}/ci/${SDN_CONTROLLER}/juju-deployer/"
121 SRCBUNDLE="${SRCBUNDLE}/ovs-${SDN_CONTROLLER}-${HA_MODE}.yaml"
125 echo "------ Set openstack password ------"
126 sed -i -- "s/admin-password: openstack/admin-password: $OS_ADMIN_PASSWORD/" $SRCBUNDLE
128 if [ -n "$EXTNET_NAME" ]; then
129 echo "------ Set openstack default network ------"
130 sed -i -- "s/neutron-external-network: ext_net/neutron-external-network: $EXTNET_NAME/" $SRCBUNDLE
133 echo "------ Set ceph disks ------"
134 #Find the first line of osd-devices to change the one for ceph, then the other for ceph-osd
135 sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE
136 sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE
139 ## Configure Joid deployment
142 echo "------ Deploy with juju ------"
143 echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES"
145 ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES
146 exit_on_error $? "Main deploy FAILED"
151 JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc
152 echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------"
157 KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase1.services.keystone.options.vip)
160 KEYSTONE=$(juju status keystone |grep public-address|sed -- 's/.*\: //')
166 case "$SDN_CONTROLLER" in
168 SDN_CONTROLLER_IP=$(juju status odl-controller/0 |grep public-address|sed -- 's/.*\: //')
171 SDN_CONTROLLER_IP=$(juju status onos-controller/0 |grep public-address|sed -- 's/.*\: //')
174 SDN_CONTROLLER_IP='none'
179 # export the openrc file
180 cat << EOF > $JOID_ADMIN_OPENRC
181 export OS_USERNAME=admin
182 export OS_PASSWORD=$OS_ADMIN_PASSWORD
183 export OS_TENANT_NAME=admin
184 export OS_AUTH_URL=http://$KEYSTONE:35357/v2.0
185 export OS_REGION_NAME=Canonical
186 export OS_ENDPOINT_TYPE='adminURL'
187 export CINDER_ENDPOINT_TYPE='adminURL'
188 export GLANCE_ENDPOINT_TYPE='adminURL'
189 export KEYSTONE_ENDPOINT_TYPE='adminURL'
190 export NEUTRON_ENDPOINT_TYPE='adminURL'
191 export NOVA_ENDPOINT_TYPE='adminURL'
192 export SDN_CONTROLLER=$SDN_CONTROLLER_IP
193 export SDN_PASSWORD=$SDN_PASSWORD
194 export OS_INTERFACE=admin
198 ## Backup local juju env
201 echo "------ Backup Juju environment ------"
202 cp environments.yaml $LAB_CONFIG/
205 ## Basic test to return a realistic result to jenkins
208 echo "------ Do basic test ------"
209 source $JOID_ADMIN_OPENRC
210 curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d "
213 \"methods\": [\"password\"],
217 \"domain\": { \"id\": \"default\" },
218 \"password\": \"$OS_ADMIN_PASSWORD\"
223 }" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null;
224 exit_on_error $? "Deploy FAILED to auth to openstack"
230 echo "Deploy success"