From cfa2ddf99ca829dd6282be74dac30c521b17a919 Mon Sep 17 00:00:00 2001
From: Julia Kreger <juliaashleykreger@gmail.com>
Date: Mon, 16 Jul 2018 12:21:42 -0700
Subject: [PATCH] Make pxelinux.cfg folder configurable

Some operators may wish to utilize different default folders
for their bootloaders to search for refernces to the asociated
configuration file.

This patch adds an option to the configuration file that allows
operators to change the default.

Change-Id: I9b8f97868aea74c1b1b458fe8f16ada1ff4ea579
---
 ironic/common/pxe_utils.py                             |  2 +-
 ironic/conf/pxe.py                                     |  7 +++++++
 ...x-config-folder-to-be-defined-da0ddd397d58dcc8.yaml | 10 ++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 releasenotes/notes/allow-pxelinux-config-folder-to-be-defined-da0ddd397d58dcc8.yaml

diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 34f79ada84..c3ce89a370 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -32,7 +32,7 @@ CONF = cfg.CONF
 
 LOG = logging.getLogger(__name__)
 
-PXE_CFG_DIR_NAME = 'pxelinux.cfg'
+PXE_CFG_DIR_NAME = CONF.pxe.pxe_config_subdir
 
 DHCP_CLIENT_ID = '61'  # rfc2132
 DHCP_TFTP_SERVER_NAME = '66'  # rfc2132
diff --git a/ironic/conf/pxe.py b/ironic/conf/pxe.py
index a893e1509b..1a2454327d 100644
--- a/ironic/conf/pxe.py
+++ b/ironic/conf/pxe.py
@@ -92,6 +92,13 @@ opts = [
     cfg.StrOpt('pxe_bootfile_name',
                default='pxelinux.0',
                help=_('Bootfile DHCP parameter.')),
+    cfg.StrOpt('pxe_config_subdir',
+               default='pxelinux.cfg',
+               help=_('Directory in which to create symbolic links which '
+                      'represent the MAC or IP address of the the ports on '
+                      'a node and allow boot loaders to load the PXE '
+                      'file for the node. This directory name is relative '
+                      'to the PXE or iPXE folders.')),
     cfg.StrOpt('uefi_pxe_bootfile_name',
                default='bootx64.efi',
                help=_('Bootfile DHCP parameter for UEFI boot mode.')),
diff --git a/releasenotes/notes/allow-pxelinux-config-folder-to-be-defined-da0ddd397d58dcc8.yaml b/releasenotes/notes/allow-pxelinux-config-folder-to-be-defined-da0ddd397d58dcc8.yaml
new file mode 100644
index 0000000000..93e481d331
--- /dev/null
+++ b/releasenotes/notes/allow-pxelinux-config-folder-to-be-defined-da0ddd397d58dcc8.yaml
@@ -0,0 +1,10 @@
+---
+features:
+  - |
+    Adds a new configuration option ``[pxe]pxe_config_subdir`` to allow
+    operators to define the specific directory that may be used inside of
+    ``/tftpboot`` or ``/httpboot`` for a boot loader to locate the
+    configuration file for the node. This option defaults to ``pxelinux.cfg``
+    which is the directory that the Syslinux `pxelinux.0` bootloader utilized.
+    Operators may wish to change the directory name if they are using other boot
+    loaders such as `GRUB` or `iPXE`.