[aiab] Allow to run aiab deployment from any directory

Make aiab scripts to use relative paths, this fixes a problem
when the user runs the script from a different from `/root/deploy`
directory, or runs it from outside of `tools/deployment/aiab`.

Change-Id: If539812390253c720f47aacbda666de8acfd0fda
This commit is contained in:
Evgeny L 2019-06-12 18:07:36 +00:00 committed by Kaspars Skels
parent bd16dbc3b3
commit f97a2c53f8
3 changed files with 25 additions and 24 deletions

View File

@ -22,6 +22,8 @@
# # # #
############################################################################### ###############################################################################
AIAB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
usage () usage ()
{ {
echo "Usage: $(basename $0) {-y|-h}" 1>&2 echo "Usage: $(basename $0) {-y|-h}" 1>&2
@ -148,7 +150,7 @@ get_dns_servers ()
if grep -q "10.96.0.10" "/etc/resolv.conf"; then if grep -q "10.96.0.10" "/etc/resolv.conf"; then
echo "Not changing DNS servers, /etc/resolv.conf already updated." echo "Not changing DNS servers, /etc/resolv.conf already updated."
else else
DNS_CONFIG_FILE="../../../../site/${TARGET_SITE}/networks/common-addresses.yaml" DNS_CONFIG_FILE="${AIAB_DIR}/../../../site/${TARGET_SITE}/networks/common-addresses.yaml"
declare -a DNS_SERVERS=($(get_dns_servers)) declare -a DNS_SERVERS=($(get_dns_servers))
NS1=${DNS_SERVERS[0]:-8.8.8.8} NS1=${DNS_SERVERS[0]:-8.8.8.8}
NS2=${DNS_SERVERS[1]:-$NS1} NS2=${DNS_SERVERS[1]:-$NS1}
@ -160,4 +162,4 @@ fi
echo "" echo ""
echo "Starting Airship deployment..." echo "Starting Airship deployment..."
sleep 1 sleep 1
common/deploy-airship.sh demo ${AIAB_DIR}/common/deploy-airship.sh demo

View File

@ -24,11 +24,6 @@
set -x set -x
# IMPORTANT:
# If the directory for airship-in-a-bottle is already cloned into $WORKSPACE,
# it will not be re-cloned. This can be used to set up different tests, like
# changing the versions and contents of the design before running this script
# The last step to run through in this script. Valid Values are "collect", # The last step to run through in this script. Valid Values are "collect",
# "genesis", "deploy", and "demo". By default this will run through to the end # "genesis", "deploy", and "demo". By default this will run through to the end
# of the genesis steps # of the genesis steps
@ -46,8 +41,12 @@ else
STEP_BREAKPOINT=20 STEP_BREAKPOINT=20
fi fi
# The directory that will contain the copies of designs and repos from this script # The directory of the repo where current script is located.
export WORKSPACE=${WORKSPACE:-"/root/deploy"} REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../../../ >/dev/null 2>&1 && pwd )"
# The directory that will contain the copies of designs and repos from this
# script. By default it is a directory where the repository is cloned.
export WORKSPACE=${WORKSPACE:-"${REPO_DIR}/../"}
# The site to deploy # The site to deploy
TARGET_SITE=${TARGET_SITE:-"aiab"} TARGET_SITE=${TARGET_SITE:-"aiab"}
@ -68,9 +67,6 @@ NODE_NET_IFACE=${NODE_NET_IFACE:-""}
# Allowance for Genesis/Armada to settle in seconds: # Allowance for Genesis/Armada to settle in seconds:
POST_GENESIS_DELAY=${POST_GENESIS_DELAY:-60} POST_GENESIS_DELAY=${POST_GENESIS_DELAY:-60}
# The directory of the repo where current script is located.
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../../../ >/dev/null 2>&1 && pwd )"
# Command shortcuts # Command shortcuts
PEGLEG="${REPO_DIR}/tools/airship pegleg" PEGLEG="${REPO_DIR}/tools/airship pegleg"
SHIPYARD="${REPO_DIR}/tools/airship shipyard" SHIPYARD="${REPO_DIR}/tools/airship shipyard"
@ -306,7 +302,7 @@ function execute_create_heat_stack() {
echo " " echo " "
set -x set -x
# Switch to directory where the script is located # Switch to directory where the script is located
pushd ${WORKSPACE}/treasuremap/tools/deployment/aiab/ pushd ${WORKSPACE}/treasuremap/tools/deployment/aiab/common/
bash test_create_heat_stack.sh bash test_create_heat_stack.sh
popd popd
} }
@ -332,9 +328,9 @@ function print_dashboards() {
echo " Username: admin" echo " Username: admin"
echo " Password: password" echo " Password: password"
echo " " echo " "
echo "OpenStack CLI commands could be launched via \`./run_openstack_cli.sh\` script, e.g.:" echo "OpenStack CLI commands could be launched via \`./openstack\` script, e.g.:"
echo " # cd ${WORKSPACE}/treasuremap/tools/deployment/aiab" echo " # cd ${WORKSPACE}/treasuremap/tools/"
echo " # ./run_openstack_cli.sh stack list" echo " # ./openstack stack list"
echo " ..." echo " ..."
echo " " echo " "
echo "Other dashboards:" echo "Other dashboards:"

View File

@ -15,6 +15,9 @@
set -e set -e
AIAB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd )"
OPENSTACK="${AIAB_DIR}/../../openstack"
# External subnet is local to the environment and generally can be anything # External subnet is local to the environment and generally can be anything
# other then clash with default all-in-one OSH setup that uses 127.24.4.0/24 # other then clash with default all-in-one OSH setup that uses 127.24.4.0/24
export OSH_BR_EX_ADDR="172.24.8.1/24" export OSH_BR_EX_ADDR="172.24.8.1/24"
@ -23,18 +26,17 @@ export OSH_EXT_SUBNET="172.24.8.0/24"
# Install curl if it's not already installed # Install curl if it's not already installed
apt -y install --no-install-recommends curl apt -y install --no-install-recommends curl
cp /root/deploy/treasuremap/tools/openstack /root/deploy/treasuremap/tools/deployment/aiab pushd "${AIAB_DIR}"
cd /root/deploy/treasuremap/tools/deployment/aiab
printf "\nCreating KeyPair\n" printf "\nCreating KeyPair\n"
./openstack keypair create heat-vm-key > id_rsa ${OPENSTACK} keypair create heat-vm-key > id_rsa
chmod 600 id_rsa chmod 600 id_rsa
printf "Downloading heat-public-net-deployment.yaml\n" printf "Downloading heat-public-net-deployment.yaml\n"
curl -LO https://raw.githubusercontent.com/openstack/openstack-helm/master/tools/gate/files/heat-public-net-deployment.yaml curl -LO https://raw.githubusercontent.com/openstack/openstack-helm/master/tools/gate/files/heat-public-net-deployment.yaml
printf "Creating public-net Heat Stack\n" printf "Creating public-net Heat Stack\n"
./openstack stack create --wait \ ${OPENSTACK} stack create --wait \
--parameter subnet_cidr=${OSH_EXT_SUBNET} \ --parameter subnet_cidr=${OSH_EXT_SUBNET} \
--parameter subnet_gateway=${OSH_BR_EX_ADDR%/*} \ --parameter subnet_gateway=${OSH_BR_EX_ADDR%/*} \
-t /target/heat-public-net-deployment.yaml \ -t /target/heat-public-net-deployment.yaml \
@ -44,15 +46,16 @@ printf "Downloading heat-basic-vm-deployment.yaml\n"
curl -LO https://raw.githubusercontent.com/openstack/openstack-helm/master/tools/gate/files/heat-basic-vm-deployment.yaml curl -LO https://raw.githubusercontent.com/openstack/openstack-helm/master/tools/gate/files/heat-basic-vm-deployment.yaml
printf "Creating test-stack-01\n" printf "Creating test-stack-01\n"
./openstack stack create -t /target/heat-basic-vm-deployment.yaml test-stack-01 --wait ${OPENSTACK} stack create -t /target/heat-basic-vm-deployment.yaml test-stack-01 --wait
popd
printf "Heat Stack List\n" printf "Heat Stack List\n"
./openstack stack list ${OPENSTACK} stack list
printf "Nova Server List\n" printf "Nova Server List\n"
./openstack server list ${OPENSTACK} server list
FLOATING_IP=$(./openstack stack output show \ FLOATING_IP=$(${OPENSTACK} stack output show \
test-stack-01 \ test-stack-01 \
floating_ip \ floating_ip \
-f value -c output_value) -f value -c output_value)