sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
5a2e6e
From 75fbba4601d09112615c342f88ef7b43fead0508 Mon Sep 17 00:00:00 2001
5a2e6e
From: Ryan McCabe <rmccabe@redhat.com>
5a2e6e
Date: Fri, 2 Feb 2018 10:25:31 -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>
5a2e6e
Resolves: rhbz#1540094
5a2e6e
---
5a2e6e
 cloudinit/net/sysconfig.py                     | 6 +++++-
5a2e6e
 tests/unittests/test_distros/test_netconfig.py | 4 ++++
5a2e6e
 2 files changed, 9 insertions(+), 1 deletion(-)
5a2e6e
5a2e6e
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
5a2e6e
index 09df76e3..9975fe2c 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
 
5a2e6e
     @classmethod
5a2e6e
     def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
5a2e6e
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
5a2e6e
index 861cf8ef..10e25a72 100644
5a2e6e
--- a/tests/unittests/test_distros/test_netconfig.py
5a2e6e
+++ b/tests/unittests/test_distros/test_netconfig.py
5a2e6e
@@ -257,9 +257,11 @@ 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
5a2e6e
+GATEWAY=192.168.1.254
5a2e6e
 ONBOOT=yes
5a2e6e
 TYPE=Ethernet
5a2e6e
 USERCTL=no
5a2e6e
@@ -394,9 +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
5a2e6e
 IPV6INIT=yes
5a2e6e
+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
5a2e6e
 ONBOOT=yes
5a2e6e
 TYPE=Ethernet
5a2e6e
 USERCTL=no
5a2e6e
-- 
5a2e6e
2.14.3
5a2e6e