Merge lp:~ltrager/maas/remove_di_from_kernel_opts into lp:~maas-committers/maas/trunk

Proposed by Lee Trager
Status: Superseded
Proposed branch: lp:~ltrager/maas/remove_di_from_kernel_opts
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 218 lines (+33/-117)
2 files modified
src/provisioningserver/kernel_opts.py (+27/-69)
src/provisioningserver/tests/test_kernel_opts.py (+6/-48)
To merge this branch: bzr merge lp:~ltrager/maas/remove_di_from_kernel_opts
Reviewer Review Type Date Requested Status
Andres Rodriguez Pending
Review via email: mp+309081@code.launchpad.net

This proposal has been superseded by a proposal from 2016-10-22.

Commit message

Remove deprecated d-i install code from kernel opts.

Description of the change

MAAS supports four netboot options. commissioning, xinstall, enlist, and install. xinstall is MASS's current, and only supported installation boot method which uses Curtin. install was used for deploying using the Debian installer. As that method is no longer supported we can always return the same kernel arguments.

To post a comment you must log in.

Unmerged revisions

5461. By Lee Trager

Remove deprecated d-i install code from kernel opts.

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-12-01 18:12:59 +0000
+++ src/provisioningserver/kernel_opts.py 2016-10-22 06:27:37 +0000
@@ -48,21 +48,6 @@
48 __call__ = KernelParametersBase._replace48 __call__ = KernelParametersBase._replace
4949
5050
51def compose_preseed_opt(preseed_url):
52 """Compose a kernel option for preseed URL.
53
54 :param preseed_url: The URL from which a preseed can be fetched.
55 """
56 # See https://help.ubuntu.com/12.04/installation-guide
57 # /i386/preseed-using.html#preseed-auto
58 return "auto url=%s" % preseed_url
59
60
61def compose_locale_opt():
62 locale = 'en_US'
63 return "locale=%s" % locale
64
65
66def compose_logging_opts(log_host):51def compose_logging_opts(log_host):
67 return [52 return [
68 'log_host=%s' % log_host,53 'log_host=%s' % log_host,
@@ -97,61 +82,11 @@
97 )82 )
9883
9984
100def compose_hostname_opts(params):
101 """Return list of hostname/domain options based on `params`.
102
103 The domain is omitted if `params` does not include it.
104 """
105 options = [
106 'hostname=%s' % params.hostname,
107 ]
108 if params.domain is not None:
109 options.append('domain=%s' % params.domain)
110 return options
111
112
113def prefix_target_name(name):85def prefix_target_name(name):
114 """Prefix an ISCSI target name with the standard target-name prefix."""86 """Prefix an ISCSI target name with the standard target-name prefix."""
115 return "%s:%s" % (ISCSI_TARGET_NAME_PREFIX, name)87 return "%s:%s" % (ISCSI_TARGET_NAME_PREFIX, name)
11688
11789
118def compose_purpose_opts(params):
119 """Return the list of the purpose-specific kernel options."""
120 if params.purpose in ["commissioning", "xinstall", "enlist"]:
121 # These are kernel parameters read by the ephemeral environment.
122 tname = prefix_target_name(
123 get_ephemeral_name(
124 params.osystem, params.arch, params.subarch,
125 params.release, params.label))
126 kernel_params = [
127 # Read by the open-iscsi initramfs code.
128 "iscsi_target_name=%s" % tname,
129 "iscsi_target_ip=%s" % params.fs_host,
130 "iscsi_target_port=3260",
131 "iscsi_initiator=%s" % params.hostname,
132 # Read by cloud-initramfs-dyn-netconf and klibc's ipconfig
133 # in the initramfs.
134 "ip=::::%s:BOOTIF" % params.hostname,
135 # kernel / udev name iscsi devices with this path
136 "ro root=/dev/disk/by-path/ip-%s:%s-iscsi-%s-lun-1" % (
137 params.fs_host, "3260", tname),
138 # Read by overlayroot package.
139 "overlayroot=tmpfs",
140 # Read by cloud-init.
141 "cloud-config-url=%s" % params.preseed_url,
142 ]
143 return kernel_params
144 else:
145 # These are options used by the Debian Installer.
146 return [
147 "netcfg/choose_interface=auto",
148 # Use the text installer, display only critical messages.
149 "text priority=critical",
150 compose_preseed_opt(params.preseed_url),
151 compose_locale_opt(),
152 ] + compose_hostname_opts(params)
153
154
155def compose_arch_opts(params):90def compose_arch_opts(params):
156 """Return any architecture-specific options required"""91 """Return any architecture-specific options required"""
157 arch_subarch = '%s/%s' % (params.arch, params.subarch)92 arch_subarch = '%s/%s' % (params.arch, params.subarch)
@@ -176,10 +111,33 @@
176111
177 :type params: `KernelParameters`.112 :type params: `KernelParameters`.
178 """113 """
179 options = []114 # These are kernel parameters read by the ephemeral environment.
180 # nomodeset prevents video mode switching.115 tname = prefix_target_name(
181 options += ["nomodeset"]116 get_ephemeral_name(
182 options += compose_purpose_opts(params)117 params.osystem, params.arch, params.subarch,
118 params.release, params.label))
119 options = [
120 # nomodeset prevents video mode switching.
121 "nomodeset",
122 # Read by the open-iscsi initramfs code.
123 "iscsi_target_name=%s" % tname,
124 "iscsi_target_ip=%s" % params.fs_host,
125 "iscsi_target_port=3260",
126 "iscsi_initiator=%s" % params.hostname,
127 # Read by cloud-initramfs-dyn-netconf and klibc's ipconfig
128 # in the initramfs.
129 "ip=::::%s:BOOTIF" % params.hostname,
130 # kernel / udev name iscsi devices with this path
131 "ro root=/dev/disk/by-path/ip-%s:%s-iscsi-%s-lun-1" % (
132 params.fs_host, "3260", tname),
133 # Read by overlayroot package.
134 "overlayroot=tmpfs",
135 # LP:1533822 - Disable reading overlay data from disk.
136 "overlayroot_cfgdisk=disabled",
137 # Read by cloud-init.
138 "cloud-config-url=%s" % params.preseed_url,
139 ]
140
183 # Note: logging opts are not respected by ephemeral images, so141 # Note: logging opts are not respected by ephemeral images, so
184 # these are actually "purpose_opts" but were left generic142 # these are actually "purpose_opts" but were left generic
185 # as it would be nice to have.143 # as it would be nice to have.
186144
=== modified file 'src/provisioningserver/tests/test_kernel_opts.py'
--- src/provisioningserver/tests/test_kernel_opts.py 2016-06-22 17:03:02 +0000
+++ src/provisioningserver/tests/test_kernel_opts.py 2016-10-22 06:27:37 +0000
@@ -8,6 +8,7 @@
8 ]8 ]
99
10import os10import os
11import random
11from unittest.mock import sentinel12from unittest.mock import sentinel
1213
13from maastesting.factory import factory14from maastesting.factory import factory
@@ -20,7 +21,6 @@
20from provisioningserver.kernel_opts import (21from provisioningserver.kernel_opts import (
21 compose_arch_opts,22 compose_arch_opts,
22 compose_kernel_command_line,23 compose_kernel_command_line,
23 compose_preseed_opt,
24 CURTIN_KERNEL_CMDLINE_NAME,24 CURTIN_KERNEL_CMDLINE_NAME,
25 get_curtin_kernel_cmdline_sep,25 get_curtin_kernel_cmdline_sep,
26 get_ephemeral_name,26 get_ephemeral_name,
@@ -128,33 +128,11 @@
128 def make_kernel_parameters(self, *args, **kwargs):128 def make_kernel_parameters(self, *args, **kwargs):
129 return make_kernel_parameters(self, *args, **kwargs)129 return make_kernel_parameters(self, *args, **kwargs)
130130
131 def test_compose_kernel_command_line_includes_preseed_url(self):131 def test_compose_kernel_command_line_includes_disable_overlay_cfg(self):
132 params = self.make_kernel_parameters()132 params = self.make_kernel_parameters(
133 self.assertIn(133 purpose=random.choice(["commissioning", "xinstall", "enlist"]))
134 "auto url=%s" % params.preseed_url,134 cmdline = compose_kernel_command_line(params)
135 compose_kernel_command_line(params))135 self.assertThat(cmdline, Contains("overlayroot_cfgdisk=disabled"))
136
137 def test_install_compose_kernel_command_line_includes_name_domain(self):
138 params = self.make_kernel_parameters(purpose="install")
139 self.assertThat(
140 compose_kernel_command_line(params),
141 ContainsAll([
142 "hostname=%s" % params.hostname,
143 "domain=%s" % params.domain,
144 ]))
145
146 def test_install_compose_kernel_command_line_omits_domain_if_omitted(self):
147 params = self.make_kernel_parameters(purpose="install", domain=None)
148 kernel_command_line = compose_kernel_command_line(params)
149 self.assertIn("hostname=%s" % params.hostname, kernel_command_line)
150 self.assertNotIn('domain=', kernel_command_line)
151
152 def test_install_compose_kernel_command_line_includes_locale(self):
153 params = self.make_kernel_parameters(purpose="install")
154 locale = "en_US"
155 self.assertIn(
156 "locale=%s" % locale,
157 compose_kernel_command_line(params))
158136
159 def test_install_compose_kernel_command_line_includes_log_settings(self):137 def test_install_compose_kernel_command_line_includes_log_settings(self):
160 params = self.make_kernel_parameters(purpose="install")138 params = self.make_kernel_parameters(purpose="install")
@@ -167,20 +145,6 @@
167 "log_port=%s" % log_port,145 "log_port=%s" % log_port,
168 ]))146 ]))
169147
170 def test_install_compose_kernel_command_line_includes_di_settings(self):
171 params = self.make_kernel_parameters(purpose="install")
172 self.assertThat(
173 compose_kernel_command_line(params),
174 Contains("text priority=critical"))
175
176 def test_install_compose_kernel_command_line_inc_purpose_opts(self):
177 # The result of compose_kernel_command_line includes the purpose
178 # options for a non "commissioning" node.
179 params = self.make_kernel_parameters(purpose="install")
180 self.assertIn(
181 "netcfg/choose_interface=auto",
182 compose_kernel_command_line(params))
183
184 def test_xinstall_compose_kernel_command_line_inc_purpose_opts(self):148 def test_xinstall_compose_kernel_command_line_inc_purpose_opts(self):
185 # The result of compose_kernel_command_line includes the purpose149 # The result of compose_kernel_command_line includes the purpose
186 # options for a non "xinstall" node.150 # options for a non "xinstall" node.
@@ -289,12 +253,6 @@
289 "iscsi_target_ip=%s" % params.fs_host,253 "iscsi_target_ip=%s" % params.fs_host,
290 ]))254 ]))
291255
292 def test_compose_preseed_kernel_opt_returns_kernel_option(self):
293 dummy_preseed_url = factory.make_name("url")
294 self.assertEqual(
295 "auto url=%s" % dummy_preseed_url,
296 compose_preseed_opt(dummy_preseed_url))
297
298 def test_compose_kernel_command_line_inc_arm_specific_option(self):256 def test_compose_kernel_command_line_inc_arm_specific_option(self):
299 params = self.make_kernel_parameters(arch="armhf", subarch="highbank")257 params = self.make_kernel_parameters(arch="armhf", subarch="highbank")
300 self.assertThat(258 self.assertThat(