blob: 5c74da7c906382fae45c14175db6e63e984756ec [file] [log] [blame]
#!/bin/bash -x
if [ -z "$WORKSPACE" ]; then
export WORKSPACE=`git rev-parse --show-toplevel`
fi
source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
# Delete all existing stacks
STACKS=$(openstack stack list -c "Stack Name" -f value)
if [ ! -z "${STACKS}" ]; then
echo "Deleting Stacks ${STACKS}"
openstack stack delete -y $STACKS
for STACK in ${STACKS}; do
until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
sleep 30
done
done
else
echo "No existing stacks to delete."
fi
# miscellaneous cleanup
openstack floating ip delete $(openstack floating ip list -c ID -f value)
openstack port delete $(openstack port list -f value -c ID)
openstack router delete $(openstack router list -f value -c ID)
openstack port delete $(openstack port list -f value -c ID)
openstack router delete $(openstack router list -f value -c ID)
openstack port delete $(openstack port list -f value -c ID)
openstack volume delete $(openstack volume list -f value -c ID)
STACK="ete-$(uuidgen | cut -c-8)"
echo "New Stack Name: ${STACK}"
SENTINEL='Docker versions and branches'
YAML_FILE=${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.yaml
ENV_FILE=${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env
cp ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-demo.env
envsubst < ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env | sed -n "1,/${SENTINEL}/p" > ${ENV_FILE}
pushd ${ONAP_WORKDIR}/demo
echo " # Rest of the file was AUTO-GENERATED from"
echo " #" $(git config --get remote.origin.url) heat/ONAP/onap_openstack.env $(git rev-parse HEAD) | tee -a ${ENV_FILE}
popd
sed "1,/${SENTINEL}/d" ${ONAP_WORKDIR}/demo/heat/ONAP/onap_openstack.env >> ${ENV_FILE}
cat ${ENV_FILE}
#diff ${WORKSPACE}/test/ete/labs/windriver/onap-openstack-template.env ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env
# reduce DCAE VM sizes
sed -i 's|__dcaeos_flavor_id__:.*|__dcaeos_flavor_id__: { get_param: flavor_medium }|' ${YAML_FILE}
sed -i 's|__dcaeos_flavor_id_cdap__:.*|__dcaeos_flavor_id_cdap__: { get_param: flavor_large }|' ${YAML_FILE}
openstack stack create -t ${YAML_FILE} -e ${WORKSPACE}/test/ete/labs/windriver/onap-openstack.env $STACK
while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $STACK)" ]; do
sleep 20
done
STATUS=$(openstack stack show -c stack_status -f value $STACK)
echo $STATUS
if [ "CREATE_COMPLETE" != "$STATUS" ]; then
exit 1
fi
# wait until Robot VM initializes
ROBOT_IP=$($WORKSPACE/test/ete/scripts/get-floating-ip.sh onap-robot)
echo "ROBOT_IP=${ROBOT_IP}"
if [ "" == "${ROBOT_IP}" ]; then
exit 1
fi
ssh-keygen -R ${ROBOT_IP}
SSH_KEY=~/.ssh/onap_key
until ssh -o StrictHostKeychecking=no -i ${SSH_KEY} root@${ROBOT_IP} "docker ps | grep -q openecompete_container"
do
sleep 2m
done