7fc49f
import cloud-init-0.7.9-9.el7_4.6
@@ -0,0 +1,164 @@
|
|
1
|
+
From 5fc5da29e5187ff6f56c968e7c06fabd1fce62ad Mon Sep 17 00:00:00 2001
|
2
|
+
From: Ryan McCabe <rmccabe@redhat.com>
|
3
|
+
Date: Thu, 8 Jun 2017 13:24:23 -0400
|
4
|
+
Subject: [PATCH] net: Allow for NetworkManager configuration
|
5
|
+
|
6
|
+
In cases where the config json specifies nameserver entries,
|
7
|
+
if there are interfaces configured to use dhcp, NetworkManager,
|
8
|
+
if enabled, will clobber the /etc/resolv.conf that cloud-init
|
9
|
+
has produced, which can break dns. If there are no interfaces
|
10
|
+
configured to use dhcp, NetworkManager could clobber
|
11
|
+
/etc/resolv.conf with an empty file.
|
12
|
+
|
13
|
+
This patch adds a mechanism for dropping additional configuration
|
14
|
+
into /etc/NetworkManager/conf.d/ and disables management of
|
15
|
+
/etc/resolv.conf by NetworkManager when nameserver information is
|
16
|
+
provided in the config.
|
17
|
+
|
18
|
+
LP: #1693251
|
19
|
+
|
20
|
+
Resolves: rhbz#1454491
|
21
|
+
|
22
|
+
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
23
|
+
(cherry picked from commit 67bab5bb804e2346673430868935f6bbcdb88f13)
|
24
|
+
---
|
25
|
+
cloudinit/distros/parsers/networkmanager_conf.py | 23 +++++++++++++++++++++++
|
26
|
+
cloudinit/net/sysconfig.py | 24 ++++++++++++++++++++++++
|
27
|
+
tests/unittests/test_net.py | 21 +++++++++++++++++++++
|
28
|
+
3 files changed, 68 insertions(+)
|
29
|
+
create mode 100644 cloudinit/distros/parsers/networkmanager_conf.py
|
30
|
+
|
31
|
+
diff --git a/cloudinit/distros/parsers/networkmanager_conf.py b/cloudinit/distros/parsers/networkmanager_conf.py
|
32
|
+
new file mode 100644
|
33
|
+
index 00000000..ac51f122
|
34
|
+
--- /dev/null
|
35
|
+
+++ b/cloudinit/distros/parsers/networkmanager_conf.py
|
36
|
+
|
37
|
+
+# Copyright (C) 2017 Red Hat, Inc.
|
38
|
+
+#
|
39
|
+
+# Author: Ryan McCabe <rmccabe@redhat.com>
|
40
|
+
+#
|
41
|
+
+# This file is part of cloud-init. See LICENSE file for license information.
|
42
|
+
+
|
43
|
+
+import configobj
|
44
|
+
+
|
45
|
+
+# This module is used to set additional NetworkManager configuration
|
46
|
+
+# in /etc/NetworkManager/conf.d
|
47
|
+
+#
|
48
|
+
+
|
49
|
+
+
|
50
|
+
+class NetworkManagerConf(configobj.ConfigObj):
|
51
|
+
+ def __init__(self, contents):
|
52
|
+
+ configobj.ConfigObj.__init__(self, contents,
|
53
|
+
+ interpolation=False,
|
54
|
+
+ write_empty_values=False)
|
55
|
+
+
|
56
|
+
+ def set_section_keypair(self, section_name, key, value):
|
57
|
+
+ if section_name not in self.sections:
|
58
|
+
+ self.main[section_name] = {}
|
59
|
+
+ self.main[section_name] = {key: value}
|
60
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
61
|
+
index ef80d99b..d496d916 100644
|
62
|
+
--- a/cloudinit/net/sysconfig.py
|
63
|
+
+++ b/cloudinit/net/sysconfig.py
|
64
|
+
@@ -5,6 +5,7 @@ import re
|
65
|
+
|
66
|
+
import six
|
67
|
+
|
68
|
+
+from cloudinit.distros.parsers import networkmanager_conf
|
69
|
+
from cloudinit.distros.parsers import resolv_conf
|
70
|
+
from cloudinit import util
|
71
|
+
|
72
|
+
@@ -250,6 +251,9 @@ class Renderer(renderer.Renderer):
|
73
|
+
self.netrules_path = config.get(
|
74
|
+
'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules')
|
75
|
+
self.dns_path = config.get('dns_path', 'etc/resolv.conf')
|
76
|
+
+ nm_conf_path = 'etc/NetworkManager/conf.d/99-cloud-init.conf'
|
77
|
+
+ self.networkmanager_conf_path = config.get('networkmanager_conf_path',
|
78
|
+
+ nm_conf_path)
|
79
|
+
|
80
|
+
@classmethod
|
81
|
+
def _render_iface_shared(cls, iface, iface_cfg):
|
82
|
+
@@ -443,6 +447,21 @@ class Renderer(renderer.Renderer):
|
83
|
+
content.add_search_domain(searchdomain)
|
84
|
+
return "\n".join([_make_header(';'), str(content)])
|
85
|
+
|
86
|
+
+ @staticmethod
|
87
|
+
+ def _render_networkmanager_conf(network_state):
|
88
|
+
+ content = networkmanager_conf.NetworkManagerConf("")
|
89
|
+
+
|
90
|
+
+ # If DNS server information is provided, configure
|
91
|
+
+ # NetworkManager to not manage dns, so that /etc/resolv.conf
|
92
|
+
+ # does not get clobbered.
|
93
|
+
+ if network_state.dns_nameservers:
|
94
|
+
+ content.set_section_keypair('main', 'dns', 'none')
|
95
|
+
+
|
96
|
+
+ if len(content) == 0:
|
97
|
+
+ return None
|
98
|
+
+ out = "".join([_make_header(), "\n", "\n".join(content.write()), "\n"])
|
99
|
+
+ return out
|
100
|
+
+
|
101
|
+
@classmethod
|
102
|
+
def _render_bridge_interfaces(cls, network_state, iface_contents):
|
103
|
+
bridge_filter = renderer.filter_by_type('bridge')
|
104
|
+
@@ -500,6 +519,11 @@ class Renderer(renderer.Renderer):
|
105
|
+
resolv_content = self._render_dns(network_state,
|
106
|
+
existing_dns_path=dns_path)
|
107
|
+
util.write_file(dns_path, resolv_content)
|
108
|
+
+ if self.networkmanager_conf_path:
|
109
|
+
+ nm_conf_path = os.path.join(target, self.networkmanager_conf_path)
|
110
|
+
+ nm_conf_content = self._render_networkmanager_conf(network_state)
|
111
|
+
+ if nm_conf_content:
|
112
|
+
+ util.write_file(nm_conf_path, nm_conf_content)
|
113
|
+
if self.netrules_path:
|
114
|
+
netrules_content = self._render_persistent_net(network_state)
|
115
|
+
netrules_path = os.path.join(target, self.netrules_path)
|
116
|
+
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
|
117
|
+
index 172d6046..379ac8bb 100755
|
118
|
+
--- a/tests/unittests/test_net.py
|
119
|
+
+++ b/tests/unittests/test_net.py
|
120
|
+
@@ -162,6 +162,13 @@ NETMASK0=0.0.0.0
|
121
|
+
;
|
122
|
+
nameserver 172.19.0.12
|
123
|
+
""".lstrip()),
|
124
|
+
+ ('etc/NetworkManager/conf.d/99-cloud-init.conf',
|
125
|
+
+ """
|
126
|
+
+# Created by cloud-init on instance boot automatically, do not edit.
|
127
|
+
+#
|
128
|
+
+[main]
|
129
|
+
+dns = none
|
130
|
+
+""".lstrip()),
|
131
|
+
('etc/udev/rules.d/70-persistent-net.rules',
|
132
|
+
"".join(['SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ',
|
133
|
+
'ATTR{address}=="fa:16:3e:ed:9a:59", NAME="eth0"\n']))]
|
134
|
+
@@ -222,6 +229,13 @@ USERCTL=no
|
135
|
+
;
|
136
|
+
nameserver 172.19.0.12
|
137
|
+
""".lstrip()),
|
138
|
+
+ ('etc/NetworkManager/conf.d/99-cloud-init.conf',
|
139
|
+
+ """
|
140
|
+
+# Created by cloud-init on instance boot automatically, do not edit.
|
141
|
+
+#
|
142
|
+
+[main]
|
143
|
+
+dns = none
|
144
|
+
+""".lstrip()),
|
145
|
+
('etc/udev/rules.d/70-persistent-net.rules',
|
146
|
+
"".join(['SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ',
|
147
|
+
'ATTR{address}=="fa:16:3e:ed:9a:59", NAME="eth0"\n']))]
|
148
|
+
@@ -304,6 +318,13 @@ USERCTL=no
|
149
|
+
;
|
150
|
+
nameserver 172.19.0.12
|
151
|
+
""".lstrip()),
|
152
|
+
+ ('etc/NetworkManager/conf.d/99-cloud-init.conf',
|
153
|
+
+ """
|
154
|
+
+# Created by cloud-init on instance boot automatically, do not edit.
|
155
|
+
+#
|
156
|
+
+[main]
|
157
|
+
+dns = none
|
158
|
+
+""".lstrip()),
|
159
|
+
('etc/udev/rules.d/70-persistent-net.rules',
|
160
|
+
"".join(['SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ',
|
161
|
+
'ATTR{address}=="fa:16:3e:ed:9a:59", NAME="eth0"\n']))]
|
162
|
+
--
|
163
|
+
2.13.6
|
164
|
+
|
@@ -0,0 +1,165 @@
|
|
1
|
+
From 4aa2305022e5d42d858102941c51d7186ef8fef9 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Scott Moser <smoser@brickies.net>
|
3
|
+
Date: Wed, 15 Mar 2017 12:06:40 -0400
|
4
|
+
Subject: [PATCH 1/3] support 'loopback' as a device type.
|
5
|
+
|
6
|
+
As reported in bug 1671927, sysconfig had an issue with rendering
|
7
|
+
a loopback device. The problem was that some as yet unknown issue was
|
8
|
+
causing the openstack config drive to parse the provided ENI file rather
|
9
|
+
than reading the network_data.json. Parsing an ENI file would add a
|
10
|
+
a 'lo' device of type 'physical', and sysconfig was failing to render
|
11
|
+
that.
|
12
|
+
|
13
|
+
The change here is:
|
14
|
+
a.) add a 'loopback' type rather than 'physical' for network config.
|
15
|
+
{'name': 'lo', 'type': 'loopback', 'subnets': ['type': 'loopback']}
|
16
|
+
b.) support skipping that type in the eni and sysconfig renderers.
|
17
|
+
c.) make network_state just piggy back on 'physical' renderer for
|
18
|
+
loopback (this was what was happening before).
|
19
|
+
|
20
|
+
Tests are added for eni and sysconfig renderer.
|
21
|
+
|
22
|
+
(cherry picked from commit 1a2ca7530518d819cbab7287b12f942743427e38)
|
23
|
+
|
24
|
+
Related: rhbz#1540094
|
25
|
+
---
|
26
|
+
cloudinit/net/eni.py | 16 +++++++++------
|
27
|
+
cloudinit/net/network_state.py | 4 ++++
|
28
|
+
cloudinit/net/sysconfig.py | 2 ++
|
29
|
+
tests/unittests/test_net.py | 44 ++++++++++++++++++++++++++++++++++++++++++
|
30
|
+
4 files changed, 60 insertions(+), 6 deletions(-)
|
31
|
+
|
32
|
+
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
|
33
|
+
index b06ffac9..0d5e9712 100644
|
34
|
+
--- a/cloudinit/net/eni.py
|
35
|
+
+++ b/cloudinit/net/eni.py
|
36
|
+
@@ -265,8 +265,11 @@ def _ifaces_to_net_config_data(ifaces):
|
37
|
+
# devname is 'eth0' for name='eth0:1'
|
38
|
+
devname = name.partition(":")[0]
|
39
|
+
if devname not in devs:
|
40
|
+
- devs[devname] = {'type': 'physical', 'name': devname,
|
41
|
+
- 'subnets': []}
|
42
|
+
+ if devname == "lo":
|
43
|
+
+ dtype = "loopback"
|
44
|
+
+ else:
|
45
|
+
+ dtype = "physical"
|
46
|
+
+ devs[devname] = {'type': dtype, 'name': devname, 'subnets': []}
|
47
|
+
# this isnt strictly correct, but some might specify
|
48
|
+
# hwaddress on a nic for matching / declaring name.
|
49
|
+
if 'hwaddress' in data:
|
50
|
+
@@ -418,10 +421,11 @@ class Renderer(renderer.Renderer):
|
51
|
+
bonding
|
52
|
+
'''
|
53
|
+
order = {
|
54
|
+
- 'physical': 0,
|
55
|
+
- 'bond': 1,
|
56
|
+
- 'bridge': 2,
|
57
|
+
- 'vlan': 3,
|
58
|
+
+ 'loopback': 0,
|
59
|
+
+ 'physical': 1,
|
60
|
+
+ 'bond': 2,
|
61
|
+
+ 'bridge': 3,
|
62
|
+
+ 'vlan': 4,
|
63
|
+
}
|
64
|
+
|
65
|
+
sections = []
|
66
|
+
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
|
67
|
+
index 11ef585b..90b2835a 100644
|
68
|
+
--- a/cloudinit/net/network_state.py
|
69
|
+
+++ b/cloudinit/net/network_state.py
|
70
|
+
@@ -211,6 +211,10 @@ class NetworkStateInterpreter(object):
|
71
|
+
exc_info=True)
|
72
|
+
LOG.debug(self.dump_network_state())
|
73
|
+
|
74
|
+
+ @ensure_command_keys(['name'])
|
75
|
+
+ def handle_loopback(self, command):
|
76
|
+
+ return self.handle_physical(command)
|
77
|
+
+
|
78
|
+
@ensure_command_keys(['name'])
|
79
|
+
def handle_physical(self, command):
|
80
|
+
'''
|
81
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
82
|
+
index efd101ca..25c29104 100644
|
83
|
+
--- a/cloudinit/net/sysconfig.py
|
84
|
+
+++ b/cloudinit/net/sysconfig.py
|
85
|
+
@@ -500,6 +500,8 @@ class Renderer(renderer.Renderer):
|
86
|
+
'''Given state, return /etc/sysconfig files + contents'''
|
87
|
+
iface_contents = {}
|
88
|
+
for iface in network_state.iter_interfaces():
|
89
|
+
+ if iface['type'] == "loopback":
|
90
|
+
+ continue
|
91
|
+
iface_name = iface['name']
|
92
|
+
iface_cfg = NetInterface(iface_name, base_sysconf_dir)
|
93
|
+
cls._render_iface_shared(iface, iface_cfg)
|
94
|
+
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
|
95
|
+
index ffa911cc..d75742be 100644
|
96
|
+
--- a/tests/unittests/test_net.py
|
97
|
+
+++ b/tests/unittests/test_net.py
|
98
|
+
@@ -600,6 +600,14 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
+CONFIG_V1_EXPLICIT_LOOPBACK = {
|
103
|
+
+ 'version': 1,
|
104
|
+
+ 'config': [{'name': 'eth0', 'type': 'physical',
|
105
|
+
+ 'subnets': [{'control': 'auto', 'type': 'dhcp'}]},
|
106
|
+
+ {'name': 'lo', 'type': 'loopback',
|
107
|
+
+ 'subnets': [{'control': 'auto', 'type': 'loopback'}]},
|
108
|
+
+ ]}
|
109
|
+
+
|
110
|
+
|
111
|
+
def _setup_test(tmp_dir, mock_get_devicelist, mock_read_sys_net,
|
112
|
+
mock_sys_dev_path):
|
113
|
+
@@ -770,6 +778,27 @@ USERCTL=no
|
114
|
+
with open(os.path.join(render_dir, fn)) as fh:
|
115
|
+
self.assertEqual(expected_content, fh.read())
|
116
|
+
|
117
|
+
+ def test_config_with_explicit_loopback(self):
|
118
|
+
+ ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
|
119
|
+
+ render_dir = self.tmp_path("render")
|
120
|
+
+ os.makedirs(render_dir)
|
121
|
+
+ renderer = sysconfig.Renderer()
|
122
|
+
+ renderer.render_network_state(render_dir, ns)
|
123
|
+
+ found = dir2dict(render_dir)
|
124
|
+
+ nspath = '/etc/sysconfig/network-scripts/'
|
125
|
+
+ self.assertNotIn(nspath + 'ifcfg-lo', found.keys())
|
126
|
+
+ expected = """\
|
127
|
+
+# Created by cloud-init on instance boot automatically, do not edit.
|
128
|
+
+#
|
129
|
+
+BOOTPROTO=dhcp
|
130
|
+
+DEVICE=eth0
|
131
|
+
+NM_CONTROLLED=no
|
132
|
+
+ONBOOT=yes
|
133
|
+
+TYPE=Ethernet
|
134
|
+
+USERCTL=no
|
135
|
+
+"""
|
136
|
+
+ self.assertEqual(expected, found[nspath + 'ifcfg-eth0'])
|
137
|
+
+
|
138
|
+
|
139
|
+
class TestEniNetRendering(TestCase):
|
140
|
+
|
141
|
+
@@ -811,6 +840,21 @@ iface eth1000 inet dhcp
|
142
|
+
"""
|
143
|
+
self.assertEqual(expected.lstrip(), contents.lstrip())
|
144
|
+
|
145
|
+
+ def test_config_with_explicit_loopback(self):
|
146
|
+
+ tmp_dir = self.tmp_dir()
|
147
|
+
+ ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
|
148
|
+
+ renderer = eni.Renderer()
|
149
|
+
+ renderer.render_network_state(tmp_dir, ns)
|
150
|
+
+ expected = """\
|
151
|
+
+auto lo
|
152
|
+
+iface lo inet loopback
|
153
|
+
+
|
154
|
+
+auto eth0
|
155
|
+
+iface eth0 inet dhcp
|
156
|
+
+"""
|
157
|
+
+ self.assertEqual(
|
158
|
+
+ expected, dir2dict(tmp_dir)['/etc/network/interfaces'])
|
159
|
+
+
|
160
|
+
|
161
|
+
class TestEniNetworkStateToEni(TestCase):
|
162
|
+
mycfg = {
|
163
|
+
--
|
164
|
+
2.14.3
|
165
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
From 6f9c05464a8ed420fb3e2ed71b401ecd1d772bad Mon Sep 17 00:00:00 2001
|
2
|
+
From: Ryan McCabe <rmccabe@redhat.com>
|
3
|
+
Date: Tue, 30 Jan 2018 12:37:00 -0500
|
4
|
+
Subject: [PATCH 2/3] Render the GATEWAY= value in interface files which have a
|
5
|
+
gateway in the subnet configuration.
|
6
|
+
|
7
|
+
Resolves: rhbz#1540094
|
8
|
+
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
9
|
+
---
|
10
|
+
cloudinit/net/sysconfig.py | 3 +++
|
11
|
+
1 file changed, 3 insertions(+)
|
12
|
+
|
13
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
14
|
+
index 25c29104..ca031691 100644
|
15
|
+
--- a/cloudinit/net/sysconfig.py
|
16
|
+
+++ b/cloudinit/net/sysconfig.py
|
17
|
+
@@ -347,6 +347,9 @@ class Renderer(renderer.Renderer):
|
18
|
+
iface_cfg['NETMASK' + str(ipv4_index)] = \
|
19
|
+
subnet['netmask']
|
20
|
+
|
21
|
+
+ if 'gateway' in subnet:
|
22
|
+
+ iface_cfg['GATEWAY'] = subnet['gateway']
|
23
|
+
+
|
24
|
+
@classmethod
|
25
|
+
def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
|
26
|
+
for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):
|
27
|
+
--
|
28
|
+
2.14.3
|
29
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
From 92ab19b85a1cdab73280b679c4a3bd0e32f3d2e2 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Ryan McCabe <rmccabe@redhat.com>
|
3
|
+
Date: Mon, 4 Dec 2017 13:43:30 -0500
|
4
|
+
Subject: [PATCH 3/3] sysconfig: Don't write BOOTPROTO=dhcp for ipv6 dhcp
|
5
|
+
|
6
|
+
Don't write BOOTPROTO=dhcp for ipv6 dhcp, as BOOTPROTO applies
|
7
|
+
only to ipv4. Explicitly write IPV6_AUTOCONF=no for dhcp on ipv6.
|
8
|
+
|
9
|
+
X-downstream-only: yes
|
10
|
+
|
11
|
+
Resolves: rhbz#1540093
|
12
|
+
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
13
|
+
(cherry picked from commit cbc09ba2f8e6fa967232039e6f6a3363d54ba592)
|
14
|
+
---
|
15
|
+
cloudinit/net/sysconfig.py | 2 +-
|
16
|
+
1 file changed, 1 insertion(+), 1 deletion(-)
|
17
|
+
|
18
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
19
|
+
index ca031691..09df76e3 100644
|
20
|
+
--- a/cloudinit/net/sysconfig.py
|
21
|
+
+++ b/cloudinit/net/sysconfig.py
|
22
|
+
@@ -287,7 +287,7 @@ class Renderer(renderer.Renderer):
|
23
|
+
if subnet_type == 'dhcp6':
|
24
|
+
iface_cfg['IPV6INIT'] = True
|
25
|
+
iface_cfg['DHCPV6C'] = True
|
26
|
+
- iface_cfg['BOOTPROTO'] = 'dhcp'
|
27
|
+
+ iface_cfg['IPV6_AUTOCONF'] = False
|
28
|
+
elif subnet_type in ['dhcp4', 'dhcp']:
|
29
|
+
iface_cfg['BOOTPROTO'] = 'dhcp'
|
30
|
+
elif subnet_type == 'static':
|
31
|
+
--
|
32
|
+
2.14.3
|
33
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
From 75fbba4601d09112615c342f88ef7b43fead0508 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Ryan McCabe <rmccabe@redhat.com>
|
3
|
+
Date: Fri, 2 Feb 2018 10:25:31 -0500
|
4
|
+
Subject: [PATCH] sysconfig: Render IPV6_DEFAULTGW correctly
|
5
|
+
|
6
|
+
Downstream backport of the fixes introduced in upstream commit
|
7
|
+
97abd83513bee191b58f095f4d683b18acce0b49 which will not apply to
|
8
|
+
the RHEL 0.7.9 tree.
|
9
|
+
|
10
|
+
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
11
|
+
Resolves: rhbz#1540094
|
12
|
+
---
|
13
|
+
cloudinit/net/sysconfig.py | 6 +++++-
|
14
|
+
tests/unittests/test_distros/test_netconfig.py | 4 ++++
|
15
|
+
2 files changed, 9 insertions(+), 1 deletion(-)
|
16
|
+
|
17
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
18
|
+
index 09df76e3..9975fe2c 100644
|
19
|
+
--- a/cloudinit/net/sysconfig.py
|
20
|
+
+++ b/cloudinit/net/sysconfig.py
|
21
|
+
@@ -348,7 +348,11 @@ class Renderer(renderer.Renderer):
|
22
|
+
subnet['netmask']
|
23
|
+
|
24
|
+
if 'gateway' in subnet:
|
25
|
+
- iface_cfg['GATEWAY'] = subnet['gateway']
|
26
|
+
+ iface_cfg['DEFROUTE'] = True
|
27
|
+
+ if ":" in subnet['gateway']:
|
28
|
+
+ iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
|
29
|
+
+ else:
|
30
|
+
+ iface_cfg['GATEWAY'] = subnet['gateway']
|
31
|
+
|
32
|
+
@classmethod
|
33
|
+
def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
|
34
|
+
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
|
35
|
+
index 861cf8ef..10e25a72 100644
|
36
|
+
--- a/tests/unittests/test_distros/test_netconfig.py
|
37
|
+
+++ b/tests/unittests/test_distros/test_netconfig.py
|
38
|
+
@@ -257,9 +257,11 @@ NETWORKING=yes
|
39
|
+
# Created by cloud-init on instance boot automatically, do not edit.
|
40
|
+
#
|
41
|
+
BOOTPROTO=none
|
42
|
+
+DEFROUTE=yes
|
43
|
+
DEVICE=eth0
|
44
|
+
IPADDR=192.168.1.5
|
45
|
+
NETMASK=255.255.255.0
|
46
|
+
+GATEWAY=192.168.1.254
|
47
|
+
ONBOOT=yes
|
48
|
+
TYPE=Ethernet
|
49
|
+
USERCTL=no
|
50
|
+
@@ -394,9 +396,11 @@ IPV6_AUTOCONF=no
|
51
|
+
# Created by cloud-init on instance boot automatically, do not edit.
|
52
|
+
#
|
53
|
+
BOOTPROTO=none
|
54
|
+
+DEFROUTE=yes
|
55
|
+
DEVICE=eth0
|
56
|
+
IPV6ADDR=2607:f0d0:1002:0011::2/64
|
57
|
+
IPV6INIT=yes
|
58
|
+
+IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
|
59
|
+
ONBOOT=yes
|
60
|
+
TYPE=Ethernet
|
61
|
+
USERCTL=no
|
62
|
+
--
|
63
|
+
2.14.3
|
64
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
From 6f54ccf28a327174df663ea2e07f32d7e632fddd Mon Sep 17 00:00:00 2001
|
2
|
+
From: Ryan McCabe <rmccabe@redhat.com>
|
3
|
+
Date: Thu, 15 Feb 2018 10:30:40 -0500
|
4
|
+
Subject: [PATCH] sysconfig: Render DNS and DOMAIN
|
5
|
+
|
6
|
+
Currently when dns and dns search info is provided, it is not
|
7
|
+
rendered when outputting to sysconfig format.
|
8
|
+
|
9
|
+
This patch causes the DNS and DOMAIN lines to be written out rendering
|
10
|
+
sysconfig.
|
11
|
+
|
12
|
+
This is a backport of upstream commit
|
13
|
+
bbe91cdc6917adb503b455e6860c21ea7b3f567f which will not apply to the
|
14
|
+
0.7.9 tree.
|
15
|
+
|
16
|
+
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
17
|
+
Resolves: rhbz#1545525
|
18
|
+
---
|
19
|
+
cloudinit/net/sysconfig.py | 17 +++++++++++++++++
|
20
|
+
tests/unittests/test_net.py | 8 +++++---
|
21
|
+
2 files changed, 22 insertions(+), 3 deletions(-)
|
22
|
+
|
23
|
+
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
|
24
|
+
index 9975fe2c..ec412512 100644
|
25
|
+
--- a/cloudinit/net/sysconfig.py
|
26
|
+
+++ b/cloudinit/net/sysconfig.py
|
27
|
+
@@ -354,6 +354,23 @@ class Renderer(renderer.Renderer):
|
28
|
+
else:
|
29
|
+
iface_cfg['GATEWAY'] = subnet['gateway']
|
30
|
+
|
31
|
+
+ if 'dns_search' in subnet:
|
32
|
+
+ if isinstance(subnet['dns_search'], (list, tuple)):
|
33
|
+
+ # Currently limited to 6 entries per resolv.conf(5)
|
34
|
+
+ search_list = subnet['dns_search'][:6]
|
35
|
+
+ iface_cfg['DOMAIN'] = ' '.join(search_list)
|
36
|
+
+ else:
|
37
|
+
+ iface_cfg['DOMAIN'] = subnet['dns_search']
|
38
|
+
+
|
39
|
+
+ if 'dns_nameservers' in subnet:
|
40
|
+
+ if isinstance(subnet['dns_nameservers'], (list, tuple)):
|
41
|
+
+ # Currently limited to 3 entries per resolv.conf(5)
|
42
|
+
+ dns_list = subnet['dns_nameservers'][:3]
|
43
|
+
+ for i, k in enumerate(dns_list, 1):
|
44
|
+
+ iface_cfg['DNS' + str(i)] = k
|
45
|
+
+ else:
|
46
|
+
+ iface_cfg['DNS1'] = subnet['dns_nameservers']
|
47
|
+
+
|
48
|
+
@classmethod
|
49
|
+
def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
|
50
|
+
for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):
|
51
|
+
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
|
52
|
+
index d75742be..f2a1998a 100644
|
53
|
+
--- a/tests/unittests/test_net.py
|
54
|
+
+++ b/tests/unittests/test_net.py
|
55
|
+
@@ -780,7 +780,9 @@ USERCTL=no
|
56
|
+
|
57
|
+
def test_config_with_explicit_loopback(self):
|
58
|
+
ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
|
59
|
+
- render_dir = self.tmp_path("render")
|
60
|
+
+ tmp_dir = tempfile.mkdtemp()
|
61
|
+
+ self.addCleanup(shutil.rmtree, tmp_dir)
|
62
|
+
+ render_dir = os.path.join(tmp_dir, "render")
|
63
|
+
os.makedirs(render_dir)
|
64
|
+
renderer = sysconfig.Renderer()
|
65
|
+
renderer.render_network_state(render_dir, ns)
|
66
|
+
@@ -792,7 +794,6 @@ USERCTL=no
|
67
|
+
#
|
68
|
+
BOOTPROTO=dhcp
|
69
|
+
DEVICE=eth0
|
70
|
+
-NM_CONTROLLED=no
|
71
|
+
ONBOOT=yes
|
72
|
+
TYPE=Ethernet
|
73
|
+
USERCTL=no
|
74
|
+
@@ -841,7 +842,8 @@ iface eth1000 inet dhcp
|
75
|
+
self.assertEqual(expected.lstrip(), contents.lstrip())
|
76
|
+
|
77
|
+
def test_config_with_explicit_loopback(self):
|
78
|
+
- tmp_dir = self.tmp_dir()
|
79
|
+
+ tmp_dir = tempfile.mkdtemp()
|
80
|
+
+ self.addCleanup(shutil.rmtree, tmp_dir)
|
81
|
+
ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
|
82
|
+
renderer = eni.Renderer()
|
83
|
+
renderer.render_network_state(tmp_dir, ns)
|
84
|
+
--
|
85
|
+
2.14.3
|
86
|
+
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
Name: cloud-init
|
9
9
|
Version: 0.7.9
|
10
|
-
Release: 9%{?dist}.
|
10
|
+
Release: 9%{?dist}.6
|
11
11
|
Summary: Cloud instance init scripts
|
12
12
|
|
13
13
|
Group: System Environment/Base
|
@@ -49,6 +49,13 @@ Patch0024: 0024-Identify-Brightbox-as-an-Ec2-datasource-user.patch
|
|
49
49
|
Patch0025: 0025-AliYun-Enable-platform-identification-and-enable-by-.patch
|
50
50
|
Patch0026: 0026-Fix-alibaba-cloud-unit-tests-to-work-with-0.7.9.patch
|
51
51
|
Patch0027: 0027-systemd-create-run-cloud-init-enabled.patch
|
52
|
+
Patch0028: 0028-net-Allow-for-NetworkManager-configuration.patch
|
53
|
+
Patch0029: 0029-support-loopback-as-a-device-type.patch
|
54
|
+
Patch0030: 0030-Render-the-GATEWAY-value-in-interface-files-which-ha.patch
|
55
|
+
Patch0031: 0031-sysconfig-Don-t-write-BOOTPROTO-dhcp-for-ipv6-dhcp.patch
|
56
|
+
Patch0032: 0032-sysconfig-Render-IPV6_DEFAULTGW-correctly.patch
|
57
|
+
Patch0033: 0033-sysconfig-Render-DNS-and-DOMAIN.patch
|
58
|
+
|
52
59
|
|
53
60
|
# Deal with noarch -> arch
|
54
61
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1067089
|
@@ -184,6 +191,25 @@ fi
|
|
184
191
|
%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf
|
185
192
|
|
186
193
|
%changelog
|
194
|
+
* Thu Feb 15 2018 Ryan McCabe <rmccabe@redhat.com> 0.7.9-9.6
|
195
|
+
- Correctly render DNS and DOMAIN for sysconfig
|
196
|
+
Resolves: rhbz#1545525
|
197
|
+
|
198
|
+
* Fri Feb 02 2018 Ryan McCabe <rmccabe@redhat.com> 0.7.9-9.5
|
199
|
+
- sysconfig: Fix rendering of default gateway for ipv6
|
200
|
+
Resolves: rhbz#1540094
|
201
|
+
|
202
|
+
* Tue Jan 30 2018 Ryan McCabe <rmccabe@redhat.com> 0.7.9-9.4
|
203
|
+
- sysconfig: Fix rendering of default gateway for ipv4
|
204
|
+
Resolves: rhbz#1540094
|
205
|
+
- sysconfig: Correct rendering for dhcp on ipv6
|
206
|
+
Resolves: rhbz#1540093
|
207
|
+
|
208
|
+
* Mon Jan 22 2018 Ryan McCabe <rmccabe@redhat.com> 0.7.9-9.3
|
209
|
+
- Disable NetworkManager management of resolv.conf if nameservers
|
210
|
+
are specified by configuration.
|
211
|
+
Resolves: rhbz#1537439
|
212
|
+
|
187
213
|
* Thu Dec 21 2017 Ryan McCabe <rmccabe@redhat.com> 0.7.9-9.2
|
188
214
|
- Prevent Azure NM and dhclient hooks from running when cloud-init is
|
189
215
|
disabled (rhbz#1530127)
|