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 | 303a016 | 2017-12-06 10:32:55 -0800 | [diff] [blame] | 24 | # miscellaneous cleanup |
| 25 | openstack floating ip delete $(openstack floating ip list -c ID -f value) |
| 26 | openstack port delete $(openstack port list -f value -c ID) |
| 27 | openstack router delete $(openstack router list -f value -c ID) |
| 28 | openstack port delete $(openstack port list -f value -c ID) |
| 29 | openstack router delete $(openstack router list -f value -c ID) |
| 30 | openstack port delete $(openstack port list -f value -c ID) |
| 31 | openstack volume delete $(openstack volume list -f value -c ID) |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 32 | |
| 33 | |
| 34 | |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 35 | STACK="ete-$(uuidgen | cut -c-8)" |
Gary Wu | 99a7c1a | 2017-10-23 13:12:06 -0700 | [diff] [blame] | 36 | echo "New Stack Name: ${STACK}" |
Gary Wu | b84428e | 2017-10-30 11:09:27 -0700 | [diff] [blame] | 37 | |
| 38 | |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame] | 39 | SENTINEL='Docker versions and branches' |
Gary Wu | 2c43ba5 | 2017-11-21 11:33:12 -0800 | [diff] [blame] | 40 | YAML_FILE=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame] | 41 | ENV_FILE=${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env |
Gary Wu | bd89460 | 2017-10-30 11:52:40 -0700 | [diff] [blame] | 42 | 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] | 43 | envsubst < ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE} |
| 44 | pushd ${ONAP_WORKDIR}/demo |
| 45 | echo " # Rest of the file was AUTO-GENERATED from" |
| 46 | echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE} |
| 47 | popd |
| 48 | sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE} |
| 49 | cat ${ENV_FILE} |
| 50 | |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 51 | #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] | 52 | |
Gary Wu | 2c43ba5 | 2017-11-21 11:33:12 -0800 | [diff] [blame] | 53 | # reduce DCAE VM sizes |
| 54 | sed -i 's|__dcaeos_flavor_id__:.*|__dcaeos_flavor_id__: { get_param: flavor_medium }|' ${YAML_FILE} |
| 55 | sed -i 's|__dcaeos_flavor_id_cdap__:.*|__dcaeos_flavor_id_cdap__: { get_param: flavor_large }|' ${YAML_FILE} |
| 56 | |
| 57 | openstack stack create -t ${YAML_FILE} -e ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env $STACK |
Gary Wu | 874794d | 2017-10-13 12:27:39 -0700 | [diff] [blame] | 58 | |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 59 | 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] | 60 | sleep 20 |
Gary Wu | f5fef8b | 2017-11-09 10:59:46 -0800 | [diff] [blame] | 61 | done |
| 62 | |
| 63 | STATUS=$(openstack stack show -c stack_status -f value $STACK) |
| 64 | echo $STATUS |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 65 | if [ "CREATE_COMPLETE" != "$STATUS" ]; then |
| 66 | exit 1 |
| 67 | fi |
| 68 | |
| 69 | |
| 70 | # wait until Robot VM initializes |
Gary Wu | a3f31bd | 2017-11-09 17:11:01 -0800 | [diff] [blame] | 71 | ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot) |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 72 | echo "ROBOT_IP=${ROBOT_IP}" |
| 73 | |
| 74 | if [ "" == "${ROBOT_IP}" ]; then |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | ssh-keygen -R ${ROBOT_IP} |
| 79 | |
| 80 | SSH_KEY=~/.ssh/onap_key |
| 81 | |
| 82 | until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container" |
| 83 | do |
Gary Wu | 3cad6f3 | 2017-11-15 23:29:11 -0800 | [diff] [blame] | 84 | sleep 2m |
Gary Wu | 778b41b | 2017-11-09 12:08:24 -0800 | [diff] [blame] | 85 | done |