47
46
__call__ = KernelParametersBase._replace
50
def compose_initrd_opt(arch, subarch, release, purpose):
51
path = "%s/initrd.gz" % compose_image_path(arch, subarch, release, purpose)
52
return "initrd=%s" % path
55
49
def compose_preseed_opt(preseed_url):
56
50
"""Compose a kernel option for preseed URL.
58
52
:param preseed_url: The URL from which a preseed can be fetched.
54
# See https://help.ubuntu.com/12.04/installation-guide
55
# /i386/preseed-using.html#preseed-auto
60
56
return "auto url=%s" % preseed_url
63
def compose_suite_opt(release):
64
return "suite=%s" % release
67
def compose_hostname_opt(hostname):
68
return "hostname=%s" % hostname
71
def compose_domain_opt(domain):
72
return "domain=%s" % domain
75
59
def compose_locale_opt():
77
61
return "locale=%s" % locale
110
def compose_hostname_opts(params):
111
"""Return list of hostname/domain options based on `params`.
113
The domain is omitted if `params` does not include it.
116
'hostname=%s' % params.hostname,
118
if params.domain is not None:
119
options.append('domain=%s' % params.domain)
127
123
def compose_purpose_opts(params):
128
124
"""Return the list of the purpose-specific kernel options."""
129
125
if params.purpose == "commissioning":
126
# These are kernel parameters read by the ephemeral environment.
128
# Read by the open-iscsi initramfs code.
131
129
"iscsi_target_name=%s:%s" % (
132
130
ISCSI_TARGET_NAME_PREFIX,
133
131
get_ephemeral_name(params.release, params.arch)),
135
"ro root=LABEL=cloudimg-rootfs",
136
132
"iscsi_target_ip=%s" % params.fs_host,
137
133
"iscsi_target_port=3260",
134
"iscsi_initiator=%s" % params.hostname,
135
# Read by cloud-initramfs-dyn-netconf and klibc's ipconfig
137
"ip=::::%s:BOOTIF" % params.hostname,
138
# cloud-images have this filesystem label.
139
"ro root=LABEL=cloudimg-rootfs",
140
# Read by overlayroot package.
142
# Read by cloud-init.
143
"cloud-config-url=%s" % params.preseed_url,
146
# These are options used by the Debian Installer.
141
"netcfg/choose_interface=auto"
148
"netcfg/choose_interface=auto",
149
# Use the text installer, display only critical messages.
150
"text priority=critical",
151
compose_preseed_opt(params.preseed_url),
152
compose_locale_opt(),
153
] + compose_hostname_opts(params)
145
156
def compose_arch_opts(params):
147
158
if (params.arch, params.subarch) == ("armhf", "highbank"):
148
159
return ["console=ttyAMA0"]
153
def compose_kernel_command_line_new(params):
161
# On Intel send kernel output to both console and ttyS0.
162
return ["console=tty1", "console=ttyS0"]
165
def compose_kernel_command_line(params):
154
166
"""Generate a line of kernel options for booting `node`.
156
168
:type params: `KernelParameters`.
160
params.arch, params.subarch,
161
params.release, params.purpose),
162
compose_preseed_opt(params.preseed_url),
163
compose_suite_opt(params.release),
164
compose_hostname_opt(params.hostname),
165
compose_domain_opt(params.domain),
166
compose_locale_opt(),
171
# nomodeset prevents video mode switching.
172
options += ["nomodeset"]
168
173
options += compose_purpose_opts(params)
174
# Note: logging opts are not respected by ephemeral images, so
175
# these are actually "purpose_opts" but were left generic
176
# as it would be nice to have.
169
177
options += compose_logging_opts(params.log_host)
170
178
options += compose_arch_opts(params)
171
179
return ' '.join(options)