blob: 2fd05562a725c9166c20d48519aa2d5d7592c40a [file] [log] [blame]
Gary Wuf5fef8b2017-11-09 10:59:46 -08001#!/bin/bash -x
Gary Wu874794d2017-10-13 12:27:39 -07002
Gary Wu4e980132018-05-17 15:38:07 -07003if [ "$#" -lt 1 ]; then
4 echo "Usage: $0 <lab-name> [<demo repo directory>]"
Gary Wuf8233432018-01-05 13:16:26 -08005 exit 1
6fi
7
Gary Wu4e980132018-05-17 15:38:07 -07008
Gary Wu874794d2017-10-13 12:27:39 -07009if [ -z "$WORKSPACE" ]; then
10 export WORKSPACE=`git rev-parse --show-toplevel`
11fi
12
Gary Wuf8233432018-01-05 13:16:26 -080013LAB_DIR=${WORKSPACE}/test/ete/labs/$1
14
15if [ ! -d "$LAB_DIR" ]; then
16 echo "Directory $LAB_DIR not found"
17 exit 2
18fi
19
Gary Wu838c34d2017-10-23 14:22:40 -070020source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
Gary Wu874794d2017-10-13 12:27:39 -070021
Gary Wub84428e2017-10-30 11:09:27 -070022
Gary Wu4e980132018-05-17 15:38:07 -070023DEMO_DIR=${ONAP_WORKDIR}/demo
24if [ "$#" -ge 2 ]; then
25 DEMO_DIR=$2
26fi
27
Gary Wu3cad6f32017-11-15 23:29:11 -080028SENTINEL='Docker versions and branches'
Gary Wud83efff2018-01-09 16:47:30 -080029
Gary Wub57cc8f2018-01-12 01:17:32 -080030mkdir -p ${LAB_DIR}/target
Gary Wu2845d142018-08-01 12:02:37 -070031rsync -avt $DEMO_DIR/heat/ONAP/ ${LAB_DIR}/target/
Gary Wub57cc8f2018-01-12 01:17:32 -080032YAML_FILE=${LAB_DIR}/target/onap_openstack.yaml
33ENV_FILE=${LAB_DIR}/target/onap_openstack.env
Gary Wu4e980132018-05-17 15:38:07 -070034YAML_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.yaml
35ENV_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.env
Gary Wud83efff2018-01-09 16:47:30 -080036
37# copy heat template to WORKSPACE
Gary Wub57cc8f2018-01-12 01:17:32 -080038cp ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080039
40# generate final env file
Gary Wu4e980132018-05-17 15:38:07 -070041pushd ${DEMO_DIR}
Gary Wuf8233432018-01-05 13:16:26 -080042envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080043echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080044echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
45popd
Gary Wub57cc8f2018-01-12 01:17:32 -080046sed "1,/${SENTINEL}/d" ${ENV_SRC} >> ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080047cat ${ENV_FILE}
48
Gary Wua254fab2018-04-03 07:52:28 -070049diff ${ENV_SRC} ${ENV_FILE}
Gary Wub57cc8f2018-01-12 01:17:32 -080050
Gary Wud83efff2018-01-09 16:47:30 -080051# generate final heat template
52# add apt proxy to heat template if applicable
53if [ -x $LAB_DIR/apt-proxy.sh ]; then
54 $LAB_DIR/apt-proxy.sh ${YAML_FILE}
Gary Wua254fab2018-04-03 07:52:28 -070055 diff ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080056fi
57
58
59#exit 0
60
Gary Wuf8233432018-01-05 13:16:26 -080061#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070062
Gary Wud83efff2018-01-09 16:47:30 -080063
64# tear down old deployment
Gary Wuf88c6302018-08-08 12:55:58 -070065$WORKSPACE/test/ete/scripts/teardown-onap.sh -q
Gary Wud83efff2018-01-09 16:47:30 -080066
67# create new stack
Gary Wucbb3d882018-08-01 07:50:30 -070068STACK="onap-heat-$(uuidgen | cut -c-4)"
Gary Wud83efff2018-01-09 16:47:30 -080069echo "New Stack Name: ${STACK}"
Gary Wua254fab2018-04-03 07:52:28 -070070if ! openstack stack create -t ${YAML_FILE} -e ${ENV_FILE} $STACK; then
71 exit 1
72fi
Gary Wu874794d2017-10-13 12:27:39 -070073
Gary Wuf5fef8b2017-11-09 10:59:46 -080074while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080075 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080076done
77
78STATUS=$(openstack stack show -c stack_status -f value $STACK)
79echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080080if [ "CREATE_COMPLETE" != "$STATUS" ]; then
81 exit 1
82fi
83
84
85# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080086ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080087echo "ROBOT_IP=${ROBOT_IP}"
88
89if [ "" == "${ROBOT_IP}" ]; then
90 exit 1
91fi
92
93ssh-keygen -R ${ROBOT_IP}
94
95SSH_KEY=~/.ssh/onap_key
96
Gary Wu3e4eede2018-04-17 17:33:07 -070097for n in $(seq 1 10); do
98 ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} "sudo docker ps" | grep openecompete_container
99 RESULT=$?
100 if [ $RESULT -eq 0 ]; then
101 break
102 fi
103 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -0800104done