Browse Source

[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
tags/v1.1^2
Evgeny L 1 month ago
parent
commit
f97a2c53f8

+ 4
- 2
tools/deployment/aiab/airship-in-a-bottle.sh View File

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

+ 10
- 14
tools/deployment/aiab/common/deploy-airship.sh View File

@@ -24,11 +24,6 @@
24 24
 
25 25
 set -x
26 26
 
27
-# IMPORTANT:
28
-# If the directory for airship-in-a-bottle is already cloned into $WORKSPACE,
29
-# it will not be re-cloned. This can be used to set up different tests, like
30
-# changing the versions and contents of the design before running this script
31
-
32 27
 # The last step to run through in this script. Valid Values are "collect",
33 28
 # "genesis", "deploy", and "demo". By default this will run through to the end
34 29
 # of the genesis steps
@@ -46,8 +41,12 @@ else
46 41
   STEP_BREAKPOINT=20
47 42
 fi
48 43
 
49
-# The directory that will contain the copies of designs and repos from this script
50
-export WORKSPACE=${WORKSPACE:-"/root/deploy"}
44
+# The directory of the repo where current script is located.
45
+REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../../../ >/dev/null 2>&1 && pwd )"
46
+
47
+# The directory that will contain the copies of designs and repos from this
48
+# script. By default it is a directory where the repository is cloned.
49
+export WORKSPACE=${WORKSPACE:-"${REPO_DIR}/../"}
51 50
 
52 51
 # The site to deploy
53 52
 TARGET_SITE=${TARGET_SITE:-"aiab"}
@@ -68,9 +67,6 @@ NODE_NET_IFACE=${NODE_NET_IFACE:-""}
68 67
 # Allowance for Genesis/Armada to settle in seconds:
69 68
 POST_GENESIS_DELAY=${POST_GENESIS_DELAY:-60}
70 69
 
71
-# The directory of the repo where current script is located.
72
-REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../../../ >/dev/null 2>&1 && pwd )"
73
-
74 70
 # Command shortcuts
75 71
 PEGLEG="${REPO_DIR}/tools/airship pegleg"
76 72
 SHIPYARD="${REPO_DIR}/tools/airship shipyard"
@@ -306,7 +302,7 @@ function execute_create_heat_stack() {
306 302
   echo " "
307 303
   set -x
308 304
   # Switch to directory where the script is located
309
-  pushd ${WORKSPACE}/treasuremap/tools/deployment/aiab/
305
+  pushd ${WORKSPACE}/treasuremap/tools/deployment/aiab/common/
310 306
   bash test_create_heat_stack.sh
311 307
   popd
312 308
 }
@@ -332,9 +328,9 @@ function print_dashboards() {
332 328
   echo "  Username: admin"
333 329
   echo "  Password: password"
334 330
   echo " "
335
-  echo "OpenStack CLI commands could be launched via \`./run_openstack_cli.sh\` script, e.g.:"
336
-  echo "  # cd ${WORKSPACE}/treasuremap/tools/deployment/aiab"
337
-  echo "  # ./run_openstack_cli.sh stack list"
331
+  echo "OpenStack CLI commands could be launched via \`./openstack\` script, e.g.:"
332
+  echo "  # cd ${WORKSPACE}/treasuremap/tools/"
333
+  echo "  # ./openstack stack list"
338 334
   echo "  ..."
339 335
   echo "  "
340 336
   echo "Other dashboards:"

+ 11
- 8
tools/deployment/aiab/common/test_create_heat_stack.sh View File

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

Loading…
Cancel
Save