From 42b0bc930a525f6ff35b35bb7cb9fc93c7a829df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20Jens=C3=A5s?= <hjensas@redhat.com>
Date: Mon, 11 Mar 2019 20:04:08 +0100
Subject: [PATCH] Support ctlplane subnet host routes from undercloud.conf

Change: I692fcc4a494b2cda1911814a53a0c6ec2f99f807 in
python-tripleoclient added support to define host routes
for the subnets in undercloud.conf.

Update the undercloud ctlplane network post script so
that it add's these routes to the host_routes property
of the undercloud ctlplane subnets.

THT already uses the data in the subnets host_routes, it
is passed as ControlPlaneStaticRoutes to NetworkConfig
unless ControlPlaneStaticRoutes was statically overriden
in the environment.

Closes-Bug: #1819464
Depends-On: I692fcc4a494b2cda1911814a53a0c6ec2f99f807
Change-Id: I46b7c7175f542ad4d375a20f133c05064e7b7222
---
 .../post_deploy/undercloud_ctlplane_network.py       |  2 ++
 ...undercloud-conf-host-routes-00e981d1f00405d8.yaml | 12 ++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 releasenotes/notes/ctlplane-undercloud-conf-host-routes-00e981d1f00405d8.yaml

diff --git a/extraconfig/post_deploy/undercloud_ctlplane_network.py b/extraconfig/post_deploy/undercloud_ctlplane_network.py
index 387a1d0adb..df29ed3482 100755
--- a/extraconfig/post_deploy/undercloud_ctlplane_network.py
+++ b/extraconfig/post_deploy/undercloud_ctlplane_network.py
@@ -205,6 +205,7 @@ def _local_neutron_segments_and_subnets(sdk, ctlplane_id, net_cidrs):
     segment = _get_segment(sdk, CONF['physical_network'], ctlplane_id)
     host_routes = [{'destination': '169.254.169.254/32',
                     'nexthop': CONF['local_ip']}]
+    host_routes += s['HostRoutes']
     if subnet:
         if CONF['enable_routed_networks'] and subnet.segment_id == None:
             # The subnet exists and does not have a segment association. Since
@@ -245,6 +246,7 @@ def _remote_neutron_segments_and_subnets(sdk, ctlplane_id, net_cidrs):
         metadata_nexthop = s['NetworkGateway']
         host_routes = [{'destination': '169.254.169.254/32',
                         'nexthop': metadata_nexthop}]
+        host_routes += s['HostRoutes']
         subnet = _get_subnet(sdk, s['NetworkCidr'], ctlplane_id)
         segment = _get_segment(sdk, phynet, ctlplane_id)
         if subnet:
diff --git a/releasenotes/notes/ctlplane-undercloud-conf-host-routes-00e981d1f00405d8.yaml b/releasenotes/notes/ctlplane-undercloud-conf-host-routes-00e981d1f00405d8.yaml
new file mode 100644
index 0000000000..ba5606b649
--- /dev/null
+++ b/releasenotes/notes/ctlplane-undercloud-conf-host-routes-00e981d1f00405d8.yaml
@@ -0,0 +1,12 @@
+---
+features:
+  - |
+    A new option ``host_routes`` are now available for subnet defenitions in
+    ``undercloud.conf``.
+
+    - Host routes specified for the *local_subnet* will be added to
+      the routing table on the Undercloud.
+    - Host routes for *all* subnets are passed to tripleo-heat-templates so
+      that the *host_routes* property of the ctlplane subnets are set
+      accordingly when installing the Undercloud.
+