Merge lp:~smoser/maas/lp1402042 into lp:~maas-committers/maas/trunk

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: no longer in the source branch.
Merged at revision: 4080
Proposed branch: lp:~smoser/maas/lp1402042
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 118 lines (+49/-6)
2 files modified
src/provisioningserver/kernel_opts.py (+16/-3)
src/provisioningserver/tests/test_kernel_opts.py (+33/-3)
To merge this branch: bzr merge lp:~smoser/maas/lp1402042
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+264049@code.launchpad.net

Commit message

support using '---' as separator for copy-over kernel params

See bug 1402042 for a full description of why this change is necessary.

Description of the change

Suggestions on the variable name are welcome. I'd like to keep it consistent between maas and curtin.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Looks okay but here are my suggestions for this code: http://paste.ubuntu.com/11841389/
What do you think?

Revision history for this message
Scott Moser (smoser) wrote :

the only comment i have is that CURTIN_KERNEL_CMDLINE_NAME seems not useful.
the name 'KERNEL_CMDLINE_COPY_TO_INSTALL_SEP' is obnoxiously large, but it better describes it.
CURTIN_KERNEL_CMDLINE_NAME doesn't really mean anything if you read that by itself.

i fully accept that this is a bikeshed, but as i said in the description i'd like to have the name stay the same between maas and curtin.

its up to you, i dont really have a strong feelings.

Revision history for this message
Raphaël Badin (rvb) wrote :

> the only comment i have is that CURTIN_KERNEL_CMDLINE_NAME seems not useful.
> the name 'KERNEL_CMDLINE_COPY_TO_INSTALL_SEP' is obnoxiously large, but it
> better describes it.
> CURTIN_KERNEL_CMDLINE_NAME doesn't really mean anything if you read that by
> itself.
>
> i fully accept that this is a bikeshed, but as i said in the description i'd
> like to have the name stay the same between maas and curtin.
>
> its up to you, i dont really have a strong feelings.

Okay, sure, let's rename CURTIN_KERNEL_CMDLINE_NAME.

