Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 1 | #!/bin/bash -x |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 2 | |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 3 | if [ -z "$WORKSPACE" ]; then |
| 4 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 5 | fi |
| 6 | |
Gary Wu | 838c34d | 2017-10-23 14:22:40 -0700 | [diff] [blame] | 7 | source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 8 | |
Gary Wu | 99a7c1a | 2017-10-23 13:12:06 -0700 | [diff] [blame] | 9 | # Delete all existing stacks |
| 10 | STACKS=$(openstack stack list -c "Stack Name" -f value) |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 11 | |
Gary Wu | bd89460 | 2017-10-30 11:52:40 -0700 | [diff] [blame] | 12 | if [ ! -z "${STACKS}" ]; then |
| 13 | echo "Deleting Stacks ${STACKS}" |
| 14 | openstack stack delete -y $STACKS |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 15 | for STACK in ${STACKS}; do |
Gary Wu | 15db618 | 2017-11-09 15:44:38 -0800 | [diff] [blame] | 16 | until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 17 | sleep 30 |
| 18 | done |
| 19 | done |
Gary Wu | bd89460 | 2017-10-30 11:52:40 -0700 | [diff] [blame] | 20 | else |
| 21 | echo "No existing stacks to delete." |
| 22 | fi |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 23 | |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 24 | |
| 25 | |
| 26 | |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 27 | STACK="ete-$(uuidgen | cut -c-8)" |
Gary Wu | 99a7c1a | 2017-10-23 13:12:06 -0700 | [diff] [blame] | 28 | echo "New Stack Name: ${STACK}" |
Gary Wu | b84428e | 2017-10-30 11:09:27 -0700 | [diff] [blame] | 29 | |
| 30 | |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame^] | 31 | SENTINEL='Docker versions and branches' |
| 32 | ENV_FILE=${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env |
Gary Wu | bd89460 | 2017-10-30 11:52:40 -0700 | [diff] [blame] | 33 | cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-demo.env |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame^] | 34 | envsubst < ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE} |
| 35 | pushd ${ONAP_WORKDIR}/demo |
| 36 | echo " # Rest of the file was AUTO-GENERATED from" |
| 37 | echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE} |
| 38 | popd |
| 39 | sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE} |
| 40 | cat ${ENV_FILE} |
| 41 | |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 42 | #diff ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env |
Gary Wu | b84428e | 2017-10-30 11:09:27 -0700 | [diff] [blame] | 43 | |
Gary Wu | a770e64 | 2017-10-23 12:30:29 -0700 | [diff] [blame] | 44 | openstack stack create -t ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml -e ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env $STACK |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 45 | |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 46 | while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame^] | 47 | sleep 20 |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 48 | done |
| 49 | |
| 50 | STATUS=$(openstack stack show -c stack_status -f value $STACK) |
| 51 | echo $STATUS |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 52 | if [ "CREATE_COMPLETE" != "$STATUS" ]; then |
| 53 | exit 1 |
| 54 | fi |
| 55 | |
| 56 | |
| 57 | # wait until Robot VM initializes |
Gary Wu | a3f31bd | 2017-11-09 17:11:01 -0800 | [diff] [blame] | 58 | ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot) |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 59 | echo "ROBOT_IP=${ROBOT_IP}" |
| 60 | |
| 61 | if [ "" == "${ROBOT_IP}" ]; then |
| 62 | exit 1 |
| 63 | fi |
| 64 | |
| 65 | ssh-keygen -R ${ROBOT_IP} |
| 66 | |
| 67 | SSH_KEY=~/.ssh/onap_key |
| 68 | |
| 69 | until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container" |
| 70 | do |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame^] | 71 | sleep 2m |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 72 | done |