summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-02-07 15:02:43 +0000
committerGerrit Code Review <review@openstack.org>2020-02-07 15:02:43 +0000
commita50a1d0e5b14c98ba4832d9eb84d16930c3282e6 (patch)
treefe97820d09ae93d37dfd6a19cbdeea45a7c2f406
parent8c4571acf7abb54e4a50b0ef3c75b8bf5120176f (diff)
parentf61624e0693a0b2ccba46b271d0fb83e191f5077 (diff)
downloadironic-a50a1d0e5b14c98ba4832d9eb84d16930c3282e6.tar.gz
Merge "Fix ipxe interface to perform ipxe boot without ipxe_enabled enabled"
-rw-r--r--ironic/common/pxe_utils.py20
-rw-r--r--ironic/drivers/modules/storage/cinder.py9
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py24
-rw-r--r--ironic/tests/unit/drivers/modules/test_ipxe.py6
-rw-r--r--ironic/tests/unit/drivers/modules/test_pxe.py2
-rw-r--r--releasenotes/notes/fix-ipxe-interface-without-opt-enabled-4fa2f83975295e20.yaml6
6 files changed, 31 insertions, 36 deletions
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 106252332..b16a01102 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -61,10 +61,7 @@ KERNEL_RAMDISK_LABELS = {'deploy': DEPLOY_KERNEL_RAMDISK_LABELS,
def get_root_dir():
"""Returns the directory where the config files and images will live."""
- if CONF.pxe.ipxe_enabled:
- return CONF.deploy.http_root
- else:
- return CONF.pxe.tftp_root
+ return CONF.pxe.tftp_root
def get_ipxe_root_dir():
@@ -117,7 +114,8 @@ def _link_mac_pxe_configs(task, ipxe_enabled=False):
create_link(_get_pxe_mac_path(port.address, client_id=client_id,
ipxe_enabled=ipxe_enabled))
# Grub2 MAC address only
- create_link(_get_pxe_grub_mac_path(port.address))
+ create_link(_get_pxe_grub_mac_path(port.address,
+ ipxe_enabled=ipxe_enabled))
def _link_ip_address_pxe_configs(task, ipxe_enabled=False):
@@ -158,8 +156,9 @@ def _link_ip_address_pxe_configs(task, ipxe_enabled=False):
ip_address_path)
-def _get_pxe_grub_mac_path(mac):
- return os.path.join(get_root_dir(), mac + '.conf')
+def _get_pxe_grub_mac_path(mac, ipxe_enabled=False):
+ root_dir = get_ipxe_root_dir() if ipxe_enabled else get_root_dir()
+ return os.path.join(root_dir, mac + '.conf')
def _get_pxe_mac_path(mac, delimiter='-', client_id=None,
@@ -367,7 +366,7 @@ def clean_up_pxe_config(task, ipxe_enabled=False):
ipxe_enabled=ipxe_enabled))
# Grub2 MAC address based confiuration
ironic_utils.unlink_without_raise(
- _get_pxe_grub_mac_path(port.address))
+ _get_pxe_grub_mac_path(port.address, ipxe_enabled=ipxe_enabled))
if ipxe_enabled:
utils.rmtree_without_raise(os.path.join(get_ipxe_root_dir(),
task.node.uuid))
@@ -786,7 +785,8 @@ def build_service_pxe_config(task, instance_image_info,
ramdisk_boot=False,
ipxe_enabled=False):
node = task.node
- pxe_config_path = get_pxe_config_file_path(node.uuid)
+ pxe_config_path = get_pxe_config_file_path(node.uuid,
+ ipxe_enabled=ipxe_enabled)
# NOTE(pas-ha) if it is takeover of ACTIVE node or node performing
# unrescue operation, first ensure that basic PXE configs and links
# are in place before switching pxe config
@@ -924,7 +924,7 @@ def prepare_instance_pxe_config(task, image_info,
provider = dhcp_factory.DHCPFactory()
provider.update_dhcp(task, dhcp_opts)
pxe_config_path = get_pxe_config_file_path(
- node.uuid)
+ node.uuid, ipxe_enabled=ipxe_enabled)
if not os.path.isfile(pxe_config_path):
pxe_options = build_pxe_config_options(
task, image_info, service=ramdisk_boot,
diff --git a/ironic/drivers/modules/storage/cinder.py b/ironic/drivers/modules/storage/cinder.py
index e2a0a7731..d27614869 100644
--- a/ironic/drivers/modules/storage/cinder.py
+++ b/ironic/drivers/modules/storage/cinder.py
@@ -21,6 +21,7 @@ import retrying
from ironic.common import cinder
from ironic.common import exception
from ironic.common.i18n import _
+from ironic.common import pxe_utils
from ironic.common import states
from ironic.drivers import base
from ironic.drivers import utils
@@ -76,13 +77,7 @@ class CinderStorage(base.StorageInterface):
iscsi_uuids_found = []
wwpn_found = 0
wwnn_found = 0
- ipxe_enabled = False
- if 'pxe_boot' in task.driver.boot.capabilities:
- if CONF.pxe.ipxe_enabled:
- ipxe_enabled = True
- elif 'ipxe_boot' in task.driver.boot.capabilities:
- ipxe_enabled = True
-
+ ipxe_enabled = pxe_utils.is_ipxe_enabled(task)
for connector in task.volume_connectors:
if (connector.type in VALID_ISCSI_TYPES
and connector.connector_id is not None):
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 851f14b0a..62980dfcd 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -638,16 +638,9 @@ class TestPXEUtils(db_base.DbTestCase):
def test_get_root_dir(self):
expected_dir = '/tftproot'
- self.config(ipxe_enabled=False, group='pxe')
self.config(tftp_root=expected_dir, group='pxe')
self.assertEqual(expected_dir, pxe_utils.get_root_dir())
- def test_get_root_dir_ipxe(self):
- expected_dir = '/httpboot'
- self.config(ipxe_enabled=True, group='pxe')
- self.config(http_root=expected_dir, group='deploy')
- self.assertEqual(expected_dir, pxe_utils.get_root_dir())
-
def test_get_pxe_config_file_path(self):
self.assertEqual(os.path.join(CONF.pxe.tftp_root,
self.node.uuid,
@@ -699,7 +692,8 @@ class TestPXEUtils(db_base.DbTestCase):
self.config(tftp_server='ff80::1', group='pxe')
self._dhcp_options_for_instance(ip_version=6)
- def _test_get_kernel_ramdisk_info(self, expected_dir, mode='deploy'):
+ def _test_get_kernel_ramdisk_info(self, expected_dir, mode='deploy',
+ ipxe_enabled=False):
node_uuid = 'fake-node'
driver_info = {
@@ -712,7 +706,8 @@ class TestPXEUtils(db_base.DbTestCase):
expected[k] = (v, expected_dir + '/fake-node/%s' % k)
kr_info = pxe_utils.get_kernel_ramdisk_info(node_uuid,
driver_info,
- mode=mode)
+ mode=mode,
+ ipxe_enabled=ipxe_enabled)
self.assertEqual(expected, kr_info)
def test_get_kernel_ramdisk_info(self):
@@ -722,9 +717,8 @@ class TestPXEUtils(db_base.DbTestCase):
def test_get_kernel_ramdisk_info_ipxe(self):
expected_dir = '/http'
- self.config(ipxe_enabled=True, group='pxe')
self.config(http_root=expected_dir, group='deploy')
- self._test_get_kernel_ramdisk_info(expected_dir)
+ self._test_get_kernel_ramdisk_info(expected_dir, ipxe_enabled=True)
def test_get_kernel_ramdisk_info_bad_driver_info(self):
self.config(tftp_root='/tftp', group='pxe')
@@ -742,9 +736,9 @@ class TestPXEUtils(db_base.DbTestCase):
def test_get_rescue_kr_info_ipxe(self):
expected_dir = '/http'
- self.config(ipxe_enabled=True, group='pxe')
self.config(http_root=expected_dir, group='deploy')
- self._test_get_kernel_ramdisk_info(expected_dir, mode='rescue')
+ self._test_get_kernel_ramdisk_info(expected_dir, mode='rescue',
+ ipxe_enabled=True)
def _dhcp_options_for_instance_ipxe(self, task, boot_file, ip_version=4):
self.config(ipxe_enabled=True, group='pxe')
@@ -1647,13 +1641,13 @@ class PXEInterfacesTestCase(db_base.DbTestCase):
@mock.patch.object(deploy_utils, 'fetch_images', autospec=True)
def test_cache_ramdisk_kernel_ipxe(self, mock_fetch_image,
mock_ensure_tree):
- self.config(ipxe_enabled=True, group='pxe')
fake_pxe_info = {'foo': 'bar'}
expected_path = os.path.join(CONF.deploy.http_root,
self.node.uuid)
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
- pxe_utils.cache_ramdisk_kernel(task, fake_pxe_info)
+ pxe_utils.cache_ramdisk_kernel(task, fake_pxe_info,
+ ipxe_enabled=True)
mock_ensure_tree.assert_called_with(expected_path)
mock_fetch_image.assert_called_once_with(self.context, mock.ANY,
list(fake_pxe_info.values()),
diff --git a/ironic/tests/unit/drivers/modules/test_ipxe.py b/ironic/tests/unit/drivers/modules/test_ipxe.py
index ceb6e4616..64e5393b0 100644
--- a/ironic/tests/unit/drivers/modules/test_ipxe.py
+++ b/ironic/tests/unit/drivers/modules/test_ipxe.py
@@ -635,7 +635,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
dhcp_opts = pxe_utils.dhcp_options_for_instance(
task, ipxe_enabled=True)
pxe_config_path = pxe_utils.get_pxe_config_file_path(
- task.node.uuid)
+ task.node.uuid, ipxe_enabled=True)
task.node.properties['capabilities'] = 'boot_mode:bios'
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
"30212642-09d3-467f-8e09-21685826ab50")
@@ -677,7 +677,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
dhcp_opts = pxe_utils.dhcp_options_for_instance(
task, ipxe_enabled=True)
pxe_config_path = pxe_utils.get_pxe_config_file_path(
- task.node.uuid)
+ task.node.uuid, ipxe_enabled=True)
task.node.properties['capabilities'] = 'boot_mode:bios'
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
"30212642-09d3-467f-8e09-21685826ab50")
@@ -792,7 +792,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
ipxe_enabled=True)
pxe_config_path = pxe_utils.get_pxe_config_file_path(
- task.node.uuid)
+ task.node.uuid, ipxe_enabled=True)
task.node.properties['capabilities'] = 'boot_mode:bios'
task.driver.boot.prepare_instance(task)
self.assertFalse(get_image_info_mock.called)
diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py
index fcf01ceb7..09d149988 100644
--- a/ironic/tests/unit/drivers/modules/test_pxe.py
+++ b/ironic/tests/unit/drivers/modules/test_pxe.py
@@ -792,7 +792,7 @@ class PXEBootTestCase(db_base.DbTestCase):
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
ipxe_enabled=True)
pxe_config_path = pxe_utils.get_pxe_config_file_path(
- task.node.uuid)
+ task.node.uuid, ipxe_enabled=True)
task.node.properties['capabilities'] = 'boot_mode:bios'
task.driver.boot.prepare_instance(task)
self.assertFalse(get_image_info_mock.called)
diff --git a/releasenotes/notes/fix-ipxe-interface-without-opt-enabled-4fa2f83975295e20.yaml b/releasenotes/notes/fix-ipxe-interface-without-opt-enabled-4fa2f83975295e20.yaml
new file mode 100644
index 000000000..94d86d6df
--- /dev/null
+++ b/releasenotes/notes/fix-ipxe-interface-without-opt-enabled-4fa2f83975295e20.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Fixes an issue that when ``ipxe`` interface is in use with
+ ``[pxe]ipxe_enabled`` set to false, the PXE configuration is not handled
+ properly which prevents the machine from performing a successful iPXE boot.