From 13e77e2179937f7fdf42ae40bc58af9909721526 Mon Sep 17 00:00:00 2001
From: Vanou Ishii <ishii.vanou@fujitsu.com>
Date: Mon, 1 Feb 2021 08:15:42 +0900
Subject: [PATCH] Fix Mis-Ordering of Bash Variable Definition in DevStack

In devstack/lib/ironic, IRONIC_DEPLOY_DRIVER is defined at line 341.
However variables which use IRONIC_DEPLOY_DRIVER in default value
(e.g. IRONIC_DEPLOY_RAMDISK, IRONIC_DEPLOY_KERNEL, IRONIC_DEPLOY_ISO
and IRONIC_EFIBOOT) are defined at line 276-282.

This will cause problem at line 295-296:

 if [[ "$IRONIC_BUILD_DEPLOY_RAMDISK" == "False" && \
         ! (-e "$IRONIC_DEPLOY_RAMDISK" && -e "$IRONIC_DEPLOY_KERNEL")

So, this commit moves definition of IRONIC_DEPLOY_DRIVER before
its first use.

Change-Id: I74acb32714ce8830d4697fc796146b894aa7d8c9
---
 devstack/lib/ironic | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/devstack/lib/ironic b/devstack/lib/ironic
index d1c98f5979..69f26b8fd9 100644
--- a/devstack/lib/ironic
+++ b/devstack/lib/ironic
@@ -271,6 +271,13 @@ if [[ "$hostdomain" =~ "rax" ]]; then
     fi
 fi
 
+# Which deploy driver to use - valid choices right now
+# are ``ipmi``, ``snmp`` and ``redfish``.
+#
+# Additional valid choices if IRONIC_IS_HARDWARE == true are:
+# ``idrac`` and ``irmc``.
+IRONIC_DEPLOY_DRIVER=${IRONIC_DEPLOY_DRIVER:-ipmi}
+
 # If present, these files are used as deploy ramdisk/kernel.
 # (The value must be an absolute path)
 IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-$TOP_DIR/files/ir-deploy-$IRONIC_DEPLOY_DRIVER.initramfs}
@@ -333,12 +340,6 @@ if [[ "$IRONIC_DEPLOY_ISO_REQUIRED" = "True" \
     die "Prebuilt ISOs are not available, provide an ISO via IRONIC_DEPLOY_ISO \
         or set IRONIC_BUILD_DEPLOY_RAMDISK=True to use ISOs"
 fi
-# Which deploy driver to use - valid choices right now
-# are ``ipmi``, ``snmp`` and ``redfish``.
-#
-# Additional valid choices if IRONIC_IS_HARDWARE == true are:
-# ``idrac`` and ``irmc``.
-IRONIC_DEPLOY_DRIVER=${IRONIC_DEPLOY_DRIVER:-ipmi}
 
 # If the requested driver is not yet enable, enable it, if it is not it will fail anyway
 if [[ -z "$(echo ${IRONIC_ENABLED_HARDWARE_TYPES} | grep -w ${IRONIC_DEPLOY_DRIVER})" ]]; then