sailesh1993 / rpms / cloud-init

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