Merge ~daniel-thewatkins/cloud-init/+git/cloud-init:networking into cloud-init:master

Proposed by Dan Watkins on 2019-07-23
Status: Merged
Approved by: Dan Watkins on 2019-07-26
Approved revision: 48a55ca3a3bf064c942a91e86de2761b6324ac88
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~daniel-thewatkins/cloud-init/+git/cloud-init:networking
Merge into: cloud-init:master
Diff against target: 446 lines (+112/-51)
7 files modified
cloudinit/net/cmdline.py (+16/-9)
cloudinit/sources/DataSourceOracle.py (+4/-6)
cloudinit/sources/__init__.py (+2/-1)
cloudinit/sources/tests/test_oracle.py (+9/-10)
cloudinit/stages.py (+1/-0)
cloudinit/tests/test_stages.py (+69/-14)
tests/unittests/test_net.py (+11/-11)
Reviewer Review Type Date Requested Status
Ryan Harper 2019-07-23 Approve on 2019-07-26
Server Team CI bot continuous-integration Approve on 2019-07-23
Review via email: mp+370526@code.launchpad.net

Commit message

net/cmdline: split interfaces_by_mac and init network config determination

Previously "cmdline" network configuration could be either
user-specified network-config=... configuration data, or
initramfs-provided configuration data. Before data sources could modify
the order in which network config sources were considered, this
conflation didn't matter (and, indeed, in the default data source
configuration it will continue to not matter).

However, it _is_ desirable for a data source to be able to specify that
its network configuration should be preferred over the
initramfs-provided network configuration but still allow explicit
network-config=... configuration passed to the kernel cmdline to
continue to override both of those sources.

(This also modifies the Oracle data source to use read_initramfs_config
directly, which is effectively what it was using
read_kernel_cmdline_config for previously.)

To post a comment you must log in.

PASSED: Continuous integration, rev:48a55ca3a3bf064c942a91e86de2761b6324ac88
https://jenkins.ubuntu.com/server/job/cloud-init-ci/800/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/800/rebuild

review: Approve (continuous-integration)
Ryan Harper (raharper) wrote :

Nice clean-up. One question inline around the mock used, otherwise fine.

