7fc49f
From 75fbba4601d09112615c342f88ef7b43fead0508 Mon Sep 17 00:00:00 2001
7fc49f
From: Ryan McCabe <rmccabe@redhat.com>
7fc49f
Date: Fri, 2 Feb 2018 10:25:31 -0500
7fc49f
Subject: [PATCH] sysconfig: Render IPV6_DEFAULTGW correctly
7fc49f
7fc49f
Downstream backport of the fixes introduced in upstream commit
7fc49f
97abd83513bee191b58f095f4d683b18acce0b49 which will not apply to
7fc49f
the RHEL 0.7.9 tree.
7fc49f
7fc49f
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
7fc49f
Resolves: rhbz#1540094
7fc49f
---
7fc49f
 cloudinit/net/sysconfig.py                     | 6 +++++-
7fc49f
 tests/unittests/test_distros/test_netconfig.py | 4 ++++
7fc49f
 2 files changed, 9 insertions(+), 1 deletion(-)
7fc49f
7fc49f
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
7fc49f
index 09df76e3..9975fe2c 100644
7fc49f
--- a/cloudinit/net/sysconfig.py
7fc49f
+++ b/cloudinit/net/sysconfig.py
7fc49f
@@ -348,7 +348,11 @@ class Renderer(renderer.Renderer):
7fc49f
                                 subnet['netmask']
7fc49f
 
7fc49f
                 if 'gateway' in subnet:
7fc49f
-                    iface_cfg['GATEWAY'] = subnet['gateway']
7fc49f
+                    iface_cfg['DEFROUTE'] = True
7fc49f
+                    if ":" in subnet['gateway']:
7fc49f
+                        iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
7fc49f
+                    else:
7fc49f
+                        iface_cfg['GATEWAY'] = subnet['gateway']
7fc49f
 
7fc49f
     @classmethod
7fc49f
     def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
7fc49f
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
7fc49f
index 861cf8ef..10e25a72 100644
7fc49f
--- a/tests/unittests/test_distros/test_netconfig.py
7fc49f
+++ b/tests/unittests/test_distros/test_netconfig.py
7fc49f
@@ -257,9 +257,11 @@ NETWORKING=yes
7fc49f
 # Created by cloud-init on instance boot automatically, do not edit.
7fc49f
 #
7fc49f
 BOOTPROTO=none
7fc49f
+DEFROUTE=yes
7fc49f
 DEVICE=eth0
7fc49f
 IPADDR=192.168.1.5
7fc49f
 NETMASK=255.255.255.0
7fc49f
+GATEWAY=192.168.1.254
7fc49f
 ONBOOT=yes
7fc49f
 TYPE=Ethernet
7fc49f
 USERCTL=no
7fc49f
@@ -394,9 +396,11 @@ IPV6_AUTOCONF=no
7fc49f
 # Created by cloud-init on instance boot automatically, do not edit.
7fc49f
 #
7fc49f
 BOOTPROTO=none
7fc49f
+DEFROUTE=yes
7fc49f
 DEVICE=eth0
7fc49f
 IPV6ADDR=2607:f0d0:1002:0011::2/64
7fc49f
 IPV6INIT=yes
7fc49f
+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
7fc49f
 ONBOOT=yes
7fc49f
 TYPE=Ethernet
7fc49f
 USERCTL=no
7fc49f
-- 
7fc49f
2.14.3
7fc49f