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