HAProxy - Add host routes to the lbaas namespace

This change adds a loop through the subnet host routes and
if any of this routes have the destination different from
0.0.0.0/0, adds it to the lbaas namespace.

Change-Id: I08cd006faed2291d731768d71149d07592bce301
Closes-Bug: #1635355
(cherry picked from commit 4a708bfce9)
This commit is contained in:
Flávio Ramalho 2016-10-20 14:15:20 -03:00
parent a6102279c7
commit efacaecfba
1 changed files with 9 additions and 1 deletions

View File

@ -309,10 +309,18 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
device = ip_lib.IPDevice(interface_name, namespace=namespace)
device.addr.wait_until_address_ready(vip_address)
# Add subnet host routes
host_routes = port.fixed_ips[0].subnet.host_routes
for host_route in host_routes:
if host_route.destination != "0.0.0.0/0":
cmd = ['route', 'add', '-net', host_route.destination,
'gw', host_route.nexthop]
ip_wrapper = ip_lib.IPWrapper(namespace=namespace)
ip_wrapper.netns.execute(cmd, check_exit_code=False)
gw_ip = port.fixed_ips[0].subnet.gateway_ip
if not gw_ip:
host_routes = port.fixed_ips[0].subnet.host_routes
for host_route in host_routes:
if host_route.destination == "0.0.0.0/0":
gw_ip = host_route.nexthop