Blame SOURCES/0012-include-NOZEROCONF-yes-in-etc-sysconfig-network.patch

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