#!/usr/bin/env bash

# **neutron_aim.sh**

echo "*********************************************************************"
echo "Begin DevStack Exercise: $0"
echo "*********************************************************************"

# Settings
# ========

# This script exits on an error so that errors don't compound and you see
# only the first error that occurred.
set -o errexit

# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)

# Import common functions
source $TOP_DIR/devstack/functions

# Import configuration
source $TOP_DIR/devstack/openrc

# Import exercise configuration
#source $TOP_DIR/exerciserc

source $TOP_DIR/devstack/openrc demo demo

VALIDATE_OPTS=${VALIDATE_OPTS:-"--config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini"}

# Print the commands being run so that we can see the command that triggers
# an error.  It is also useful for following allowing as the install occurs.
set -o xtrace

# Validate any pre-existing resources
gbp-validate $VALIDATE_OPTS

# Create network
openstack network create net1

# Validate
gbp-validate $VALIDATE_OPTS

# Delete network
openstack network delete net1

# Validate
gbp-validate $VALIDATE_OPTS

set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
echo "*********************************************************************"
