Add pxe template per node

Allow to pass a pxe_template field in driver_info. If that is
present, it will search for the template file specified there,
instead of checking the per-arch/agent templates.

Change-Id: I436a61ad6a3e688bc6f833f5645c99be6d7e26e7
Story: #2004525
Task: #28264
This commit is contained in:
Yolanda Robla 2018-12-17 12:15:00 +01:00 committed by yolanda.robla
parent fec97d9156
commit 0bda09acf4
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.