Merge lp:~lamont/maas/bug-1621507 into lp:~maas-committers/maas/trunk

Proposed by LaMont Jones
Status: Merged
Approved by: LaMont Jones
Approved revision: no longer in the source branch.
Merged at revision: 5529
Proposed branch: lp:~lamont/maas/bug-1621507
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 181 lines (+105/-41)
2 files modified
src/provisioningserver/kernel_opts.py (+13/-3)
src/provisioningserver/tests/test_kernel_opts.py (+92/-38)
To merge this branch: bzr merge lp:~lamont/maas/bug-1621507
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+309519@code.launchpad.net

Commit message

IPv6 support requires that we add "ip6=dhcp" to the kernel commandline for ephemeral kernels.

Description of the change

IPv6 support requires that we add "ip6=dhcp" to the kernel commandline for ephemeral kernels.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

I don't fully understand what's going on here. The magic token "BOOTIF" is... magic. Anyway, it seems fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/kernel_opts.py'
2--- src/provisioningserver/kernel_opts.py 2015-12-01 18:12:59 +0000
3+++ src/provisioningserver/kernel_opts.py 2016-10-28 15:38:40 +0000
4@@ -13,6 +13,7 @@
5 import os
6
7 import curtin
8+from netaddr import IPAddress
9 from provisioningserver.drivers import ArchitectureRegistry
10 from provisioningserver.logger import get_maas_logger
11
12@@ -129,9 +130,18 @@
13 "iscsi_target_ip=%s" % params.fs_host,
14 "iscsi_target_port=3260",
15 "iscsi_initiator=%s" % params.hostname,
16- # Read by cloud-initramfs-dyn-netconf and klibc's ipconfig
17- # in the initramfs.
18- "ip=::::%s:BOOTIF" % params.hostname,
19+ # Read by cloud-initramfs-dyn-netconf initramfs-tools networking
20+ # configuration in the initramfs. Choose IPv4 or IPv6 based on the
21+ # family of fs_host. If BOOTIF is set, IPv6 config uses that
22+ # exclusively.
23+ (
24+ "ip=::::%s:BOOTIF" % params.hostname
25+ if IPAddress(params.fs_host).version == 4 else "ip=off"
26+ ),
27+ (
28+ "ip6=dhcp"
29+ if IPAddress(params.fs_host).version == 6 else "ip6=off"
30+ ),
31 # kernel / udev name iscsi devices with this path
32 "ro root=/dev/disk/by-path/ip-%s:%s-iscsi-%s-lun-1" % (
33 params.fs_host, "3260", tname),
34
35=== modified file 'src/provisioningserver/tests/test_kernel_opts.py'
36--- src/provisioningserver/tests/test_kernel_opts.py 2016-06-22 17:03:02 +0000
37+++ src/provisioningserver/tests/test_kernel_opts.py 2016-10-28 15:38:40 +0000
38@@ -43,6 +43,9 @@
39 ArchitectureRegistry and call addCleanup on the testcase to make sure
40 it is removed after the test completes.
41 """
42+ # fs_host needs to be an IP address, set it if it was not passed.
43+ if 'fs_host' not in parms:
44+ parms.update({'fs_host': factory.make_ip_address()})
45 parms.update(
46 {field: factory.make_name(field)
47 for field in KernelParameters._fields
48@@ -181,44 +184,95 @@
49 "netcfg/choose_interface=auto",
50 compose_kernel_command_line(params))
51
52- def test_xinstall_compose_kernel_command_line_inc_purpose_opts(self):
53- # The result of compose_kernel_command_line includes the purpose
54- # options for a non "xinstall" node.
55- params = self.make_kernel_parameters(purpose="xinstall")
56- cmdline = compose_kernel_command_line(params)
57- self.assertThat(
58- cmdline,
59- ContainsAll([
60- "root=/dev/disk/by-path/ip-",
61- "iscsi_initiator=",
62- "overlayroot=tmpfs",
63- "ip=::::%s:BOOTIF" % params.hostname]))
64-
65- def test_commissioning_compose_kernel_command_line_inc_purpose_opts(self):
66- # The result of compose_kernel_command_line includes the purpose
67- # options for a non "commissioning" node.
68- params = self.make_kernel_parameters(purpose="commissioning")
69- cmdline = compose_kernel_command_line(params)
70- self.assertThat(
71- cmdline,
72- ContainsAll([
73- "root=/dev/disk/by-path/ip-",
74- "iscsi_initiator=",
75- "overlayroot=tmpfs",
76- "ip=::::%s:BOOTIF" % params.hostname]))
77-
78- def test_enlist_compose_kernel_command_line_inc_purpose_opts(self):
79- # The result of compose_kernel_command_line includes the purpose
80- # options for a non "commissioning" node.
81- params = self.make_kernel_parameters(purpose="enlist")
82- cmdline = compose_kernel_command_line(params)
83- self.assertThat(
84- cmdline,
85- ContainsAll([
86- "root=/dev/disk/by-path/ip-",
87- "iscsi_initiator=",
88- "overlayroot=tmpfs",
89- "ip=::::%s:BOOTIF" % params.hostname]))
90+ def test_xinstall_compose_kernel_command_line_inc_purpose_opts4(self):
91+ # The result of compose_kernel_command_line includes the purpose
92+ # options for a non "xinstall" node.
93+ params = self.make_kernel_parameters(
94+ purpose="xinstall", fs_host=factory.make_ipv4_address())
95+ cmdline = compose_kernel_command_line(params)
96+ self.assertThat(
97+ cmdline,
98+ ContainsAll([
99+ "root=/dev/disk/by-path/ip-",
100+ "iscsi_initiator=",
101+ "overlayroot=tmpfs",
102+ "ip6=off",
103+ "ip=::::%s:BOOTIF" % params.hostname]))
104+
105+ def test_xinstall_compose_kernel_command_line_inc_purpose_opts6(self):
106+ # The result of compose_kernel_command_line includes the purpose
107+ # options for a non "xinstall" node.
108+ params = self.make_kernel_parameters(
109+ purpose="xinstall", fs_host=factory.make_ipv6_address())
110+ cmdline = compose_kernel_command_line(params)
111+ self.assertThat(
112+ cmdline,
113+ ContainsAll([
114+ "root=/dev/disk/by-path/ip-",
115+ "iscsi_initiator=",
116+ "overlayroot=tmpfs",
117+ "ip=off",
118+ "ip6=dhcp"]))
119+
120+ def test_commissioning_compose_kernel_command_line_inc_purpose_opts4(self):
121+ # The result of compose_kernel_command_line includes the purpose
122+ # options for a non "commissioning" node.
123+ params = self.make_kernel_parameters(
124+ purpose="commissioning", fs_host=factory.make_ipv4_address())
125+ cmdline = compose_kernel_command_line(params)
126+ self.assertThat(
127+ cmdline,
128+ ContainsAll([
129+ "root=/dev/disk/by-path/ip-",
130+ "iscsi_initiator=",
131+ "overlayroot=tmpfs",
132+ "ip6=off",
133+ "ip=::::%s:BOOTIF" % params.hostname]))
134+
135+ def test_commissioning_compose_kernel_command_line_inc_purpose_opts6(self):
136+ # The result of compose_kernel_command_line includes the purpose
137+ # options for a non "commissioning" node.
138+ params = self.make_kernel_parameters(
139+ purpose="commissioning", fs_host=factory.make_ipv6_address())
140+ cmdline = compose_kernel_command_line(params)
141+ self.assertThat(
142+ cmdline,
143+ ContainsAll([
144+ "root=/dev/disk/by-path/ip-",
145+ "iscsi_initiator=",
146+ "overlayroot=tmpfs",
147+ "ip=off",
148+ "ip6=dhcp"]))
149+
150+ def test_enlist_compose_kernel_command_line_inc_purpose_opts4(self):
151+ # The result of compose_kernel_command_line includes the purpose
152+ # options for a non "commissioning" node.
153+ params = self.make_kernel_parameters(
154+ purpose="enlist", fs_host=factory.make_ipv4_address())
155+ cmdline = compose_kernel_command_line(params)
156+ self.assertThat(
157+ cmdline,
158+ ContainsAll([
159+ "root=/dev/disk/by-path/ip-",
160+ "iscsi_initiator=",
161+ "overlayroot=tmpfs",
162+ "ip6=off",
163+ "ip=::::%s:BOOTIF" % params.hostname]))
164+
165+ def test_enlist_compose_kernel_command_line_inc_purpose_opts6(self):
166+ # The result of compose_kernel_command_line includes the purpose
167+ # options for a non "commissioning" node.
168+ params = self.make_kernel_parameters(
169+ purpose="enlist", fs_host=factory.make_ipv6_address())
170+ cmdline = compose_kernel_command_line(params)
171+ self.assertThat(
172+ cmdline,
173+ ContainsAll([
174+ "root=/dev/disk/by-path/ip-",
175+ "iscsi_initiator=",
176+ "overlayroot=tmpfs",
177+ "ip=off",
178+ "ip6=dhcp"]))
179
180 def test_commissioning_compose_kernel_command_line_inc_extra_opts(self):
181 mock_get_curtin_sep = self.patch(