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