blob: b580351ddf06620c3cbe2fee6a208053dc947c00 [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
Gary Wub57cc8f2018-01-12 01:17:32 -080024mkdir -p ${LAB_DIR}/target
25YAML_FILE=${LAB_DIR}/target/onap_openstack.yaml
26ENV_FILE=${LAB_DIR}/target/onap_openstack.env
27YAML_SRC=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml
28ENV_SRC=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env
Gary Wud83efff2018-01-09 16:47:30 -080029
30# copy heat template to WORKSPACE
Gary Wub57cc8f2018-01-12 01:17:32 -080031cp ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080032
33# generate final env file
34pushd ${ONAP_WORKDIR}/demo
Gary Wuf8233432018-01-05 13:16:26 -080035envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080036echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080037echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
38popd
Gary Wub57cc8f2018-01-12 01:17:32 -080039sed "1,/${SENTINEL}/d" ${ENV_SRC} >> ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080040cat ${ENV_FILE}
41
Gary Wua254fab2018-04-03 07:52:28 -070042diff ${ENV_SRC} ${ENV_FILE}
Gary Wub57cc8f2018-01-12 01:17:32 -080043
Gary Wud83efff2018-01-09 16:47:30 -080044# generate final heat template
45# add apt proxy to heat template if applicable
46if [ -x $LAB_DIR/apt-proxy.sh ]; then
47 $LAB_DIR/apt-proxy.sh ${YAML_FILE}
Gary Wua254fab2018-04-03 07:52:28 -070048 diff ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080049fi
50
51
52#exit 0
53
Gary Wuf8233432018-01-05 13:16:26 -080054#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070055
Gary Wud83efff2018-01-09 16:47:30 -080056
57# tear down old deployment
58$WORKSPACE/test/ete/scripts/teardown-onap.sh
59
60# create new stack
61STACK="ete-$(uuidgen | cut -c-8)"
62echo "New Stack Name: ${STACK}"
Gary Wua254fab2018-04-03 07:52:28 -070063if ! openstack stack create -t ${YAML_FILE} -e ${ENV_FILE} $STACK; then
64 exit 1
65fi
Gary Wu874794d2017-10-13 12:27:39 -070066
Gary Wuf5fef8b2017-11-09 10:59:46 -080067while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080068 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080069done
70
71STATUS=$(openstack stack show -c stack_status -f value $STACK)
72echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080073if [ "CREATE_COMPLETE" != "$STATUS" ]; then
74 exit 1
75fi
76
77
78# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080079ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080080echo "ROBOT_IP=${ROBOT_IP}"
81
82if [ "" == "${ROBOT_IP}" ]; then
83 exit 1
84fi
85
86ssh-keygen -R ${ROBOT_IP}
87
88SSH_KEY=~/.ssh/onap_key
89
Gary Wu3e4eede2018-04-17 17:33:07 -070090for n in $(seq 1 10); do
91 ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} "sudo docker ps" | grep openecompete_container
92 RESULT=$?
93 if [ $RESULT -eq 0 ]; then
94 break
95 fi
96 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -080097done