1064ba
From cee7eef674c4fe7e4a23e5c358df23064796e9e2 Mon Sep 17 00:00:00 2001
5a2e6e
From: Ryan McCabe <rmccabe@redhat.com>
1064ba
Date: Thu, 30 Nov 2017 08:59:03 -0500
5a2e6e
Subject: [PATCH] sysconfig: Render IPV6_DEFAULTGW correctly
5a2e6e
5a2e6e
Downstream backport of the fixes introduced in upstream commit
5a2e6e
97abd83513bee191b58f095f4d683b18acce0b49 which will not apply to
5a2e6e
the RHEL 0.7.9 tree.
5a2e6e
5a2e6e
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
1064ba
Resolves: rhbz#1492726
5a2e6e
---
5a2e6e
 cloudinit/net/sysconfig.py                     | 6 +++++-
1064ba
 tests/unittests/test_distros/test_netconfig.py | 4 +++-
1064ba
 tests/unittests/test_net.py                    | 1 +
1064ba
 3 files changed, 9 insertions(+), 2 deletions(-)
5a2e6e
5a2e6e
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
1064ba
index e34c8491..380daedf 100644
5a2e6e
--- a/cloudinit/net/sysconfig.py
5a2e6e
+++ b/cloudinit/net/sysconfig.py
5a2e6e
@@ -348,7 +348,11 @@ class Renderer(renderer.Renderer):
5a2e6e
                                 subnet['netmask']
5a2e6e
 
5a2e6e
                 if 'gateway' in subnet:
5a2e6e
-                    iface_cfg['GATEWAY'] = subnet['gateway']
5a2e6e
+                    iface_cfg['DEFROUTE'] = True
5a2e6e
+                    if ":" in subnet['gateway']:
5a2e6e
+                        iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
5a2e6e
+                    else:
5a2e6e
+                        iface_cfg['GATEWAY'] = subnet['gateway']
5a2e6e
 
1064ba
                 if 'dns_search' in subnet:
1064ba
                     if isinstance(subnet['dns_search'], (list, tuple)):
5a2e6e
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
1064ba
index 108d5741..10e25a72 100644
5a2e6e
--- a/tests/unittests/test_distros/test_netconfig.py
5a2e6e
+++ b/tests/unittests/test_distros/test_netconfig.py
1064ba
@@ -257,6 +257,7 @@ NETWORKING=yes
5a2e6e
 # Created by cloud-init on instance boot automatically, do not edit.
5a2e6e
 #
5a2e6e
 BOOTPROTO=none
5a2e6e
+DEFROUTE=yes
5a2e6e
 DEVICE=eth0
5a2e6e
 IPADDR=192.168.1.5
5a2e6e
 NETMASK=255.255.255.0
1064ba
@@ -395,10 +396,11 @@ IPV6_AUTOCONF=no
5a2e6e
 # Created by cloud-init on instance boot automatically, do not edit.
5a2e6e
 #
5a2e6e
 BOOTPROTO=none
5a2e6e
+DEFROUTE=yes
5a2e6e
 DEVICE=eth0
5a2e6e
 IPV6ADDR=2607:f0d0:1002:0011::2/64
1064ba
-GATEWAY=2607:f0d0:1002:0011::1
5a2e6e
 IPV6INIT=yes
5a2e6e
+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
5a2e6e
 ONBOOT=yes
5a2e6e
 TYPE=Ethernet
5a2e6e
 USERCTL=no
1064ba
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
1064ba
index 551370d4..34af5daa 100644
1064ba
--- a/tests/unittests/test_net.py
1064ba
+++ b/tests/unittests/test_net.py
1064ba
@@ -833,6 +833,7 @@ USERCTL=no
1064ba
 # Created by cloud-init on instance boot automatically, do not edit.
1064ba
 #
1064ba
 BOOTPROTO=none
1064ba
+DEFROUTE=yes
1064ba
 DEVICE=interface0
1064ba
 GATEWAY=10.0.2.2
1064ba
 HWADDR=52:54:00:12:34:00
5a2e6e
-- 
5a2e6e
2.14.3
5a2e6e