sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
bb836b
From dfea0490b899804761fbd7aa23822783d7c36ec5 Mon Sep 17 00:00:00 2001
18322d
From: Eduardo Otubo <otubo@redhat.com>
bb836b
Date: Fri, 7 May 2021 13:36:13 +0200
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
bb836b
index 3d276666..d5440998 100644
18322d
--- a/cloudinit/net/sysconfig.py
18322d
+++ b/cloudinit/net/sysconfig.py
bb836b
@@ -925,7 +925,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
bb836b
index 4ea0e597..c67b5fcc 100644
18322d
--- a/tests/unittests/test_net.py
18322d
+++ b/tests/unittests/test_net.py
bb836b
@@ -1729,7 +1729,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
-- 
bb836b
2.27.0
18322d