I agree it's convenient if the names are the same but note that the MAAS instance doesn't need to be exported (aka put in __all__) because this is only used in this module (well, and the tests but that doesn't count).

Revision history for this message
Raphaël Badin (rvb) wrote :

Looks good to me :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/provisioningserver/kernel_opts.py'
--- src/provisioningserver/kernel_opts.py 2015-06-10 11:35:04 +0000
+++ src/provisioningserver/kernel_opts.py 2015-07-09 13:39:17 +0000
@@ -21,6 +21,7 @@
21from collections import namedtuple21from collections import namedtuple
22import os22import os
2323
24import curtin
24from provisioningserver.drivers import ArchitectureRegistry25from provisioningserver.drivers import ArchitectureRegistry
25from provisioningserver.logger import get_maas_logger26from provisioningserver.logger import get_maas_logger
2627
@@ -171,6 +172,15 @@
171 return []172 return []
172173
173174
175CURTIN_KERNEL_CMDLINE_NAME = 'KERNEL_CMDLINE_COPY_TO_INSTALL_SEP'
176
177
178def get_curtin_kernel_cmdline_sep():
179 """Return the separator for passing extra parameters to the kernel."""
180 return getattr(
181 curtin, CURTIN_KERNEL_CMDLINE_NAME, '--')
182
183
174def compose_kernel_command_line(params):184def compose_kernel_command_line(params):
175 """Generate a line of kernel options for booting `node`.185 """Generate a line of kernel options for booting `node`.
176186
@@ -185,13 +195,16 @@
185 # as it would be nice to have.195 # as it would be nice to have.
186 options += compose_logging_opts(params.log_host)196 options += compose_logging_opts(params.log_host)
187 options += compose_arch_opts(params)197 options += compose_arch_opts(params)
198 cmdline_sep = get_curtin_kernel_cmdline_sep()
188 if params.extra_opts:199 if params.extra_opts:
189 # Using -- before extra opts makes both d-i and Curtin install200 # Using --- before extra opts makes both d-i and Curtin install
190 # them into the grub config when installing an OS, thus causing201 # them into the grub config when installing an OS, thus causing
191 # the options to "stick" when local booting later.202 # the options to "stick" when local booting later.
192 options.append('--')203 # see LP: #1402042 for info on '---' versus '--'
204 options.append(cmdline_sep)
193 options.append(params.extra_opts)205 options.append(params.extra_opts)
194 kernel_opts = ' '.join(options)206 kernel_opts = ' '.join(options)
195 maaslog.debug(207 maaslog.debug(
196 '%s: kernel parameters -- "%s"' % (params.hostname, kernel_opts))208 '%s: kernel parameters %s "%s"' %
209 (cmdline_sep, params.hostname, kernel_opts))
197 return kernel_opts210 return kernel_opts
198211
=== modified file 'src/provisioningserver/tests/test_kernel_opts.py'
--- src/provisioningserver/tests/test_kernel_opts.py 2015-05-07 18:14:38 +0000
+++ src/provisioningserver/tests/test_kernel_opts.py 2015-07-09 13:39:17 +0000
@@ -20,6 +20,7 @@
2020
21from maastesting.factory import factory21from maastesting.factory import factory
22from maastesting.testcase import MAASTestCase22from maastesting.testcase import MAASTestCase
23from mock import sentinel
23from provisioningserver import kernel_opts24from provisioningserver import kernel_opts
24from provisioningserver.drivers import (25from provisioningserver.drivers import (
25 Architecture,26 Architecture,
@@ -29,6 +30,8 @@
29 compose_arch_opts,30 compose_arch_opts,
30 compose_kernel_command_line,31 compose_kernel_command_line,
31 compose_preseed_opt,32 compose_preseed_opt,
33 CURTIN_KERNEL_CMDLINE_NAME,
34 get_curtin_kernel_cmdline_sep,
32 get_ephemeral_name,35 get_ephemeral_name,
33 get_last_directory,36 get_last_directory,
34 ISCSI_TARGET_NAME_PREFIX,37 ISCSI_TARGET_NAME_PREFIX,
@@ -106,6 +109,29 @@
106 self.assertNotIn('::' + target, full_name)109 self.assertNotIn('::' + target, full_name)
107110
108111
112class TestGetCurtinKernelCmdlineSepTest(MAASTestCase):
113
114 def test_get_curtin_kernel_cmdline_sep_returns_curtin_value(self):
115 sep = factory.make_name('separator')
116 self.patch(
117 kernel_opts.curtin, CURTIN_KERNEL_CMDLINE_NAME, sep)
118 self.assertEqual(sep, get_curtin_kernel_cmdline_sep())
119
120 def test_get_curtin_kernel_cmdline_sep_returns_default(self):
121 original_sep = getattr(
122 kernel_opts.curtin, CURTIN_KERNEL_CMDLINE_NAME,
123 sentinel.missing)
124
125 if original_sep != sentinel.missing:
126 def restore_sep():
127 setattr(
128 kernel_opts.curtin,
129 CURTIN_KERNEL_CMDLINE_NAME, original_sep)
130 self.addCleanup(restore_sep)
131 delattr(kernel_opts.curtin, CURTIN_KERNEL_CMDLINE_NAME)
132 self.assertEqual('--', get_curtin_kernel_cmdline_sep())
133
134
109class TestKernelOpts(MAASTestCase):135class TestKernelOpts(MAASTestCase):
110136
111 def make_kernel_parameters(self, *args, **kwargs):137 def make_kernel_parameters(self, *args, **kwargs):
@@ -191,12 +217,16 @@
191 "ip=::::%s:BOOTIF" % params.hostname]))217 "ip=::::%s:BOOTIF" % params.hostname]))
192218
193 def test_commissioning_compose_kernel_command_line_inc_extra_opts(self):219 def test_commissioning_compose_kernel_command_line_inc_extra_opts(self):
220 mock_get_curtin_sep = self.patch(
221 kernel_opts, 'get_curtin_kernel_cmdline_sep')
222 sep = factory.make_name('sep')
223 mock_get_curtin_sep.return_value = sep
194 extra_opts = "special console=ABCD -- options to pass"224 extra_opts = "special console=ABCD -- options to pass"
195 params = self.make_kernel_parameters(extra_opts=extra_opts)225 params = self.make_kernel_parameters(extra_opts=extra_opts)
196 cmdline = compose_kernel_command_line(params)226 cmdline = compose_kernel_command_line(params)
197 # There should be a double dash (--) surrounded by spaces before227 # There should be KERNEL_CMDLINE_COPY_TO_INSTALL_SEP surrounded by
198 # the options, but otherwise added verbatim.228 # spaces before the options, but otherwise added verbatim.
199 self.assertThat(cmdline, Contains(' -- ' + extra_opts))229 self.assertThat(cmdline, Contains(' %s ' % sep + extra_opts))
200230
201 def test_commissioning_compose_kernel_handles_extra_opts_None(self):231 def test_commissioning_compose_kernel_handles_extra_opts_None(self):
202 params = self.make_kernel_parameters(extra_opts=None)232 params = self.make_kernel_parameters(extra_opts=None)