Merge lp:~jameinel/maas/1.2-pxeconfig-includes-kernel-opts into lp:maas/1.2

Proposed by John A Meinel on 2012-11-07
Status: Merged
Approved by: John A Meinel on 2012-11-08
Approved revision: 1288
Merged at revision: 1290
Proposed branch: lp:~jameinel/maas/1.2-pxeconfig-includes-kernel-opts
Merge into: lp:maas/1.2
Diff against target: 99 lines (+43/-1)
4 files modified
src/maasserver/api.py (+9/-1)
src/maasserver/tests/test_api.py (+17/-0)
src/provisioningserver/kernel_opts.py (+4/-0)
src/provisioningserver/tests/test_kernel_opts.py (+13/-0)
To merge this branch: bzr merge lp:~jameinel/maas/1.2-pxeconfig-includes-kernel-opts
Reviewer Review Type Date Requested Status
Julian Edwards (community) 2012-11-07 Approve on 2012-11-08
Review via email: mp+133255@code.launchpad.net

Commit Message

Expose the new kernel options to the pxeconfig api.

Add the extra options to KernelParameters, and return them when the tftp server places its request.
Tweak the tftp server so that it adds the new parameters to the commandline.

Description of the Change

This closes the loop, so that nodes should boot with kernel_opts that are set (either in the global config, or once my other patches land in a tag.)

The main downside is that this is technically an API break as 'pxe_config' is now returning extra data in the JSON response, but old clients are strict about what data they accept. (They take the exact JSON back into a dict and pass it as **kwargs to the namedtuple constructor, which requires an exact match.)

If we really care about that, then we can bump the api version or something like that. It doesn't really make sense to add another API call just to get a little bit more data. We already have to configure the one URL in pserv.yaml, it would be silly to add a lot of other config to just make one more request.

To post a comment you must log in.
Julian Edwards (julian-edwards) wrote :

Given that I doubt anyone is upgrading in anything other than lockstep right now, I think it's fine to change this (internal) API call. However once we know people are doing bigger deployments, the API call will need to be different and we bump the version so that clusters are not forced into lockstep upgrades.

review: Approve
MAAS Lander (maas-lander) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api.py'
2--- src/maasserver/api.py 2012-11-07 13:31:59 +0000
3+++ src/maasserver/api.py 2012-11-08 05:07:20 +0000
4@@ -1784,6 +1784,13 @@
5 else:
6 series = node.get_distro_series()
7
8+ if node is not None:
9+ # We don't care if the kernel opts is from the global setting or a tag,
10+ # just get the options
11+ _, extra_kernel_opts = node.get_effective_kernel_options()
12+ else:
13+ extra_kernel_opts = None
14+
15 purpose = get_boot_purpose(node)
16 server_address = get_maas_facing_server_address()
17 cluster_address = get_mandatory_param(request.GET, "local")
18@@ -1791,7 +1798,8 @@
19 params = KernelParameters(
20 arch=arch, subarch=subarch, release=series, purpose=purpose,
21 hostname=hostname, domain=domain, preseed_url=preseed_url,
22- log_host=server_address, fs_host=cluster_address)
23+ log_host=server_address, fs_host=cluster_address,
24+ extra_opts=extra_kernel_opts)
25
26 return HttpResponse(
27 json.dumps(params._asdict()),
28
29=== modified file 'src/maasserver/tests/test_api.py'
30--- src/maasserver/tests/test_api.py 2012-11-06 18:19:54 +0000
31+++ src/maasserver/tests/test_api.py 2012-11-08 05:07:20 +0000
32@@ -3362,6 +3362,23 @@
33 kernel_params = KernelParameters(**self.get_pxeconfig(params))
34 self.assertEqual(params["local"], kernel_params.fs_host)
35
36+ def test_pxeconfig_returns_extra_kernel_options(self):
37+ node = factory.make_node()
38+ kernel_opts = factory.getRandomString()
39+ Config.objects.set_config('kernel_opts', kernel_opts)
40+ mac = factory.make_mac_address(node=node)
41+ params = self.get_default_params()
42+ params['mac'] = mac.mac_address
43+ pxe_config = self.get_pxeconfig(params)
44+ self.assertEqual(kernel_opts, pxe_config['extra_opts'])
45+
46+ def test_pxeconfig_returns_None_for_extra_kernel_opts(self):
47+ mac = factory.make_mac_address()
48+ params = self.get_default_params()
49+ params['mac'] = mac.mac_address
50+ pxe_config = self.get_pxeconfig(params)
51+ self.assertEqual(None, pxe_config['extra_opts'])
52+
53
54 class TestNodeGroupsAPI(APIv10TestMixin, MultipleUsersScenarios, TestCase):
55 scenarios = [
56
57=== modified file 'src/provisioningserver/kernel_opts.py'
58--- src/provisioningserver/kernel_opts.py 2012-10-09 15:43:33 +0000
59+++ src/provisioningserver/kernel_opts.py 2012-11-08 05:07:20 +0000
60@@ -37,6 +37,8 @@
61 "preseed_url", # URL from which a preseed can be obtained.
62 "log_host", # Host/IP to which syslog can be streamed.
63 "fs_host", # Host/IP on which ephemeral filesystems are hosted.
64+ "extra_opts", # String of extra options to supply, will be appended
65+ # verbatim to the kernel command line
66 ))
67
68
69@@ -176,4 +178,6 @@
70 # as it would be nice to have.
71 options += compose_logging_opts(params.log_host)
72 options += compose_arch_opts(params)
73+ if params.extra_opts:
74+ options.append(params.extra_opts)
75 return ' '.join(options)
76
77=== modified file 'src/provisioningserver/tests/test_kernel_opts.py'
78--- src/provisioningserver/tests/test_kernel_opts.py 2012-10-09 15:39:54 +0000
79+++ src/provisioningserver/tests/test_kernel_opts.py 2012-11-08 05:07:20 +0000
80@@ -133,6 +133,19 @@
81 "overlayroot=tmpfs",
82 "ip=::::%s:BOOTIF" % params.hostname]))
83
84+ def test_commissioning_compose_kernel_command_line_inc_extra_opts(self):
85+ extra_opts = "special console=ABCD -- options to pass"
86+ params = make_kernel_parameters(extra_opts=extra_opts)
87+ cmdline = compose_kernel_command_line(params)
88+ # There should be a blank space before the options, but otherwise added
89+ # verbatim.
90+ self.assertThat(cmdline, Contains(' ' + extra_opts))
91+
92+ def test_commissioning_compose_kernel_command_line_handles_extra_opts_None(self):
93+ params = make_kernel_parameters(extra_opts=None)
94+ cmdline = compose_kernel_command_line(params)
95+ self.assertNotIn(cmdline, "None")
96+
97 def test_compose_kernel_command_line_inc_common_opts(self):
98 # Test that some kernel arguments appear on both commissioning
99 # and install command lines.

Subscribers

People subscribed via source and target branches

to status/vote changes: