Browse Source

Clean up kernel_append_params for PXE/iPXE

Currently handling of kernel_append_params is very inconsistent. This
change applies a straightforward process:
1. instance_info[kernel_append_params]
2. driver_info[kernel_append_params]
3. [pxe]kernel_append_params (renamed from pxe_append_params).

Also adds a helper for subsequent fixes in other drivers.

Change-Id: I79bcf4d8ef1f0f55a82e0991dd5bb1685b3f7957
Story: #2008902
Task: #42469
changes/55/791755/3
Dmitry Tantsur 4 weeks ago
parent
commit
2a73f5a84e
12 changed files with 86 additions and 17 deletions
  1. +1
    -1
      devstack/lib/ironic
  2. +9
    -4
      doc/source/install/include/kernel-boot-parameters.inc
  3. +4
    -2
      ironic/common/pxe_utils.py
  4. +2
    -1
      ironic/conf/pxe.py
  5. +2
    -1
      ironic/drivers/modules/irmc/boot.py
  6. +10
    -0
      ironic/drivers/modules/pxe_base.py
  7. +20
    -0
      ironic/drivers/utils.py
  8. +23
    -5
      ironic/tests/unit/common/test_pxe_utils.py
  9. +2
    -1
      ironic/tests/unit/conductor/test_manager.py
  10. +1
    -1
      ironic/tests/unit/drivers/modules/irmc/test_boot.py
  11. +2
    -1
      ironic/tests/unit/drivers/test_generic.py
  12. +10
    -0
      releasenotes/notes/pxe-append-params-9cd5831959676371.yaml

+ 1
- 1
devstack/lib/ironic View File

@ -1717,7 +1717,7 @@ function configure_ironic_conductor {
pxe_params+=" $IRONIC_EXTRA_PXE_PARAMS"
if [[ -n "$pxe_params" ]]; then
iniset $IRONIC_CONF_FILE pxe pxe_append_params "$pxe_params"
iniset $IRONIC_CONF_FILE pxe kernel_append_params "$pxe_params"
fi
local kernel_append_params="nofb nomodeset console=${IRONIC_TTY_DEV}"


+ 9
- 4
doc/source/install/include/kernel-boot-parameters.inc View File

@ -13,11 +13,16 @@ Network boot
Currently, the Bare Metal service supports assigning unified kernel parameters to PXE
booted instances by:
* Modifying the ``[pxe]/pxe_append_params`` configuration option, for example::
* Modifying the ``[pxe]/kernel_append_params`` configuration option, for
example:
.. code-block:: ini
[pxe]
kernel_append_params = quiet splash
pxe_append_params = quiet splash
.. note::
The option was called ``pxe_append_params`` before the Xena cycle.
* Copying a template from shipped templates to another place, for example::
@ -86,7 +91,7 @@ respectively.
[pxe]
# Additional append parameters for baremetal PXE boot.
pxe_append_params = nofb nomodeset vga=normal console=ttyS0,115200n8
kernel_append_params = nofb nomodeset vga=normal console=ttyS0,115200n8
* For node web console configuration is similar with the addition of ``ttyX``
@ -95,7 +100,7 @@ respectively.
[pxe]
# Additional append parameters for baremetal PXE boot.
pxe_append_params = nofb nomodeset vga=normal console=tty0 console=ttyS0,115200n8
kernel_append_params = nofb nomodeset vga=normal console=tty0 console=ttyS0,115200n8
For detailed information on how to add consoles see the reference documents
`kernel params`_ and `serial console`_.


+ 4
- 2
ironic/common/pxe_utils.py View File

@ -38,6 +38,7 @@ from ironic.conf import CONF
from ironic.drivers.modules import boot_mode_utils
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules import image_cache
from ironic.drivers import utils as driver_utils
from ironic import objects
LOG = logging.getLogger(__name__)
@ -831,10 +832,11 @@ def build_instance_pxe_options(task, pxe_info, ipxe_enabled=False):
return pxe_opts
def build_extra_pxe_options(task=None, ramdisk_params=None):
def build_extra_pxe_options(task, ramdisk_params=None):
pxe_append_params = driver_utils.get_kernel_append_params(
task.node, default=CONF.pxe.kernel_append_params)
# Enable debug in IPA according to CONF.debug if it was not
# specified yet
pxe_append_params = CONF.pxe.pxe_append_params
if CONF.debug and 'ipa-debug' not in pxe_append_params:
pxe_append_params += ' ipa-debug=1'
if ramdisk_params:


+ 2
- 1
ironic/conf/pxe.py View File

@ -21,7 +21,8 @@ from oslo_config import cfg
from ironic.common.i18n import _
opts = [
cfg.StrOpt('pxe_append_params',
cfg.StrOpt('kernel_append_params',
deprecated_name='pxe_append_params',
default='nofb nomodeset vga=normal',
mutable=True,
help=_('Additional append parameters for baremetal PXE boot.')),


+ 2
- 1
ironic/drivers/modules/irmc/boot.py View File

@ -308,7 +308,8 @@ def _prepare_boot_iso(task, root_uuid):
deploy_iso_href = deploy_info['irmc_deploy_iso']
boot_mode = boot_mode_utils.get_boot_mode(task.node)
kernel_params = CONF.pxe.pxe_append_params
# FIXME(dtantsur): why is iRMC virtual media using PXE options?
kernel_params = CONF.pxe.kernel_append_params
boot_iso_filename = _get_iso_name(task.node, label='boot')
boot_iso_fullpathname = os.path.join(


+ 10
- 0
ironic/drivers/modules/pxe_base.py View File

@ -51,9 +51,19 @@ RESCUE_PROPERTIES = {
'that is used at node rescue time. This value is '
'required for rescue mode.'),
}
OPTIONAL_PROPERTIES = {
'kernel_append_params': _("Additional kernel parameters to pass down to "
"instance kernel. These parameters can be "
"consumed by the kernel or by the applications "
"by reading /proc/cmdline. Mind severe cmdline "
"size limit. Overrides "
"[pxe]/kernel_append_params ironic "
"option."),
}
COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy()
COMMON_PROPERTIES.update(driver_utils.OPTIONAL_PROPERTIES)
COMMON_PROPERTIES.update(RESCUE_PROPERTIES)
COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
class PXEBaseMixin(object):


+ 20
- 0
ironic/drivers/utils.py View File

@ -384,3 +384,23 @@ OPTIONAL_PROPERTIES = {
"deprecated in favor of the new ones."
"Defaults to 'Default'. Optional."),
}
def get_kernel_append_params(node, default):
"""Get the applicable kernel params.
The locations are checked in this order:
1. The node's instance_info.
2. The node's driver_info.
3. Configuration.
:param node: Node object.
:param default: Default value.
"""
for location in ('instance_info', 'driver_info'):
result = getattr(node, location).get('kernel_append_params')
if result is not None:
return result
return default

+ 23
- 5
ironic/tests/unit/common/test_pxe_utils.py View File

@ -1452,9 +1452,10 @@ class PXEBuildConfigOptionsTestCase(db_base.DbTestCase):
def _test_build_pxe_config_options_pxe(self, render_mock,
whle_dsk_img=False,
debug=False, mode='deploy',
ramdisk_params=None):
ramdisk_params=None,
expected_pxe_params=None):
self.config(debug=debug)
self.config(pxe_append_params='test_param', group='pxe')
self.config(kernel_append_params='test_param', group='pxe')
driver_internal_info = self.node.driver_internal_info
driver_internal_info['is_whole_disk_image'] = whle_dsk_img
@ -1498,7 +1499,8 @@ class PXEBuildConfigOptionsTestCase(db_base.DbTestCase):
'ramdisk'))
})
expected_pxe_params = 'test_param'
if expected_pxe_params is None:
expected_pxe_params = 'test_param'
if debug:
expected_pxe_params += ' ipa-debug=1'
if ramdisk_params:
@ -1554,6 +1556,22 @@ class PXEBuildConfigOptionsTestCase(db_base.DbTestCase):
self.node.save()
self._test_build_pxe_config_options_pxe(whle_dsk_img=False)
def test_build_pxe_config_options_kernel_params_from_driver_info(self):
info = self.node.driver_info
info['kernel_append_params'] = 'params2'
self.node.driver_info = info
self.node.save()
self._test_build_pxe_config_options_pxe(whle_dsk_img=True,
expected_pxe_params='params2')
def test_build_pxe_config_options_kernel_params_from_instance_info(self):
info = self.node.instance_info
info['kernel_append_params'] = 'params2'
self.node.instance_info = info
self.node.save()
self._test_build_pxe_config_options_pxe(whle_dsk_img=True,
expected_pxe_params='params2')
def test_build_pxe_config_options_ramdisk_params(self):
self._test_build_pxe_config_options_pxe(whle_dsk_img=True,
ramdisk_params={'foo': 'bar'})
@ -1562,7 +1580,7 @@ class PXEBuildConfigOptionsTestCase(db_base.DbTestCase):
del self.node.driver_internal_info['is_whole_disk_image']
self.node.save()
pxe_params = 'my-pxe-append-params ipa-debug=0'
self.config(group='pxe', pxe_append_params=pxe_params)
self.config(group='pxe', kernel_append_params=pxe_params)
self.config(group='pxe', tftp_server='my-tftp-server')
self.config(group='pxe', tftp_root='/tftp-path/')
image_info = {
@ -1717,7 +1735,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
iso_boot=False,
multipath=False):
self.config(debug=debug)
self.config(pxe_append_params='test_param', group='pxe')
self.config(kernel_append_params='test_param', group='pxe')
self.config(ipxe_timeout=ipxe_timeout, group='pxe')
root_dir = CONF.deploy.http_root


