blob: 5c74da7c906382fae45c14175db6e63e984756ec [file] [log] [blame]
Gary Wuf5fef8b2017-11-09 10:59:46 -08001#!/bin/bash -x
Gary Wu874794d2017-10-13 12:27:39 -07002
Gary Wu874794d2017-10-13 12:27:39 -07003if [ -z "$WORKSPACE" ]; then
4 export WORKSPACE=`git rev-parse --show-toplevel`
5fi
6
Gary Wu838c34d2017-10-23 14:22:40 -07007source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
Gary Wu874794d2017-10-13 12:27:39 -07008
Gary Wu99a7c1a2017-10-23 13:12:06 -07009# Delete all existing stacks
10STACKS=$(openstack stack list -c "Stack Name" -f value)
Gary Wuf5fef8b2017-11-09 10:59:46 -080011
Gary Wubd894602017-10-30 11:52:40 -070012if [ ! -z "${STACKS}" ]; then
13 echo "Deleting Stacks ${STACKS}"
14 openstack stack delete -y $STACKS
Gary Wuf5fef8b2017-11-09 10:59:46 -080015 for STACK in ${STACKS}; do
Gary Wu15db6182017-11-09 15:44:38 -080016 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wuf5fef8b2017-11-09 10:59:46 -080017 sleep 30
18 done
19 done
Gary Wubd894602017-10-30 11:52:40 -070020else
21 echo "No existing stacks to delete."
22fi
Gary Wu874794d2017-10-13 12:27:39 -070023
Gary Wu303a0162017-12-06 10:32:55 -080024# miscellaneous cleanup
25openstack floating ip delete $(openstack floating ip list -c ID -f value)
26openstack port delete $(openstack port list -f value -c ID)
27openstack router delete $(openstack router list -f value -c ID)
28openstack port delete $(openstack port list -f value -c ID)
29openstack router delete $(openstack router list -f value -c ID)
30openstack port delete $(openstack port list -f value -c ID)
31openstack volume delete $(openstack volume list -f value -c ID)
Gary Wuf5fef8b2017-11-09 10:59:46 -080032
33
34
Gary Wu874794d2017-10-13 12:27:39 -070035STACK="ete-$(uuidgen | cut -c-8)"
Gary Wu99a7c1a2017-10-23 13:12:06 -070036echo "New Stack Name: ${STACK}"
Gary Wub84428e2017-10-30 11:09:27 -070037
38
Gary Wu3cad6f32017-11-15 23:29:11 -080039SENTINEL='Docker versions and branches'
Gary Wu2c43ba52017-11-21 11:33:12 -080040YAML_FILE=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml
Gary Wu3cad6f32017-11-15 23:29:11 -080041ENV_FILE=${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env
Gary Wubd894602017-10-30 11:52:40 -070042cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-demo.env
Gary Wu3cad6f32017-11-15 23:29:11 -080043envsubst < ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
44pushd ${ONAP_WORKDIR}/demo
45echo " # Rest of the file was AUTO-GENERATED from"
46echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
47popd
48sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE}
49cat ${ENV_FILE}
50
Gary Wuf5fef8b2017-11-09 10:59:46 -080051#diff ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env
Gary Wub84428e2017-10-30 11:09:27 -070052
Gary Wu2c43ba52017-11-21 11:33:12 -080053# reduce DCAE VM sizes
54sed -i 's|__dcaeos_flavor_id__:.*|__dcaeos_flavor_id__: { get_param: flavor_medium }|' ${YAML_FILE}
55sed -i 's|__dcaeos_flavor_id_cdap__:.*|__dcaeos_flavor_id_cdap__: { get_param: flavor_large }|' ${YAML_FILE}
56
57openstack stack create -t ${YAML_FILE} -e ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env $STACK
Gary Wu874794d2017-10-13 12:27:39 -070058
Gary Wuf5fef8b2017-11-09 10:59:46 -080059while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
Gary Wu3cad6f32017-11-15 23:29:11 -080060 sleep 20
Gary Wuf5fef8b2017-11-09 10:59:46 -080061done
62
63STATUS=$(openstack stack show -c stack_status -f value $STACK)
64echo $STATUS
Gary Wu778b41b2017-11-09 12:08:24 -080065if [ "CREATE_COMPLETE" != "$STATUS" ]; then
66 exit 1
67fi
68
69
70# wait until Robot VM initializes
Gary Wua3f31bd2017-11-09 17:11:01 -080071ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
Gary Wu778b41b2017-11-09 12:08:24 -080072echo "ROBOT_IP=${ROBOT_IP}"
73
74if [ "" == "${ROBOT_IP}" ]; then
75 exit 1
76fi
77
78ssh-keygen -R ${ROBOT_IP}
79
80SSH_KEY=~/.ssh/onap_key
81
82until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container"
83do
Gary Wu3cad6f32017-11-15 23:29:11 -080084 sleep 2m
Gary Wu778b41b2017-11-09 12:08:24 -080085done