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