+ 2
- 1
ironic/tests/unit/conductor/test_manager.py View File

@ -5695,7 +5695,8 @@ class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
'image_http_proxy', 'image_https_proxy',
'image_no_proxy'])
if pxe_common:
expected.extend(['rescue_kernel', 'rescue_ramdisk'])
expected.extend(['kernel_append_params',
'rescue_kernel', 'rescue_ramdisk'])
expected.append('force_persistent_boot_device')
self.assertCountEqual(expected, properties)


+ 1
- 1
ironic/tests/unit/drivers/modules/irmc/test_boot.py View File

@ -492,7 +492,7 @@ class IRMCDeployPrivateMethodsTestCase(test_common.BaseIRMCTest):
boot_mode_mock,
create_boot_iso_mock,
check_share_fs_mounted_mock):
CONF.pxe.pxe_append_params = 'kernel-params'
self.config(kernel_append_params='kernel-params', group='pxe')
deploy_info_mock.return_value = \
{'image_source': 'image-uuid',


+ 2
- 1
ironic/tests/unit/drivers/test_generic.py View File

@ -72,7 +72,8 @@ class ManualManagementHardwareTestCase(db_base.DbTestCase):
'deploy_kernel', 'deploy_ramdisk',
'image_download_source', 'image_http_proxy',
'image_https_proxy', 'image_no_proxy',
'force_persistent_boot_device', 'rescue_kernel', 'rescue_ramdisk']
'force_persistent_boot_device', 'kernel_append_params',
'rescue_kernel', 'rescue_ramdisk']
hardware_type = driver_factory.get_hardware_type("manual-management")
properties = hardware_type.get_properties()
self.assertCountEqual(expected_prop_keys, properties)


+ 10
- 0
releasenotes/notes/pxe-append-params-9cd5831959676371.yaml View File

@ -0,0 +1,10 @@
---
features:
- |
Adds support for setting kernel parameters for PXE and iPXE boot through
the new ``kernel_append_params`` setting in the node's ``driver_info`` or
``instance_info``.
deprecations:
- |
The configuration option ``[pxe]pxe_append_params`` has been renamed to
``[pxe]kernel_append_params``. The old name is now deprecated.

Loading…
Cancel
Save