summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/common/test_pxe_utils.py
diff options
context:
space:
mode:
authorMichael Turek <mjturek@linux.vnet.ibm.com>2016-09-28 14:18:53 +0000
committerMichael Turek <mjturek@linux.vnet.ibm.com>2016-11-07 15:19:08 +0000
commitf13959c03183ac7893387224d082360c1e9fcb51 (patch)
tree937a2f90965239ffd70d94ceb8c5ead587ed1572 /ironic/tests/unit/common/test_pxe_utils.py
parent9eb148ad371329dc97c2fd973ea5aeff1aef3b08 (diff)
downloadironic-f13959c03183ac7893387224d082360c1e9fcb51.tar.gz
Enable PXE for systems using petitboot
Petitboot systems do not use the pxelinux.0 loader. Instead, petitboot itself handles pxelinux functionality. A side effect of this is that petitboot requires DHCP option 210 (tftp path-prefix) as this information is normally derived from the boot file name. This patch uses the value of tftp_root as a path prefix and makes the PXE module honor that prefix. Change-Id: Ib9e954feea2cec38dd8328ada35005c0311c2a1b Closes-Bug: #1639187 Co-Authored-By: Michael Turek <mjturek@linux.vnet.ibm.com>
Diffstat (limited to 'ironic/tests/unit/common/test_pxe_utils.py')
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 781a69b8b..55fb553da 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -424,9 +424,13 @@ class TestPXEUtils(db_base.DbTestCase):
self.config(ip_version=ip_version, group='pxe')
self.config(tftp_server='192.0.2.1', group='pxe')
self.config(pxe_bootfile_name='fake-bootfile', group='pxe')
+ self.config(tftp_root='/tftp-path/', group='pxe')
expected_info = [{'opt_name': 'bootfile-name',
'opt_value': 'fake-bootfile',
'ip_version': ip_version},
+ {'opt_name': '210',
+ 'opt_value': '/tftp-path/',
+ 'ip_version': ip_version},
{'opt_name': 'server-ip-address',
'opt_value': '192.0.2.1',
'ip_version': ip_version},
@@ -603,3 +607,25 @@ class TestPXEUtils(db_base.DbTestCase):
'/httpboot/pxelinux.cfg/aa-aa-aa-aa-aa-aa')
rmtree_mock.assert_called_once_with(
os.path.join(CONF.deploy.http_root, self.node.uuid))
+
+ def test_get_tftp_path_prefix_with_trailing_slash(self):
+ self.config(tftp_root='/tftpboot-path/', group='pxe')
+ path_prefix = pxe_utils.get_tftp_path_prefix()
+ self.assertEqual(path_prefix, '/tftpboot-path/')
+
+ def test_get_tftp_path_prefix_without_trailing_slash(self):
+ self.config(tftp_root='/tftpboot-path', group='pxe')
+ path_prefix = pxe_utils.get_tftp_path_prefix()
+ self.assertEqual(path_prefix, '/tftpboot-path/')
+
+ def test_get_path_relative_to_tftp_root_with_trailing_slash(self):
+ self.config(tftp_root='/tftpboot-path/', group='pxe')
+ test_file_path = '/tftpboot-path/pxelinux.cfg/test'
+ relpath = pxe_utils.get_path_relative_to_tftp_root(test_file_path)
+ self.assertEqual(relpath, 'pxelinux.cfg/test')
+
+ def test_get_path_relative_to_tftp_root_without_trailing_slash(self):
+ self.config(tftp_root='/tftpboot-path', group='pxe')
+ test_file_path = '/tftpboot-path/pxelinux.cfg/test'
+ relpath = pxe_utils.get_path_relative_to_tftp_root(test_file_path)
+ self.assertEqual(relpath, 'pxelinux.cfg/test')