Blob Blame History Raw
From 75fbba4601d09112615c342f88ef7b43fead0508 Mon Sep 17 00:00:00 2001
From: Ryan McCabe <rmccabe@redhat.com>
Date: Fri, 2 Feb 2018 10:25:31 -0500
Subject: [PATCH] sysconfig: Render IPV6_DEFAULTGW correctly

Downstream backport of the fixes introduced in upstream commit
97abd83513bee191b58f095f4d683b18acce0b49 which will not apply to
the RHEL 0.7.9 tree.

Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
Resolves: rhbz#1540094
---
 cloudinit/net/sysconfig.py                     | 6 +++++-
 tests/unittests/test_distros/test_netconfig.py | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index 09df76e3..9975fe2c 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -348,7 +348,11 @@ class Renderer(renderer.Renderer):
                                 subnet['netmask']
 
                 if 'gateway' in subnet:
-                    iface_cfg['GATEWAY'] = subnet['gateway']
+                    iface_cfg['DEFROUTE'] = True
+                    if ":" in subnet['gateway']:
+                        iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
+                    else:
+                        iface_cfg['GATEWAY'] = subnet['gateway']
 
     @classmethod
     def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index 861cf8ef..10e25a72 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -257,9 +257,11 @@ NETWORKING=yes
 # Created by cloud-init on instance boot automatically, do not edit.
 #
 BOOTPROTO=none
+DEFROUTE=yes
 DEVICE=eth0
 IPADDR=192.168.1.5
 NETMASK=255.255.255.0
+GATEWAY=192.168.1.254
 ONBOOT=yes
 TYPE=Ethernet
 USERCTL=no
@@ -394,9 +396,11 @@ IPV6_AUTOCONF=no
 # Created by cloud-init on instance boot automatically, do not edit.
 #
 BOOTPROTO=none
+DEFROUTE=yes
 DEVICE=eth0
 IPV6ADDR=2607:f0d0:1002:0011::2/64
 IPV6INIT=yes
+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
 ONBOOT=yes
 TYPE=Ethernet
 USERCTL=no
-- 
2.14.3