blob: 182e398caa1e8362eb1141df5c76519b74aa076b [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
31YAML_FILE=${LAB_DIR}/target/onap_openstack.yaml
32ENV_FILE=${LAB_DIR}/target/onap_openstack.env
Gary Wu4e980132018-05-17 15:38:07 -070033YAML_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.yaml
34ENV_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.env
Gary Wud83efff2018-01-09 16:47:30 -080035
36# copy heat template to WORKSPACE
Gary Wub57cc8f2018-01-12 01:17:32 -080037cp ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080038
39# generate final env file
Gary Wu4e980132018-05-17 15:38:07 -070040pushd ${DEMO_DIR}
Gary Wuf8233432018-01-05 13:16:26 -080041envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080042echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080043echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
44popd
Gary Wub57cc8f2018-01-12 01:17:32 -080045sed "1,/${SENTINEL}/d" ${ENV_SRC} >> ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080046cat ${ENV_FILE}
47
Gary Wua254fab2018-04-03 07:52:28 -070048diff ${ENV_SRC} ${ENV_FILE}
Gary Wub57cc8f2018-01-12 01:17:32 -080049
Gary Wud83efff2018-01-09 16:47:30 -080050# generate final heat template
51# add apt proxy to heat template if applicable
52if [ -x $LAB_DIR/apt-proxy.sh ]; then
53 $LAB_DIR/apt-proxy.sh ${YAML_FILE}
Gary Wua254fab2018-04-03 07:52:28 -070054 diff ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080055fi
56
57
58#exit 0
59
Gary Wuf8233432018-01-05 13:16:26 -080060#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070061
Gary Wud83efff2018-01-09 16:47:30 -080062
63# tear down old deployment
64$WORKSPACE/test/ete/scripts/teardown-onap.sh
65
66# create new stack
67STACK="ete-$(uuidgen | cut -c-8)"
68echo "New Stack Name: ${STACK}"
Gary Wua254fab2018-04-03 07:52:28 -070069if ! openstack stack create -t ${YAML_FILE} -e ${ENV_FILE} $STACK; then
70 exit 1
71fi
Gary Wu874794d2017-10-13 12:27:39 -070072
Gary Wuf5fef8b2017-11-09 10:59:46 -080073while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080074 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080075done
76
77STATUS=$(openstack stack show -c stack_status -f value $STACK)
78echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080079if [ "CREATE_COMPLETE" != "$STATUS" ]; then
80 exit 1
81fi
82
83
84# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080085ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080086echo "ROBOT_IP=${ROBOT_IP}"
87
88if [ "" == "${ROBOT_IP}" ]; then
89 exit 1
90fi
91
92ssh-keygen -R ${ROBOT_IP}
93
94SSH_KEY=~/.ssh/onap_key
95
Gary Wu3e4eede2018-04-17 17:33:07 -070096for n in $(seq 1 10); do
97 ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} "sudo docker ps" | grep openecompete_container
98 RESULT=$?
99 if [ $RESULT -eq 0 ]; then
100 break
101 fi
102 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -0800103done