Merge lp:~raharper/curtin/trunk.fix-lp1536262 into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Merged
Merged at revision: 356
Proposed branch: lp:~raharper/curtin/trunk.fix-lp1536262
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 125 lines (+52/-8)
4 files modified
curtin/net/__init__.py (+5/-4)
examples/tests/basic_network_static.yaml (+17/-0)
tests/unittests/test_net.py (+5/-4)
tests/vmtests/test_network.py (+25/-0)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.fix-lp1536262
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+284053@code.launchpad.net

Commit message

curtin/net: move global dns-* options under auto lo in ENI

ifupdown expects any dns-* options to be related to an iface stanza
The only iface ensured to be called with ifup is lo; moving the dns-*
parameters under iface lo allows dns options to always be present even
if other interfaces are not ifup'ed.

Update unittests and add new vmtest (TestNetworkStatic) to confirm
proper configuration under lo iface.

Description of the change

curtin/net: move global dns-* options under auto lo in ENI

ifupdown expects any dns-* options to be related to an iface stanza
The only iface ensured to be called with ifup is lo; moving the dns-*
parameters under iface lo allows dns options to always be present even
if other interfaces are not ifup'ed.

Update unittests and add new vmtest (TestNetworkStatic) to confirm
proper configuration under lo iface.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

This looks good.
I'm ok to only run the wily or trusty test.
Since we have unit test coverage on the expected behavior.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/net/__init__.py'
2--- curtin/net/__init__.py 2015-09-17 15:07:04 +0000
3+++ curtin/net/__init__.py 2016-01-27 03:25:06 +0000
4@@ -335,6 +335,11 @@
5 'bridge': 2,
6 'vlan': 3,
7 }
8+ content += "auto lo\niface lo inet loopback\n"
9+ for dnskey, value in network_state.get('dns', {}).items():
10+ if len(value):
11+ content += " dns-{} {}\n".format(dnskey, " ".join(value))
12+
13 for iface in sorted(interfaces.values(),
14 key=lambda k: (order[k['type']], k['name'])):
15 content += "auto {name}\n".format(**iface)
16@@ -366,10 +371,6 @@
17 content += iface_add_attrs(iface)
18 content += "\n"
19
20- for dnskey, value in network_state.get('dns', {}).items():
21- if len(value):
22- content += "dns-{} {}\n".format(dnskey, " ".join(value))
23-
24 for route in network_state.get('routes'):
25 content += render_route(route)
26
27
28=== added file 'examples/tests/basic_network_static.yaml'
29--- examples/tests/basic_network_static.yaml 1970-01-01 00:00:00 +0000
30+++ examples/tests/basic_network_static.yaml 2016-01-27 03:25:06 +0000
31@@ -0,0 +1,17 @@
32+network:
33+ version: 1
34+ config:
35+ # Physical interfaces.
36+ - type: physical
37+ name: eth0
38+ mac_address: "52:54:00:12:34:00"
39+ subnets:
40+ - type: static
41+ address: 10.0.2.15/24
42+ gateway: 10.0.2.2
43+ - type: nameserver
44+ address:
45+ - 10.0.2.3
46+ search:
47+ - wark.maas
48+ - foobar.maas
49
50=== modified file 'tests/unittests/test_net.py'
51--- tests/unittests/test_net.py 2015-09-17 15:07:04 +0000
52+++ tests/unittests/test_net.py 2016-01-27 03:25:06 +0000
53@@ -320,15 +320,16 @@
54
55 def test_render_interfaces(self):
56 ns = self.get_net_state()
57- ifaces = ('auto eth0\n' + 'iface eth0 inet dhcp\n\n' +
58+ ifaces = ('auto lo\n' + 'iface lo inet loopback\n' +
59+ ' dns-nameservers 1.2.3.4 5.6.7.8\n' +
60+ ' dns-search wark.maas\n' +
61+ 'auto eth0\n' + 'iface eth0 inet dhcp\n\n' +
62 'auto eth0:1\n' +
63 'iface eth0:1 inet static\n' +
64 ' address 192.168.21.3/24\n' +
65 ' dns-nameservers 8.8.8.8 8.8.4.4\n' +
66 ' dns-search barley.maas sach.maas\n\n' +
67- 'auto eth1\n' + 'iface eth1 inet manual\n\n' +
68- 'dns-nameservers 1.2.3.4 5.6.7.8\n' +
69- 'dns-search wark.maas\n')
70+ 'auto eth1\n' + 'iface eth1 inet manual\n\n')
71 net_ifaces = net.render_interfaces(ns.network_state)
72 print(ns.network_state.get('interfaces'))
73 self.assertEqual(sorted(ifaces.split('\n')),
74
75=== modified file 'tests/vmtests/test_network.py'
76--- tests/vmtests/test_network.py 2015-12-17 22:07:00 +0000
77+++ tests/vmtests/test_network.py 2016-01-27 03:25:06 +0000
78@@ -235,18 +235,34 @@
79 self.assertEqual(gw_ip, gw)
80
81
82+class TestNetworkStaticAbs(TestNetworkAbs):
83+ conf_file = "examples/tests/basic_network_static.yaml"
84+
85+
86 class TrustyTestNetwork(relbase.trusty, TestNetworkAbs):
87 __test__ = True
88
89
90+class TrustyTestNetworkStatic(relbase.trusty, TestNetworkStaticAbs):
91+ __test__ = True
92+
93+
94 class VividTestNetwork(relbase.vivid, TestNetworkAbs):
95 __test__ = True
96
97
98+class VividTestNetworkStatic(relbase.vivid, TestNetworkStaticAbs):
99+ __test__ = True
100+
101+
102 class WilyTestNetwork(relbase.wily, TestNetworkAbs):
103 __test__ = True
104
105
106+class WilyTestNetworkStatic(relbase.wily, TestNetworkStaticAbs):
107+ __test__ = True
108+
109+
110 class XenialTestNetwork(relbase.xenial, TestNetworkAbs):
111 __test__ = True
112 # FIXME: net.ifnames=0 should not be required as image should
113@@ -254,3 +270,12 @@
114 # over the net.ifnames to the installed system via '---' as the net
115 # config should take care of that.
116 extra_kern_args = "net.ifnames=0"
117+
118+
119+class XenialTestNetworkStatic(relbase.xenial, TestNetworkStaticAbs):
120+ __test__ = True
121+ # FIXME: net.ifnames=0 should not be required as image should
122+ # eventually address this internally. Here we do not carry
123+ # over the net.ifnames to the installed system via '---' as the net
124+ # config should take care of that.
125+ extra_kern_args = "net.ifnames=0"

Subscribers

People subscribed via source and target branches