blob: 571b380d1dfbd0117171e46f9f0218fb74a71bcf [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 Wub84428e2017-10-30 11:09:27 -070021
Gary Wu3cad6f32017-11-15 23:29:11 -080022SENTINEL='Docker versions and branches'
Gary Wud83efff2018-01-09 16:47:30 -080023
24YAML_FILE=${LAB_DIR}/onap_openstack.yaml
Gary Wuf8233432018-01-05 13:16:26 -080025ENV_FILE=${LAB_DIR}/onap-openstack.env
Gary Wud83efff2018-01-09 16:47:30 -080026
27# copy heat template to WORKSPACE
28cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml ${YAML_FILE}
29
30# generate final env file
31pushd ${ONAP_WORKDIR}/demo
Gary Wuf8233432018-01-05 13:16:26 -080032cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${LAB_DIR}/onap-openstack-demo.env
33envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080034echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080035echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
36popd
37sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE}
38cat ${ENV_FILE}
39
Gary Wud83efff2018-01-09 16:47:30 -080040# generate final heat template
41# add apt proxy to heat template if applicable
42if [ -x $LAB_DIR/apt-proxy.sh ]; then
43 $LAB_DIR/apt-proxy.sh ${YAML_FILE}
44 diff ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml ${YAML_FILE}
45fi
46
47
48#exit 0
49
Gary Wuf8233432018-01-05 13:16:26 -080050#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070051
Gary Wud83efff2018-01-09 16:47:30 -080052
53# tear down old deployment
54$WORKSPACE/test/ete/scripts/teardown-onap.sh
55
56# create new stack
57STACK="ete-$(uuidgen | cut -c-8)"
58echo "New Stack Name: ${STACK}"
Gary Wuf8233432018-01-05 13:16:26 -080059openstack stack create -t ${YAML_FILE} -e ${LAB_DIR}/onap-openstack.env $STACK
Gary Wu874794d2017-10-13 12:27:39 -070060
Gary Wuf5fef8b2017-11-09 10:59:46 -080061while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080062 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080063done
64
65STATUS=$(openstack stack show -c stack_status -f value $STACK)
66echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080067if [ "CREATE_COMPLETE" != "$STATUS" ]; then
68 exit 1
69fi
70
71
72# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080073ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080074echo "ROBOT_IP=${ROBOT_IP}"
75
76if [ "" == "${ROBOT_IP}" ]; then
77 exit 1
78fi
79
80ssh-keygen -R ${ROBOT_IP}
81
82SSH_KEY=~/.ssh/onap_key
83
84until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container"
85do
Gary Wu3cad6f32017-11-15 23:29:11 -080086 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -080087done