[jump] Add simple check for required Linux bridges 27/51827/2
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Wed, 7 Feb 2018 01:31:52 +0000 (02:31 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Wed, 7 Feb 2018 19:35:18 +0000 (20:35 +0100)
- MaaS requires PXE/admin to be a Linux bridge;
- if virtual nodes are present, they should be hooked to a proper
  Linux bridge for the Public network, but only throw a warning if
  not (and create a mock public virsh network instead);
- if both virtual and baremetal nodes are present, Public bridge is
  indirectly mandatory (we can't mock it);

JIRA: FUEL-339

Change-Id: Idfe99d66c49eadc56cb3d94ca4db3467fb76d388
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
ci/deploy.sh
mcp/scripts/lib.sh

index e962ddd..ed43832 100755 (executable)
@@ -325,6 +325,9 @@ for ((i = 0; i < ${#BR_NAMES[@]}; i++)); do
 done
 notify "[NOTE] Using bridges: ${OPNFV_BRIDGES[*]}" 2
 
+# Jumpserver prerequisites check
+jumpserver_check_requirements "${virtual_nodes[*]}" "${OPNFV_BRIDGES[@]}"
+
 # Infra setup
 if [ ${DRY_RUN} -eq 1 ]; then
     notify "[NOTE] Dry run, skipping all deployment tasks" 2
index 8e9ba97..20d466f 100644 (file)
@@ -313,12 +313,48 @@ function prepare_vms {
   fi
 }
 
+function jumpserver_check_requirements {
+  local vnodes=$1; shift
+  local br=("$@")
+  local err_br_not_found='Linux bridge not found!'
+  local err_br_virsh_net='is a virtual network, Linux bridge expected!'
+  local warn_br_endpoint="Endpoints might be inaccessible from external hosts!"
+  # MaaS requires a Linux bridge for PXE/admin
+  if [[ "${vnodes}" =~ mas01 ]]; then
+    if ! brctl showmacs "${br[0]}" >/dev/null 2>&1; then
+      notify_e "[ERROR] PXE/admin (${br[0]}) ${err_br_not_found}"
+    fi
+    # Assume virsh network name matches bridge name (true if created by us)
+    if virsh net-info "${br[0]}" >/dev/null 2>&1; then
+      notify_e "[ERROR] ${br[0]} ${err_br_virsh_net}"
+    fi
+  fi
+  # If virtual nodes are present, public should be a Linux bridge
+  if [ "$(echo "${vnodes}" | wc -w)" -gt 2 ]; then
+    if ! brctl showmacs "${br[3]}" >/dev/null 2>&1; then
+      if [[ "${vnodes}" =~ mas01 ]]; then
+        # Baremetal nodes *require* a proper public network
+        notify_e "[ERROR] Public (${br[3]}) ${err_br_not_found}"
+      else
+        notify_n "[WARN] Public (${br[3]}) ${err_br_not_found}" 3
+        notify_n "[WARN] ${warn_br_endpoint}" 3
+      fi
+    fi
+    if virsh net-info "${br[3]}" >/dev/null 2>&1; then
+      if [[ "${vnodes}" =~ mas01 ]]; then
+        notify_e "[ERROR] ${br[3]} ${err_br_virsh_net}"
+      else
+        notify_n "[WARN] ${br[3]} ${err_br_virsh_net}" 3
+        notify_n "[WARN] ${warn_br_endpoint}" 3
+      fi
+    fi
+  fi
+}
+
 function create_networks {
   local vnode_networks=("$@")
   # create required networks, including constant "mcpcontrol"
-  # FIXME(alav): since we renamed "pxe" to "mcpcontrol", we need to make sure
-  # we delete the old "pxe" virtual network, or it would cause IP conflicts.
-  for net in "pxe" "mcpcontrol" "${vnode_networks[@]}"; do
+  for net in "mcpcontrol" "${vnode_networks[@]}"; do
     if virsh net-info "${net}" >/dev/null 2>&1; then
       virsh net-destroy "${net}" || true
       virsh net-undefine "${net}"