blob: 6c8d05d41d35fa32c20b19702edee524db1ecf38 [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 Wua4e1bb42018-09-05 13:15:52 -070022SO_ENCRYPTION_KEY=aa3871669d893c7fb8abbcda31b88b4f
23export OS_PASSWORD_ENCRYPTED=$(echo -n "$OS_PASSWORD" | openssl aes-128-ecb -e -K "$SO_ENCRYPTION_KEY" -nosalt | xxd -c 256 -p)
Gary Wub84428e2017-10-30 11:09:27 -070024
Gary Wu4e980132018-05-17 15:38:07 -070025DEMO_DIR=${ONAP_WORKDIR}/demo
26if [ "$#" -ge 2 ]; then
27 DEMO_DIR=$2
28fi
29
Gary Wu3cad6f32017-11-15 23:29:11 -080030SENTINEL='Docker versions and branches'
Gary Wud83efff2018-01-09 16:47:30 -080031
Gary Wub57cc8f2018-01-12 01:17:32 -080032mkdir -p ${LAB_DIR}/target
Gary Wu2845d142018-08-01 12:02:37 -070033rsync -avt $DEMO_DIR/heat/ONAP/ ${LAB_DIR}/target/
Gary Wub57cc8f2018-01-12 01:17:32 -080034YAML_FILE=${LAB_DIR}/target/onap_openstack.yaml
35ENV_FILE=${LAB_DIR}/target/onap_openstack.env
Gary Wu4e980132018-05-17 15:38:07 -070036YAML_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.yaml
37ENV_SRC=${DEMO_DIR}/heat/ONAP/onap_openstack.env
Gary Wud83efff2018-01-09 16:47:30 -080038
39# copy heat template to WORKSPACE
Gary Wub57cc8f2018-01-12 01:17:32 -080040cp ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080041
42# generate final env file
Gary Wu4e980132018-05-17 15:38:07 -070043pushd ${DEMO_DIR}
Gary Wuf8233432018-01-05 13:16:26 -080044envsubst < ${LAB_DIR}/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080045echo " # Rest of the file was AUTO-GENERATED from" | tee -a ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080046echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
47popd
Gary Wub57cc8f2018-01-12 01:17:32 -080048sed "1,/${SENTINEL}/d" ${ENV_SRC} >> ${ENV_FILE}
Gary Wu3cad6f32017-11-15 23:29:11 -080049cat ${ENV_FILE}
50
Gary Wua254fab2018-04-03 07:52:28 -070051diff ${ENV_SRC} ${ENV_FILE}
Gary Wub57cc8f2018-01-12 01:17:32 -080052
Gary Wud83efff2018-01-09 16:47:30 -080053# generate final heat template
54# add apt proxy to heat template if applicable
55if [ -x $LAB_DIR/apt-proxy.sh ]; then
56 $LAB_DIR/apt-proxy.sh ${YAML_FILE}
Gary Wua254fab2018-04-03 07:52:28 -070057 diff ${YAML_SRC} ${YAML_FILE}
Gary Wud83efff2018-01-09 16:47:30 -080058fi
59
60
61#exit 0
62
Gary Wuf8233432018-01-05 13:16:26 -080063#diff ${LAB_DIR}/onap-openstack-template.env ${LAB_DIR}/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070064
Gary Wud83efff2018-01-09 16:47:30 -080065
66# tear down old deployment
Gary Wuf88c6302018-08-08 12:55:58 -070067$WORKSPACE/test/ete/scripts/teardown-onap.sh -q
Gary Wud83efff2018-01-09 16:47:30 -080068
69# create new stack
Gary Wucbb3d882018-08-01 07:50:30 -070070STACK="onap-heat-$(uuidgen | cut -c-4)"
Gary Wud83efff2018-01-09 16:47:30 -080071echo "New Stack Name: ${STACK}"
Gary Wua254fab2018-04-03 07:52:28 -070072if ! openstack stack create -t ${YAML_FILE} -e ${ENV_FILE} $STACK; then
73 exit 1
74fi
Gary Wu874794d2017-10-13 12:27:39 -070075
Gary Wuf5fef8b2017-11-09 10:59:46 -080076while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080077 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080078done
79
80STATUS=$(openstack stack show -c stack_status -f value $STACK)
81echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080082if [ "CREATE_COMPLETE" != "$STATUS" ]; then
83 exit 1
84fi
85
86
87# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080088ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080089echo "ROBOT_IP=${ROBOT_IP}"
90
91if [ "" == "${ROBOT_IP}" ]; then
92 exit 1
93fi
94
95ssh-keygen -R ${ROBOT_IP}
96
97SSH_KEY=~/.ssh/onap_key
98
Gary Wu3e4eede2018-04-17 17:33:07 -070099for n in $(seq 1 10); do
100 ssh -o StrictHostKeychecking=no -i ${SSH_KEY} ubuntu@${ROBOT_IP} "sudo docker ps" | grep openecompete_container
101 RESULT=$?
102 if [ $RESULT -eq 0 ]; then
103 break
104 fi
105 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -0800106done