From 4ec47b66602b4eb0b86ffd1fd69b70ef2bf16a25 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Tue, 12 May 2015 17:53:24 +0100 Subject: [PATCH] Fix chainloading iPXE (undionly.kpxe) This patch is making the neutron DHCP provider to explicitly check if the request is coming from iPXE before ACK'ing the PXE request with the iPXE script (When iPXE is enabled only). Also, update the documentation that explains how to configure neutron for iPXE to create the "ipxe" tag based on the DHCP user class or DHCP option 175 (as before). Change-Id: I60f9f515a9bd45aed6b2f6f9165a2f85259b3879 Closes-Bug: #1454332 --- doc/source/deploy/install-guide.rst | 9 +++++---- ironic/common/pxe_utils.py | 8 ++++---- ironic/tests/test_pxe_utils.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/source/deploy/install-guide.rst b/doc/source/deploy/install-guide.rst index 0a3f109b8c..b3f0aa7fcd 100644 --- a/doc/source/deploy/install-guide.rst +++ b/doc/source/deploy/install-guide.rst @@ -849,12 +849,13 @@ DHCP client to chainload the iPXE image (undionly.kpxe). Neutron needs to be configured to create this DHCP tag, since it isn't create by default. #. Create a custom ``dnsmasq.conf`` file with a setting for the ipxe tag. For - example, the following creates the file ``/etc/dnsmasq-ironic.conf`` :: + example, create the file ``/etc/dnsmasq-ironic.conf`` with the content:: - cat > /etc/dnsmasq-ironic.conf << EOF - dhcp-match=ipxe,175 - EOF + # Create the "ipxe" tag if request comes from iPXE user class + dhcp-userclass=set:ipxe,iPXE + # Alternatively, create the "ipxe" tag if request comes from DHCP option 175 + # dhcp-match=set:ipxe,175 #. In the Neutron DHCP Agent configuration file (typically located at /etc/neutron/dhcp_agent.ini), set the custom ``/etc/dnsmasq-ironic.conf`` diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index 3791f96ee6..7895ac8871 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -260,15 +260,15 @@ def dhcp_options_for_instance(task): # to neutron "dhcp-match=set:ipxe,175" and use below option dhcp_opts.append({'opt_name': 'tag:!ipxe,bootfile-name', 'opt_value': CONF.pxe.pxe_bootfile_name}) + dhcp_opts.append({'opt_name': 'tag:ipxe,bootfile-name', + 'opt_value': ipxe_script_url}) else: # !175 == non-iPXE. # http://ipxe.org/howto/dhcpd#ipxe-specific_options dhcp_opts.append({'opt_name': '!175,bootfile-name', 'opt_value': CONF.pxe.pxe_bootfile_name}) - # If the request comes from iPXE, direct it to boot from the - # iPXE script - dhcp_opts.append({'opt_name': 'bootfile-name', - 'opt_value': ipxe_script_url}) + dhcp_opts.append({'opt_name': 'bootfile-name', + 'opt_value': ipxe_script_url}) else: if deploy_utils.get_boot_mode_for_deploy(task.node) == 'uefi': boot_file = CONF.pxe.uefi_pxe_bootfile_name diff --git a/ironic/tests/test_pxe_utils.py b/ironic/tests/test_pxe_utils.py index 4eb22c8e53..29ffaccf9e 100644 --- a/ironic/tests/test_pxe_utils.py +++ b/ironic/tests/test_pxe_utils.py @@ -358,7 +358,7 @@ class TestPXEUtils(db_base.DbTestCase): 'opt_value': '192.0.2.1'}, {'opt_name': 'tftp-server', 'opt_value': '192.0.2.1'}, - {'opt_name': 'bootfile-name', + {'opt_name': 'tag:ipxe,bootfile-name', 'opt_value': expected_boot_script_url}] with task_manager.acquire(self.context, self.node.uuid) as task: self.assertItemsEqual(expected_info,