Add patch to retain old values of /etc/sysconfig/network
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
parent
b32f621899
commit
6164e0aea9
194
cloud-init-17.1-no-override-default-network.patch
Normal file
194
cloud-init-17.1-no-override-default-network.patch
Normal file
@ -0,0 +1,194 @@
|
||||
diff -rup cloud-init-17.1.orig/cloudinit/net/sysconfig.py cloud-init-17.1/cloudinit/net/sysconfig.py
|
||||
--- cloud-init-17.1.orig/cloudinit/net/sysconfig.py 2018-03-26 19:22:35.693111559 +0200
|
||||
+++ cloud-init-17.1/cloudinit/net/sysconfig.py 2018-03-26 22:08:31.436719091 +0200
|
||||
@@ -590,6 +590,12 @@ class Renderer(renderer.Renderer):
|
||||
if network_state.use_ipv6:
|
||||
netcfg.append('NETWORKING_IPV6=yes')
|
||||
netcfg.append('IPV6_AUTOCONF=no')
|
||||
+ # Make sure that existing lines, other than overriding ones, remain
|
||||
+ for line in util.load_file(sysconfig_path, quiet=True).split('\n'):
|
||||
+ if not line.startswith(('NETWORKING=',
|
||||
+ 'IPV6_AUTOCONF=',
|
||||
+ 'NETWORKING_IPV6=')):
|
||||
+ netcfg.append(line)
|
||||
util.write_file(sysconfig_path, "\n".join(netcfg) + "\n", file_mode)
|
||||
|
||||
|
||||
diff -rup cloud-init-17.1.orig/tests/unittests/test_distros/test_netconfig.py cloud-init-17.1/tests/unittests/test_distros/test_netconfig.py
|
||||
--- cloud-init-17.1.orig/tests/unittests/test_distros/test_netconfig.py 2018-03-26 19:22:35.717111557 +0200
|
||||
+++ cloud-init-17.1/tests/unittests/test_distros/test_netconfig.py 2018-03-26 22:08:25.008717651 +0200
|
||||
@@ -384,6 +384,82 @@ hn0: flags=8843<UP,BROADCAST,RUNNING,SIM
|
||||
buf.write(content)
|
||||
write_bufs[filename] = buf
|
||||
|
||||
+ def replace_load_file(filename, *args, **kwargs):
|
||||
+ if filename == '/etc/sysconfig/network':
|
||||
+ return 'TEST=yes\nTEST2=yes'
|
||||
+ else:
|
||||
+ return ''
|
||||
+
|
||||
+ with ExitStack() as mocks:
|
||||
+ mocks.enter_context(
|
||||
+ mock.patch.object(util, 'write_file', replace_write))
|
||||
+ mocks.enter_context(
|
||||
+ mock.patch.object(util, 'load_file', replace_load_file))
|
||||
+ mocks.enter_context(
|
||||
+ mock.patch.object(os.path, 'isfile', return_value=False))
|
||||
+
|
||||
+ rh_distro.apply_network(BASE_NET_CFG, False)
|
||||
+
|
||||
+ self.assertEqual(len(write_bufs), 4)
|
||||
+ self.assertIn('/etc/sysconfig/network-scripts/ifcfg-lo',
|
||||
+ write_bufs)
|
||||
+ write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-lo']
|
||||
+ expected_buf = '''
|
||||
+DEVICE="lo"
|
||||
+ONBOOT=yes
|
||||
+'''
|
||||
+ self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
+ self.assertEqual(write_buf.mode, 0o644)
|
||||
+
|
||||
+ self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth0',
|
||||
+ write_bufs)
|
||||
+ write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth0']
|
||||
+ expected_buf = '''
|
||||
+DEVICE="eth0"
|
||||
+BOOTPROTO="static"
|
||||
+NETMASK="255.255.255.0"
|
||||
+IPADDR="192.168.1.5"
|
||||
+ONBOOT=yes
|
||||
+GATEWAY="192.168.1.254"
|
||||
+BROADCAST="192.168.1.0"
|
||||
+'''
|
||||
+ self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
+ self.assertEqual(write_buf.mode, 0o644)
|
||||
+
|
||||
+ self.assertIn('/etc/sysconfig/network-scripts/ifcfg-eth1',
|
||||
+ write_bufs)
|
||||
+ write_buf = write_bufs['/etc/sysconfig/network-scripts/ifcfg-eth1']
|
||||
+ expected_buf = '''
|
||||
+DEVICE="eth1"
|
||||
+BOOTPROTO="dhcp"
|
||||
+ONBOOT=yes
|
||||
+'''
|
||||
+ self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
+ self.assertEqual(write_buf.mode, 0o644)
|
||||
+
|
||||
+ self.assertIn('/etc/sysconfig/network', write_bufs)
|
||||
+ write_buf = write_bufs['/etc/sysconfig/network']
|
||||
+ expected_buf = '''
|
||||
+# Created by cloud-init v. 0.7
|
||||
+NETWORKING=yes
|
||||
+TEST=yes
|
||||
+TEST2=yes
|
||||
+'''
|
||||
+ self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
+ self.assertEqual(write_buf.mode, 0o644)
|
||||
+
|
||||
+ def test_simple_write_rh_no_extra(self):
|
||||
+ rh_distro = self._get_distro('rhel')
|
||||
+
|
||||
+ write_bufs = {}
|
||||
+
|
||||
+ def replace_write(filename, content, mode=0o644, omode="wb"):
|
||||
+ buf = WriteBuffer()
|
||||
+ buf.mode = mode
|
||||
+ buf.omode = omode
|
||||
+ buf.write(content)
|
||||
+ write_bufs[filename] = buf
|
||||
+
|
||||
with ExitStack() as mocks:
|
||||
mocks.enter_context(
|
||||
mock.patch.object(util, 'write_file', replace_write))
|
||||
@@ -453,6 +529,12 @@ NETWORKING=yes
|
||||
buf.write(content)
|
||||
write_bufs[filename] = buf
|
||||
|
||||
+ def replace_load_file(filename, *args, **kwargs):
|
||||
+ if filename == '/etc/sysconfig/network':
|
||||
+ return 'TEST=yes\nTEST2=yes'
|
||||
+ else:
|
||||
+ return ''
|
||||
+
|
||||
with ExitStack() as mocks:
|
||||
# sysconfig availability checks
|
||||
mocks.enter_context(
|
||||
@@ -460,7 +542,7 @@ NETWORKING=yes
|
||||
mocks.enter_context(
|
||||
mock.patch.object(util, 'write_file', replace_write))
|
||||
mocks.enter_context(
|
||||
- mock.patch.object(util, 'load_file', return_value=''))
|
||||
+ mock.patch.object(util, 'load_file', replace_load_file))
|
||||
mocks.enter_context(
|
||||
mock.patch.object(os.path, 'isfile', return_value=True))
|
||||
|
||||
@@ -509,6 +591,8 @@ USERCTL=no
|
||||
expected_buf = '''
|
||||
# Created by cloud-init v. 0.7
|
||||
NETWORKING=yes
|
||||
+TEST=yes
|
||||
+TEST2=yes
|
||||
'''
|
||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
self.assertEqual(write_buf.mode, 0o644)
|
||||
@@ -525,13 +609,20 @@ NETWORKING=yes
|
||||
buf.write(content)
|
||||
write_bufs[filename] = buf
|
||||
|
||||
+ def replace_load_file(filename, *args, **kwargs):
|
||||
+ if filename == '/etc/sysconfig/network':
|
||||
+ return 'TEST=yes\nTEST2=yes'
|
||||
+ else:
|
||||
+ return ''
|
||||
+
|
||||
with ExitStack() as mocks:
|
||||
mocks.enter_context(
|
||||
mock.patch.object(util, 'write_file', replace_write))
|
||||
mocks.enter_context(
|
||||
- mock.patch.object(util, 'load_file', return_value=''))
|
||||
+ mock.patch.object(util, 'load_file', replace_load_file))
|
||||
mocks.enter_context(
|
||||
mock.patch.object(os.path, 'isfile', return_value=False))
|
||||
+
|
||||
rh_distro.apply_network(BASE_NET_CFG_IPV6, False)
|
||||
|
||||
self.assertEqual(len(write_bufs), 4)
|
||||
@@ -587,6 +678,8 @@ IPV6_DEFAULTGW="2607:f0d0:1002:0011::1"
|
||||
NETWORKING=yes
|
||||
NETWORKING_IPV6=yes
|
||||
IPV6_AUTOCONF=no
|
||||
+TEST=yes
|
||||
+TEST2=yes
|
||||
'''
|
||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
self.assertEqual(write_buf.mode, 0o644)
|
||||
@@ -604,13 +697,19 @@ IPV6_AUTOCONF=no
|
||||
buf.write(content)
|
||||
write_bufs[filename] = buf
|
||||
|
||||
+ def replace_load_file(filename, *args, **kwargs):
|
||||
+ if filename == '/etc/sysconfig/network':
|
||||
+ return 'TEST=yes\nTEST2=yes'
|
||||
+ else:
|
||||
+ return ''
|
||||
+
|
||||
with ExitStack() as mocks:
|
||||
mocks.enter_context(
|
||||
mock.patch.object(util, 'which', return_value=True))
|
||||
mocks.enter_context(
|
||||
mock.patch.object(util, 'write_file', replace_write))
|
||||
mocks.enter_context(
|
||||
- mock.patch.object(util, 'load_file', return_value=''))
|
||||
+ mock.patch.object(util, 'load_file', replace_load_file))
|
||||
mocks.enter_context(
|
||||
mock.patch.object(os.path, 'isfile', return_value=True))
|
||||
|
||||
@@ -658,6 +757,8 @@ USERCTL=no
|
||||
NETWORKING=yes
|
||||
NETWORKING_IPV6=yes
|
||||
IPV6_AUTOCONF=no
|
||||
+TEST=yes
|
||||
+TEST2=yes
|
||||
'''
|
||||
self.assertCfgEquals(expected_buf, str(write_buf))
|
||||
self.assertEqual(write_buf.mode, 0o644)
|
@ -1,6 +1,6 @@
|
||||
Name: cloud-init
|
||||
Version: 17.1
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: Cloud instance init scripts
|
||||
License: ASL 2.0 or GPLv3
|
||||
URL: http://launchpad.net/cloud-init
|
||||
@ -15,6 +15,10 @@ Patch1: cloud-init-17.1-disable-lxd-tests.patch
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1385172
|
||||
Patch2: cloud-init-17.1-nm-controlled.patch
|
||||
|
||||
# Keep old properties in /etc/sysconfig/network
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1558641
|
||||
Patch3: cloud-init-17.1-no-override-default-network.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: pkgconfig(systemd)
|
||||
@ -147,6 +151,9 @@ nosetests-%{python3_version} tests/unittests/
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Mar 26 2018 Patrick Uiterwijk <puiterwijk@redhat.com> - 17.1-3
|
||||
- Add patch to retain old values of /etc/sysconfig/network
|
||||
|
||||
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 17.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user