sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init 10 months ago
Clone
2b0ae0
From bdcad981ac530277529d1c77fb5e9e6f89409bd8 Mon Sep 17 00:00:00 2001
18322d
From: Eduardo Otubo <otubo@redhat.com>
2b0ae0
Date: Mon, 5 Oct 2020 13:51:44 +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
2b0ae0
index 23e467d..af093dd 100644
18322d
--- a/cloudinit/net/sysconfig.py
18322d
+++ b/cloudinit/net/sysconfig.py
2b0ae0
@@ -888,7 +888,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
2b0ae0
index 2cc57fe..9985a97 100644
18322d
--- a/tests/unittests/test_net.py
18322d
+++ b/tests/unittests/test_net.py
2b0ae0
@@ -1614,7 +1614,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