17dafa
From 320cbee1530952d31e9e0a3047ba292e0d6d16fc Mon Sep 17 00:00:00 2001
17dafa
From: Eduardo Otubo <otubo@redhat.com>
17dafa
Date: Wed, 20 Mar 2019 11:45:59 +0100
17dafa
Subject: include 'NOZEROCONF=yes' in /etc/sysconfig/network
17dafa
17dafa
RH-Author: Eduardo Otubo <otubo@redhat.com>
17dafa
Message-id: <20190320114559.23708-1-otubo@redhat.com>
17dafa
Patchwork-id: 84937
17dafa
O-Subject: [RHEL-7.7 cloud-init PATCH] include 'NOZEROCONF=yes' in /etc/sysconfig/network
17dafa
Bugzilla: 1653131
17dafa
RH-Acked-by: Cathy Avery <cavery@redhat.com>
17dafa
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
17dafa
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
17dafa
17dafa
The option NOZEROCONF=yes is not included by default in
17dafa
/etc/sysconfig/network, which is required by Overcloud instances. The
17dafa
patch also includes tests for the modifications.
17dafa
17dafa
X-downstream-only: yes
17dafa
Resolves: rhbz#1653131
17dafa
17dafa
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
17dafa
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
17dafa
---
17dafa
 cloudinit/net/sysconfig.py  | 11 ++++++++++-
17dafa
 tests/unittests/test_net.py |  1 -
17dafa
 2 files changed, 10 insertions(+), 2 deletions(-)
17dafa
17dafa
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
17dafa
index ae0554e..d94c1f5 100644
17dafa
--- a/cloudinit/net/sysconfig.py
17dafa
+++ b/cloudinit/net/sysconfig.py
17dafa
@@ -661,7 +661,16 @@ class Renderer(renderer.Renderer):
17dafa
         # Distros configuring /etc/sysconfig/network as a file e.g. Centos
17dafa
         if sysconfig_path.endswith('network'):
17dafa
             util.ensure_dir(os.path.dirname(sysconfig_path))
17dafa
-            netcfg = [_make_header(), 'NETWORKING=yes']
17dafa
+            netcfg = []
17dafa
+            for line in util.load_file(sysconfig_path, quiet=True).split('\n'):
17dafa
+                if 'cloud-init' in line:
17dafa
+                    break
17dafa
+                if not line.startswith(('NETWORKING=',
17dafa
+                                        'IPV6_AUTOCONF=',
17dafa
+                                        'NETWORKING_IPV6=')):
17dafa
+                    netcfg.append(line)
17dafa
+            # Now generate the cloud-init portion of sysconfig/network
17dafa
+            netcfg.extend([_make_header(), 'NETWORKING=yes'])
17dafa
             if network_state.use_ipv6:
17dafa
                 netcfg.append('NETWORKING_IPV6=yes')
17dafa
                 netcfg.append('IPV6_AUTOCONF=no')
17dafa
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
17dafa
index 8bcafe0..5f1aa3e 100644
17dafa
--- a/tests/unittests/test_net.py
17dafa
+++ b/tests/unittests/test_net.py
17dafa
@@ -886,7 +886,6 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
17dafa
                 BOOTPROTO=none
17dafa
                 DEVICE=bond0
17dafa
                 DHCPV6C=yes
17dafa
-                IPV6_AUTOCONF=no
17dafa
                 IPV6INIT=yes
17dafa
                 MACADDR=aa:bb:cc:dd:ee:ff
17dafa
                 ONBOOT=yes
17dafa
-- 
17dafa
1.8.3.1
17dafa