Ryan Harper (raharper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
2index f89a0f7..556a10f 100755
3--- a/cloudinit/net/cmdline.py
4+++ b/cloudinit/net/cmdline.py
5@@ -177,21 +177,13 @@ def _is_initramfs_netconfig(files, cmdline):
6 return False
7
8
9-def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None):
10+def read_initramfs_config(files=None, mac_addrs=None, cmdline=None):
11 if cmdline is None:
12 cmdline = util.get_cmdline()
13
14 if files is None:
15 files = _get_klibc_net_cfg_files()
16
17- if 'network-config=' in cmdline:
18- data64 = None
19- for tok in cmdline.split():
20- if tok.startswith("network-config="):
21- data64 = tok.split("=", 1)[1]
22- if data64:
23- return util.load_yaml(_b64dgz(data64))
24-
25 if not _is_initramfs_netconfig(files, cmdline):
26 return None
27
28@@ -204,4 +196,19 @@ def read_kernel_cmdline_config(files=None, mac_addrs=None, cmdline=None):
29
30 return config_from_klibc_net_cfg(files=files, mac_addrs=mac_addrs)
31
32+
33+def read_kernel_cmdline_config(cmdline=None):
34+ if cmdline is None:
35+ cmdline = util.get_cmdline()
36+
37+ if 'network-config=' in cmdline:
38+ data64 = None
39+ for tok in cmdline.split():
40+ if tok.startswith("network-config="):
41+ data64 = tok.split("=", 1)[1]
42+ if data64:
43+ return util.load_yaml(_b64dgz(data64))
44+
45+ return None
46+
47 # vi: ts=4 expandtab
48diff --git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py
49index 70b9c58..76cfa38 100644
50--- a/cloudinit/sources/DataSourceOracle.py
51+++ b/cloudinit/sources/DataSourceOracle.py
52@@ -48,7 +48,7 @@ class DataSourceOracle(sources.DataSource):
53 return False
54
55 # network may be configured if iscsi root. If that is the case
56- # then read_kernel_cmdline_config will return non-None.
57+ # then read_initramfs_config will return non-None.
58 if _is_iscsi_root():
59 data = self.crawl_metadata()
60 else:
61@@ -118,10 +118,8 @@ class DataSourceOracle(sources.DataSource):
62 We nonetheless return cmdline provided config if present
63 and fallback to generate fallback."""
64 if self._network_config == sources.UNSET:
65- cmdline_cfg = cmdline.read_kernel_cmdline_config()
66- if cmdline_cfg:
67- self._network_config = cmdline_cfg
68- else:
69+ self._network_config = cmdline.read_initramfs_config()
70+ if not self._network_config:
71 self._network_config = self.distro.generate_fallback_config()
72 return self._network_config
73
74@@ -137,7 +135,7 @@ def _is_platform_viable():
75
76
77 def _is_iscsi_root():
78- return bool(cmdline.read_kernel_cmdline_config())
79+ return bool(cmdline.read_initramfs_config())
80
81
82 def _load_index(content):
83diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
84index 9d24936..c2baccd 100644
85--- a/cloudinit/sources/__init__.py
86+++ b/cloudinit/sources/__init__.py
87@@ -69,7 +69,7 @@ CLOUD_ID_REGION_PREFIX_MAP = {
88 # NetworkConfigSource represents the canonical list of network config sources
89 # that cloud-init knows about. (Python 2.7 lacks PEP 435, so use a singleton
90 # namedtuple as an enum; see https://stackoverflow.com/a/6971002)
91-_NETCFG_SOURCE_NAMES = ('cmdline', 'ds', 'system_cfg', 'fallback')
92+_NETCFG_SOURCE_NAMES = ('cmdline', 'ds', 'system_cfg', 'fallback', 'initramfs')
93 NetworkConfigSource = namedtuple('NetworkConfigSource',
94 _NETCFG_SOURCE_NAMES)(*_NETCFG_SOURCE_NAMES)
95
96@@ -166,6 +166,7 @@ class DataSource(object):
97 # should always be a subset of the members of NetworkConfigSource with no
98 # duplicate entries.
99 network_config_sources = (NetworkConfigSource.cmdline,
100+ NetworkConfigSource.initramfs,
101 NetworkConfigSource.system_cfg,
102 NetworkConfigSource.ds)
103
104diff --git a/cloudinit/sources/tests/test_oracle.py b/cloudinit/sources/tests/test_oracle.py
105index 97d6294..282382c 100644
106--- a/cloudinit/sources/tests/test_oracle.py
107+++ b/cloudinit/sources/tests/test_oracle.py
108@@ -133,9 +133,9 @@ class TestDataSourceOracle(test_helpers.CiTestCase):
109 self.assertEqual(self.my_md['uuid'], ds.get_instance_id())
110 self.assertEqual(my_userdata, ds.userdata_raw)
111
112- @mock.patch(DS_PATH + ".cmdline.read_kernel_cmdline_config")
113+ @mock.patch(DS_PATH + ".cmdline.read_initramfs_config")
114 @mock.patch(DS_PATH + "._is_iscsi_root", return_value=True)
115- def test_network_cmdline(self, m_is_iscsi_root, m_cmdline_config):
116+ def test_network_cmdline(self, m_is_iscsi_root, m_initramfs_config):
117 """network_config should read kernel cmdline."""
118 distro = mock.MagicMock()
119 ds, _ = self._get_ds(distro=distro, patches={
120@@ -145,15 +145,15 @@ class TestDataSourceOracle(test_helpers.CiTestCase):
121 MD_VER: {'system_uuid': self.my_uuid,
122 'meta_data': self.my_md}}}})
123 ncfg = {'version': 1, 'config': [{'a': 'b'}]}
124- m_cmdline_config.return_value = ncfg
125+ m_initramfs_config.return_value = ncfg
126 self.assertTrue(ds._get_data())
127 self.assertEqual(ncfg, ds.network_config)
128- m_cmdline_config.assert_called_once_with()
129+ self.assertEqual([mock.call()], m_initramfs_config.call_args_list)
130 self.assertFalse(distro.generate_fallback_config.called)
131
132- @mock.patch(DS_PATH + ".cmdline.read_kernel_cmdline_config")
133+ @mock.patch(DS_PATH + ".cmdline.read_initramfs_config")
134 @mock.patch(DS_PATH + "._is_iscsi_root", return_value=True)
135- def test_network_fallback(self, m_is_iscsi_root, m_cmdline_config):
136+ def test_network_fallback(self, m_is_iscsi_root, m_initramfs_config):
137 """test that fallback network is generated if no kernel cmdline."""
138 distro = mock.MagicMock()
139 ds, _ = self._get_ds(distro=distro, patches={
140@@ -163,18 +163,17 @@ class TestDataSourceOracle(test_helpers.CiTestCase):
141 MD_VER: {'system_uuid': self.my_uuid,
142 'meta_data': self.my_md}}}})
143 ncfg = {'version': 1, 'config': [{'a': 'b'}]}
144- m_cmdline_config.return_value = None
145+ m_initramfs_config.return_value = None
146 self.assertTrue(ds._get_data())
147 ncfg = {'version': 1, 'config': [{'distro1': 'value'}]}
148 distro.generate_fallback_config.return_value = ncfg
149 self.assertEqual(ncfg, ds.network_config)
150- m_cmdline_config.assert_called_once_with()
151+ self.assertEqual([mock.call()], m_initramfs_config.call_args_list)
152 distro.generate_fallback_config.assert_called_once_with()
153- self.assertEqual(1, m_cmdline_config.call_count)
154
155 # test that the result got cached, and the methods not re-called.
156 self.assertEqual(ncfg, ds.network_config)
157- self.assertEqual(1, m_cmdline_config.call_count)
158+ self.assertEqual(1, m_initramfs_config.call_count)
159
160
161 @mock.patch(DS_PATH + "._read_system_uuid", return_value=str(uuid.uuid4()))
162diff --git a/cloudinit/stages.py b/cloudinit/stages.py
163index 6bcda2d..5012988 100644
164--- a/cloudinit/stages.py
165+++ b/cloudinit/stages.py
166@@ -633,6 +633,7 @@ class Init(object):
167
168 available_cfgs = {
169 NetworkConfigSource.cmdline: cmdline.read_kernel_cmdline_config(),
170+ NetworkConfigSource.initramfs: cmdline.read_initramfs_config(),
171 NetworkConfigSource.ds: None,
172 NetworkConfigSource.system_cfg: self.cfg.get('network'),
173 }
174diff --git a/cloudinit/tests/test_stages.py b/cloudinit/tests/test_stages.py
175index 7e13e29..d5c9c0e 100644
176--- a/cloudinit/tests/test_stages.py
177+++ b/cloudinit/tests/test_stages.py
178@@ -59,20 +59,39 @@ class TestInit(CiTestCase):
179 (None, disable_file),
180 self.init._find_networking_config())
181
182+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
183 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
184- def test_wb__find_networking_config_disabled_by_kernel(self, m_cmdline):
185+ def test_wb__find_networking_config_disabled_by_kernel(
186+ self, m_cmdline, m_initramfs):
187 """find_networking_config returns when disabled by kernel cmdline."""
188 m_cmdline.return_value = {'config': 'disabled'}
189+ m_initramfs.return_value = {'config': ['fake_initrd']}
190 self.assertEqual(
191 (None, NetworkConfigSource.cmdline),
192 self.init._find_networking_config())
193 self.assertEqual('DEBUG: network config disabled by cmdline\n',
194 self.logs.getvalue())
195
196+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
197 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
198- def test_wb__find_networking_config_disabled_by_datasrc(self, m_cmdline):
199+ def test_wb__find_networking_config_disabled_by_initrd(
200+ self, m_cmdline, m_initramfs):
201+ """find_networking_config returns when disabled by kernel cmdline."""
202+ m_cmdline.return_value = {}
203+ m_initramfs.return_value = {'config': 'disabled'}
204+ self.assertEqual(
205+ (None, NetworkConfigSource.initramfs),
206+ self.init._find_networking_config())
207+ self.assertEqual('DEBUG: network config disabled by initramfs\n',
208+ self.logs.getvalue())
209+
210+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
211+ @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
212+ def test_wb__find_networking_config_disabled_by_datasrc(
213+ self, m_cmdline, m_initramfs):
214 """find_networking_config returns when disabled by datasource cfg."""
215 m_cmdline.return_value = {} # Kernel doesn't disable networking
216+ m_initramfs.return_value = {} # initramfs doesn't disable networking
217 self.init._cfg = {'system_info': {'paths': {'cloud_dir': self.tmpdir}},
218 'network': {}} # system config doesn't disable
219
220@@ -84,10 +103,13 @@ class TestInit(CiTestCase):
221 self.assertEqual('DEBUG: network config disabled by ds\n',
222 self.logs.getvalue())
223
224+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
225 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
226- def test_wb__find_networking_config_disabled_by_sysconfig(self, m_cmdline):
227+ def test_wb__find_networking_config_disabled_by_sysconfig(
228+ self, m_cmdline, m_initramfs):
229 """find_networking_config returns when disabled by system config."""
230 m_cmdline.return_value = {} # Kernel doesn't disable networking
231+ m_initramfs.return_value = {} # initramfs doesn't disable networking
232 self.init._cfg = {'system_info': {'paths': {'cloud_dir': self.tmpdir}},
233 'network': {'config': 'disabled'}}
234 self.assertEqual(
235@@ -96,27 +118,31 @@ class TestInit(CiTestCase):
236 self.assertEqual('DEBUG: network config disabled by system_cfg\n',
237 self.logs.getvalue())
238
239+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
240 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
241- def test__find_networking_config_uses_datasrc_order(self, m_cmdline):
242+ def test__find_networking_config_uses_datasrc_order(
243+ self, m_cmdline, m_initramfs):
244 """find_networking_config should check sources in DS defined order"""
245- # cmdline, which would normally be preferred over other sources,
246- # disables networking; in this case, though, the DS moves cmdline later
247- # so its own config is preferred
248+ # cmdline and initramfs, which would normally be preferred over other
249+ # sources, disable networking; in this case, though, the DS moves them
250+ # later so its own config is preferred
251 m_cmdline.return_value = {'config': 'disabled'}
252+ m_initramfs.return_value = {'config': 'disabled'}
253
254 ds_net_cfg = {'config': {'needle': True}}
255 self.init.datasource = FakeDataSource(network_config=ds_net_cfg)
256 self.init.datasource.network_config_sources = [
257 NetworkConfigSource.ds, NetworkConfigSource.system_cfg,
258- NetworkConfigSource.cmdline]
259+ NetworkConfigSource.cmdline, NetworkConfigSource.initramfs]
260
261 self.assertEqual(
262 (ds_net_cfg, NetworkConfigSource.ds),
263 self.init._find_networking_config())
264
265+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
266 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
267 def test__find_networking_config_warns_if_datasrc_uses_invalid_src(
268- self, m_cmdline):
269+ self, m_cmdline, m_initramfs):
270 """find_networking_config should check sources in DS defined order"""
271 ds_net_cfg = {'config': {'needle': True}}
272 self.init.datasource = FakeDataSource(network_config=ds_net_cfg)
273@@ -130,9 +156,10 @@ class TestInit(CiTestCase):
274 ' cfg_source: invalid_src',
275 self.logs.getvalue())
276
277+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
278 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
279 def test__find_networking_config_warns_if_datasrc_uses_unavailable_src(
280- self, m_cmdline):
281+ self, m_cmdline, m_initramfs):
282 """find_networking_config should check sources in DS defined order"""
283 ds_net_cfg = {'config': {'needle': True}}
284 self.init.datasource = FakeDataSource(network_config=ds_net_cfg)
285@@ -146,11 +173,14 @@ class TestInit(CiTestCase):
286 ' cfg_source: fallback',
287 self.logs.getvalue())
288
289+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
290 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
291- def test_wb__find_networking_config_returns_kernel(self, m_cmdline):
292+ def test_wb__find_networking_config_returns_kernel(
293+ self, m_cmdline, m_initramfs):
294 """find_networking_config returns kernel cmdline config if present."""
295 expected_cfg = {'config': ['fakekernel']}
296 m_cmdline.return_value = expected_cfg
297+ m_initramfs.return_value = {'config': ['fake_initrd']}
298 self.init._cfg = {'system_info': {'paths': {'cloud_dir': self.tmpdir}},
299 'network': {'config': ['fakesys_config']}}
300 self.init.datasource = FakeDataSource(
301@@ -159,10 +189,29 @@ class TestInit(CiTestCase):
302 (expected_cfg, NetworkConfigSource.cmdline),
303 self.init._find_networking_config())
304
305+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
306+ @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
307+ def test_wb__find_networking_config_returns_initramfs(
308+ self, m_cmdline, m_initramfs):
309+ """find_networking_config returns kernel cmdline config if present."""
310+ expected_cfg = {'config': ['fake_initrd']}
311+ m_cmdline.return_value = {}
312+ m_initramfs.return_value = expected_cfg
313+ self.init._cfg = {'system_info': {'paths': {'cloud_dir': self.tmpdir}},
314+ 'network': {'config': ['fakesys_config']}}
315+ self.init.datasource = FakeDataSource(
316+ network_config={'config': ['fakedatasource']})
317+ self.assertEqual(
318+ (expected_cfg, NetworkConfigSource.initramfs),
319+ self.init._find_networking_config())
320+
321+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
322 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
323- def test_wb__find_networking_config_returns_system_cfg(self, m_cmdline):
324+ def test_wb__find_networking_config_returns_system_cfg(
325+ self, m_cmdline, m_initramfs):
326 """find_networking_config returns system config when present."""
327 m_cmdline.return_value = {} # No kernel network config
328+ m_initramfs.return_value = {} # no initramfs network config
329 expected_cfg = {'config': ['fakesys_config']}
330 self.init._cfg = {'system_info': {'paths': {'cloud_dir': self.tmpdir}},
331 'network': expected_cfg}
332@@ -172,10 +221,13 @@ class TestInit(CiTestCase):
333 (expected_cfg, NetworkConfigSource.system_cfg),
334 self.init._find_networking_config())
335
336+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
337 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
338- def test_wb__find_networking_config_returns_datasrc_cfg(self, m_cmdline):
339+ def test_wb__find_networking_config_returns_datasrc_cfg(
340+ self, m_cmdline, m_initramfs):
341 """find_networking_config returns datasource net config if present."""
342 m_cmdline.return_value = {} # No kernel network config
343+ m_initramfs.return_value = {} # no initramfs network config
344 # No system config for network in setUp
345 expected_cfg = {'config': ['fakedatasource']}
346 self.init.datasource = FakeDataSource(network_config=expected_cfg)
347@@ -183,10 +235,13 @@ class TestInit(CiTestCase):
348 (expected_cfg, NetworkConfigSource.ds),
349 self.init._find_networking_config())
350
351+ @mock.patch('cloudinit.stages.cmdline.read_initramfs_config')
352 @mock.patch('cloudinit.stages.cmdline.read_kernel_cmdline_config')
353- def test_wb__find_networking_config_returns_fallback(self, m_cmdline):
354+ def test_wb__find_networking_config_returns_fallback(
355+ self, m_cmdline, m_initramfs):
356 """find_networking_config returns fallback config if not defined."""
357 m_cmdline.return_value = {} # Kernel doesn't disable networking
358+ m_initramfs.return_value = {} # no initramfs network config
359 # Neither datasource nor system_info disable or provide network
360
361 fake_cfg = {'config': [{'type': 'physical', 'name': 'eth9'}],
362diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
363index e2bbb84..1840ade 100644
364--- a/tests/unittests/test_net.py
365+++ b/tests/unittests/test_net.py
366@@ -3558,13 +3558,13 @@ class TestCmdlineConfigParsing(CiTestCase):
367 self.assertEqual(found, self.simple_cfg)
368
369
370-class TestCmdlineReadKernelConfig(FilesystemMockingTestCase):
371+class TestCmdlineReadInitramfsConfig(FilesystemMockingTestCase):
372 macs = {
373 'eth0': '14:02:ec:42:48:00',
374 'eno1': '14:02:ec:42:48:01',
375 }
376
377- def test_ip_cmdline_without_ip(self):
378+ def test_without_ip(self):
379 content = {'/run/net-eth0.conf': DHCP_CONTENT_1,
380 cmdline._OPEN_ISCSI_INTERFACE_FILE: "eth0\n"}
381 exp1 = copy.deepcopy(DHCP_EXPECTED_1)
382@@ -3574,12 +3574,12 @@ class TestCmdlineReadKernelConfig(FilesystemMockingTestCase):
383 populate_dir(root, content)
384 self.reRoot(root)
385
386- found = cmdline.read_kernel_cmdline_config(
387+ found = cmdline.read_initramfs_config(
388 cmdline='foo root=/root/bar', mac_addrs=self.macs)
389 self.assertEqual(found['version'], 1)
390 self.assertEqual(found['config'], [exp1])
391
392- def test_ip_cmdline_read_kernel_cmdline_ip(self):
393+ def test_with_ip(self):
394 content = {'/run/net-eth0.conf': DHCP_CONTENT_1}
395 exp1 = copy.deepcopy(DHCP_EXPECTED_1)
396 exp1['mac_address'] = self.macs['eth0']
397@@ -3588,18 +3588,18 @@ class TestCmdlineReadKernelConfig(FilesystemMockingTestCase):
398 populate_dir(root, content)
399 self.reRoot(root)
400
401- found = cmdline.read_kernel_cmdline_config(
402+ found = cmdline.read_initramfs_config(
403 cmdline='foo ip=dhcp', mac_addrs=self.macs)
404 self.assertEqual(found['version'], 1)
405 self.assertEqual(found['config'], [exp1])
406
407- def test_ip_cmdline_read_kernel_cmdline_ip6(self):
408+ def test_with_ip6(self):
409 content = {'/run/net6-eno1.conf': DHCP6_CONTENT_1}
410 root = self.tmp_dir()
411 populate_dir(root, content)
412 self.reRoot(root)
413
414- found = cmdline.read_kernel_cmdline_config(
415+ found = cmdline.read_initramfs_config(
416 cmdline='foo ip6=dhcp root=/dev/sda',
417 mac_addrs=self.macs)
418 self.assertEqual(
419@@ -3611,15 +3611,15 @@ class TestCmdlineReadKernelConfig(FilesystemMockingTestCase):
420 {'dns_nameservers': ['2001:67c:1562:8010::2:1'],
421 'control': 'manual', 'type': 'dhcp6', 'netmask': '64'}]}]})
422
423- def test_ip_cmdline_read_kernel_cmdline_none(self):
424+ def test_with_no_ip_or_ip6(self):
425 # if there is no ip= or ip6= on cmdline, return value should be None
426 content = {'net6-eno1.conf': DHCP6_CONTENT_1}
427 files = sorted(populate_dir(self.tmp_dir(), content))
428- found = cmdline.read_kernel_cmdline_config(
429+ found = cmdline.read_initramfs_config(
430 files=files, cmdline='foo root=/dev/sda', mac_addrs=self.macs)
431 self.assertIsNone(found)
432
433- def test_ip_cmdline_both_ip_ip6(self):
434+ def test_with_both_ip_ip6(self):
435 content = {
436 '/run/net-eth0.conf': DHCP_CONTENT_1,
437 '/run/net6-eth0.conf': DHCP6_CONTENT_1.replace('eno1', 'eth0')}
438@@ -3634,7 +3634,7 @@ class TestCmdlineReadKernelConfig(FilesystemMockingTestCase):
439 populate_dir(root, content)
440 self.reRoot(root)
441
442- found = cmdline.read_kernel_cmdline_config(
443+ found = cmdline.read_initramfs_config(
444 cmdline='foo ip=dhcp ip6=dhcp', mac_addrs=self.macs)
445
446 self.assertEqual(found['version'], 1)

Subscribers

People subscribed via source and target branches