blob: c87f9a94e5688ae5a20dd0a8783b6a9535c84973 [file] [log] [blame]
Gary Wuf5fef8b2017-11-09 10:59:46 -08001#!/bin/bash -x
Gary Wu874794d2017-10-13 12:27:39 -07002
Gary Wuf8233432018-01-05 13:16:26 -08003if [ "$#" -ne 1 ]; then
4 echo "Usage: $0 <lab-name>"
5 exit 1
6fi
7
Gary Wu874794d2017-10-13 12:27:39 -07008if [ -z "$WORKSPACE" ]; then
9 export WORKSPACE=`git rev-parse --show-toplevel`
10fi
11
Gary Wuf8233432018-01-05 13:16:26 -080012LAB_DIR=${WORKSPACE}/test/ete/labs/$1
13
14if [ ! -d "$LAB_DIR" ]; then
15 echo "Directory $LAB_DIR not found"
16 exit 2
17fi
18
Gary Wu838c34d2017-10-23 14:22:40 -070019source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
Gary Wu874794d2017-10-13 12:27:39 -070020
Gary Wucc10f1c2018-01-03 11:19:28 -080021$WORKSPACE/test/ete/scripts/teardown-onap.sh
Gary Wuf5fef8b2017-11-09 10:59:46 -080022
Gary Wu874794d2017-10-13 12:27:39 -070023STACK="ete-$(uuidgen | cut -c-8)"
Gary Wu99a7c1a2017-10-23 13:12:06 -070024echo "New Stack Name: ${STACK}"
Gary Wub84428e2017-10-30 11:09:27 -070025
26
Gary Wu3cad6f32017-11-15 23:29:11 -080027SENTINEL='Docker versions and branches'
Gary Wu2c43ba52017-11-21 11:33:12 -080028YAML_FILE=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml
Gary Wuf8233432018-01-05 13:16:26 -080029ENV_FILE=${LAB_DIR}/onap-openstack.env
30cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${LAB_DIR}/onap-openstack-demo.env
31envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080032pushd ${ONAP_WORKDIR}/demo
33echo " # Rest of the file was AUTO-GENERATED from"
34echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
35popd
36sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE}
37cat ${ENV_FILE}
38
Gary Wuf8233432018-01-05 13:16:26 -080039#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070040
Gary Wuf8233432018-01-05 13:16:26 -080041openstack stack create -t ${YAML_FILE} -e ${LAB_DIR}/onap-openstack.env $STACK
Gary Wu874794d2017-10-13 12:27:39 -070042
Gary Wuf5fef8b2017-11-09 10:59:46 -080043while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080044 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080045done
46
47STATUS=$(openstack stack show -c stack_status -f value $STACK)
48echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080049if [ "CREATE_COMPLETE" != "$STATUS" ]; then
50 exit 1
51fi
52
53
54# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080055ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080056echo "ROBOT_IP=${ROBOT_IP}"
57
58if [ "" == "${ROBOT_IP}" ]; then
59 exit 1
60fi
61
62ssh-keygen -R ${ROBOT_IP}
63
64SSH_KEY=~/.ssh/onap_key
65
66until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container"
67do
Gary Wu3cad6f32017-11-15 23:29:11 -080068 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -080069done