[deploy.sh] Factor out jump bridge parsing to j2 61/53061/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Sat, 3 Mar 2018 19:16:43 +0000 (20:16 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Sun, 4 Mar 2018 19:04:05 +0000 (20:04 +0100)
Change-Id: Ie4d8e70866d533d195a6e80cdfecbdb00a3027ce
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
ci/deploy.sh
mcp/scripts/.gitignore
mcp/scripts/xdf_data.sh.j2 [new file with mode: 0644]

index c883616..344a87f 100755 (executable)
@@ -120,8 +120,6 @@ CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
 REPO_ROOT_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")
 DEPLOY_DIR=$(cd "${REPO_ROOT_PATH}/mcp/scripts"; pwd)
 STORAGE_DIR=$(cd "${REPO_ROOT_PATH}/mcp/deploy/images"; pwd)
-BR_NAMES=('admin' 'mgmt' 'private' 'public')
-OPNFV_BRIDGES=('pxebr' 'mgmt' 'internal' 'public')
 URI_REGEXP='(file|https?|ftp)://.*'
 BASE_CONFIG_URI="file://${REPO_ROOT_PATH}/mcp/scripts/pharos"
 
@@ -288,11 +286,6 @@ export MAAS_SSH_KEY="$(cat "$(basename "${SSH_KEY}").pub")"
 do_templates "${REPO_ROOT_PATH}" "${STORAGE_DIR}" "${TARGET_LAB}" \
              "${TARGET_POD}" "${BASE_CONFIG_URI}"
 
-# Get required infra deployment data based on PDF/IDF (after template parsing)
-set +x
-eval "$(parse_yaml "${STORAGE_DIR}/pod_config.yml")"
-[[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
-
 # Serialize vnode data as '<name0>,<ram0>,<vcpu0>|<name1>,<ram1>,<vcpu1>[...]'
 for node in "${virtual_nodes[@]}"; do
     virtual_custom_ram="virtual_${node}_ram"
@@ -320,13 +313,8 @@ for sc in ${base_image_flavors}; do
 done
 virtual_repos_pkgs=${virtual_repos_pkgs%^}
 
-# Determine 'admin', 'mgmt', 'private' and 'public' bridge names based on IDF
-for ((i = 0; i < ${#BR_NAMES[@]}; i++)); do
-    br_jump=$(eval echo "\$parameters__param_opnfv_jump_bridge_${BR_NAMES[i]}")
-    if [ -n "${br_jump}" ] && [ "${br_jump}" != 'None' ]; then
-        OPNFV_BRIDGES[${i}]="${br_jump}"
-    fi
-done
+# Determine additional data (e.g. jump bridge names) based on XDF
+source "${DEPLOY_DIR}/xdf_data.sh"
 notify "[NOTE] Using bridges: ${OPNFV_BRIDGES[*]}" 2
 
 # Jumpserver prerequisites check
index b235933..89af7c4 100644 (file)
@@ -1 +1,2 @@
 user-data.*.sh
+xdf_data.sh
diff --git a/mcp/scripts/xdf_data.sh.j2 b/mcp/scripts/xdf_data.sh.j2
new file mode 100644 (file)
index 0000000..9479f23
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+##############################################################################
+# Copyright (c) 2018 Mirantis Inc., Enea AB and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+#
+# Data derived from XDF (PDF/IDF/SDF/etc), used as input in deploy.sh
+#
+
+# Determine bridge names based on IDF, where all bridges are now mandatory
+{%- set bridges = conf.idf.fuel.jumphost.bridges %}
+OPNFV_BRIDGES=(
+  '{{ bridges.admin or "pxebr" }}'
+  '{{ bridges.mgmt or "mgmt" }}'
+  '{{ bridges.private or "internal" }}'
+  '{{ bridges.public or "public" }}'
+)