From 1ba142a05f393b921632a39ab16fb38bce806b51 Mon Sep 17 00:00:00 2001
From: Derek Higgins <derekh@redhat.com>
Date: Fri, 21 Sep 2018 13:55:51 +0100
Subject: [PATCH] Restore the nova-api redirect

This was disabled when grenade switched to using rocky
as its base install as it didn't work with wsgi. Restore it
using a version that compatable with WSGI.

Task: #26604
Story: 2003808
Change-Id: I968339b48191df46a44f45c1794478aa0d1039f6
---
 devstack/files/apache-ironic-api-redirect.template |  5 +----
 devstack/upgrade/upgrade.sh                        | 12 +++++-------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/devstack/files/apache-ironic-api-redirect.template b/devstack/files/apache-ironic-api-redirect.template
index a4dfcbbac5..3afd292e8c 100644
--- a/devstack/files/apache-ironic-api-redirect.template
+++ b/devstack/files/apache-ironic-api-redirect.template
@@ -14,8 +14,5 @@
 # Ironic API through mod_wsgi.  This version assumes you are
 # running devstack to configure the software.
 
-Listen %IRONIC_SERVICE_PORT%
 
-<VirtualHost *:%IRONIC_SERVICE_PORT%>
-    Redirect 307 / %IRONIC_SERVICE_PROTOCOL%://%IRONIC_SERVICE_HOST%:%IRONIC_SERVICE_PORT%/
-</VirtualHost>
+Redirect 307 /baremetal %IRONIC_SERVICE_PROTOCOL%://%IRONIC_SERVICE_HOST%/baremetal
diff --git a/devstack/upgrade/upgrade.sh b/devstack/upgrade/upgrade.sh
index 4b42a6910a..34fb61fe56 100755
--- a/devstack/upgrade/upgrade.sh
+++ b/devstack/upgrade/upgrade.sh
@@ -93,18 +93,16 @@ ensure_stopped=''
 # According to Ironic upgrade procedure, we shouldn't have upgraded (new) ironic-api and not upgraded (old)
 # ironic-conductor. By setting redirect of API requests from primary node to subnode during upgrade
 # allow to satisfy ironic upgrade requirements.
-# FIXME: We need a wsgi alternative to this ASAP
-if [[ "$HOST_TOPOLOGY_ROLE" == 'primary-disabled' ]]; then
+if [[ "$HOST_TOPOLOGY_ROLE" == 'primary' ]]; then
     disable_service ir-api
     ensure_stopped+='ironic-api'
-    ironic_apache_conf=$(apache_site_config_for ironic-api-redirect)
-    sudo cp $IRONIC_DEVSTACK_FILES_DIR/apache-ironic-api-redirect.template $ironic_apache_conf
+    ironic_wsgi_conf=$(apache_site_config_for ironic-api-wsgi)
+    sudo cp $IRONIC_DEVSTACK_FILES_DIR/apache-ironic-api-redirect.template $ironic_wsgi_conf
     sudo sed -e "
-        s|%IRONIC_SERVICE_PORT%|$IRONIC_SERVICE_PORT|g;
         s|%IRONIC_SERVICE_PROTOCOL%|$IRONIC_SERVICE_PROTOCOL|g;
         s|%IRONIC_SERVICE_HOST%|$IRONIC_PROVISION_SUBNET_SUBNODE_IP|g;
-    " -i $ironic_apache_conf
-    enable_apache_site ironic-api-redirect
+    " -i $ironic_wsgi_conf
+    enable_apache_site ipxe-ironic
 else
     ensure_started+='ironic-api '
 fi