Merge "Add pxe template per node"

This commit is contained in:
Zuul 2019-01-21 14:14:35 +00:00 committed by Gerrit Code Review
commit 2dacda772b
3 changed files with 27 additions and 8 deletions

View File

@ -735,19 +735,22 @@ def get_pxe_config_template(node):
"""Return the PXE config template file name requested for deploy.
This method returns PXE config template file to be used for deploy.
Architecture specific template file is searched first. BIOS/UEFI
template file is used if no valid architecture specific file found.
First specific pxe template is searched in the node. After that
architecture specific template file is searched. BIOS/UEFI template file
is used if no valid architecture specific file found.
:param node: A single Node.
:returns: The PXE config template file name.
"""
cpu_arch = node.properties.get('cpu_arch')
config_template = CONF.pxe.pxe_config_template_by_arch.get(cpu_arch)
config_template = node.driver_info.get("pxe_template", None)
if config_template is None:
if boot_mode_utils.get_boot_mode(node) == 'uefi':
config_template = CONF.pxe.uefi_pxe_config_template
else:
config_template = CONF.pxe.pxe_config_template
cpu_arch = node.properties.get('cpu_arch')
config_template = CONF.pxe.pxe_config_template_by_arch.get(cpu_arch)
if config_template is None:
if boot_mode_utils.get_boot_mode(node) == 'uefi':
config_template = CONF.pxe.uefi_pxe_config_template
else:
config_template = CONF.pxe.pxe_config_template
return config_template

View File

@ -1113,6 +1113,14 @@ class GetPxeBootConfigTestCase(db_base.DbTestCase):
result = utils.get_pxe_config_template(self.node)
self.assertEqual('bios-template', result)
def test_get_pxe_config_template_per_node(self):
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
driver_info={"pxe_template": "fake-template"},
)
result = utils.get_pxe_config_template(node)
self.assertEqual('fake-template', result)
@mock.patch('time.sleep', lambda sec: None)
class OtherFunctionTestCase(db_base.DbTestCase):

View File

@ -0,0 +1,8 @@
---
features:
- |
Add a new field pxe_template that can be set at driver-info level. This
will specify a path for a custom pxe boot template. If present, this
template will be read and will have priority in front of the per-arch and
general pxe templates.