Fix ipxe interface to perform ipxe boot without ipxe_enabled enabled
When ipxe hardware interface is in use, the node should always be boot with iPXE disregards the deprecated configuration option [pxe]ipxe_enabled. Story: 2007003 Task: 37779 Change-Id: Ia658ddc966e13a7ce973eccd9c42e40a3da406f4
This commit is contained in:
@@ -61,10 +61,7 @@ KERNEL_RAMDISK_LABELS = {'deploy': DEPLOY_KERNEL_RAMDISK_LABELS,
|
|||||||
|
|
||||||
def get_root_dir():
|
def get_root_dir():
|
||||||
"""Returns the directory where the config files and images will live."""
|
"""Returns the directory where the config files and images will live."""
|
||||||
if CONF.pxe.ipxe_enabled:
|
return CONF.pxe.tftp_root
|
||||||
return CONF.deploy.http_root
|
|
||||||
else:
|
|
||||||
return CONF.pxe.tftp_root
|
|
||||||
|
|
||||||
|
|
||||||
def get_ipxe_root_dir():
|
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,
|
create_link(_get_pxe_mac_path(port.address, client_id=client_id,
|
||||||
ipxe_enabled=ipxe_enabled))
|
ipxe_enabled=ipxe_enabled))
|
||||||
# Grub2 MAC address only
|
# 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):
|
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)
|
ip_address_path)
|
||||||
|
|
||||||
|
|
||||||
def _get_pxe_grub_mac_path(mac):
|
def _get_pxe_grub_mac_path(mac, ipxe_enabled=False):
|
||||||
return os.path.join(get_root_dir(), mac + '.conf')
|
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,
|
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))
|
ipxe_enabled=ipxe_enabled))
|
||||||
# Grub2 MAC address based confiuration
|
# Grub2 MAC address based confiuration
|
||||||
ironic_utils.unlink_without_raise(
|
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:
|
if ipxe_enabled:
|
||||||
utils.rmtree_without_raise(os.path.join(get_ipxe_root_dir(),
|
utils.rmtree_without_raise(os.path.join(get_ipxe_root_dir(),
|
||||||
task.node.uuid))
|
task.node.uuid))
|
||||||
@@ -786,7 +785,8 @@ def build_service_pxe_config(task, instance_image_info,
|
|||||||
ramdisk_boot=False,
|
ramdisk_boot=False,
|
||||||
ipxe_enabled=False):
|
ipxe_enabled=False):
|
||||||
node = task.node
|
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
|
# NOTE(pas-ha) if it is takeover of ACTIVE node or node performing
|
||||||
# unrescue operation, first ensure that basic PXE configs and links
|
# unrescue operation, first ensure that basic PXE configs and links
|
||||||
# are in place before switching pxe config
|
# are in place before switching pxe config
|
||||||
@@ -924,7 +924,7 @@ def prepare_instance_pxe_config(task, image_info,
|
|||||||
provider = dhcp_factory.DHCPFactory()
|
provider = dhcp_factory.DHCPFactory()
|
||||||
provider.update_dhcp(task, dhcp_opts)
|
provider.update_dhcp(task, dhcp_opts)
|
||||||
pxe_config_path = get_pxe_config_file_path(
|
pxe_config_path = get_pxe_config_file_path(
|
||||||
node.uuid)
|
node.uuid, ipxe_enabled=ipxe_enabled)
|
||||||
if not os.path.isfile(pxe_config_path):
|
if not os.path.isfile(pxe_config_path):
|
||||||
pxe_options = build_pxe_config_options(
|
pxe_options = build_pxe_config_options(
|
||||||
task, image_info, service=ramdisk_boot,
|
task, image_info, service=ramdisk_boot,
|
||||||
|
@@ -21,6 +21,7 @@ import retrying
|
|||||||
from ironic.common import cinder
|
from ironic.common import cinder
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common.i18n import _
|
from ironic.common.i18n import _
|
||||||
|
from ironic.common import pxe_utils
|
||||||
from ironic.common import states
|
from ironic.common import states
|
||||||
from ironic.drivers import base
|
from ironic.drivers import base
|
||||||
from ironic.drivers import utils
|
from ironic.drivers import utils
|
||||||
@@ -76,13 +77,7 @@ class CinderStorage(base.StorageInterface):
|
|||||||
iscsi_uuids_found = []
|
iscsi_uuids_found = []
|
||||||
wwpn_found = 0
|
wwpn_found = 0
|
||||||
wwnn_found = 0
|
wwnn_found = 0
|
||||||
ipxe_enabled = False
|
ipxe_enabled = pxe_utils.is_ipxe_enabled(task)
|
||||||
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
|
|
||||||
|
|
||||||
for connector in task.volume_connectors:
|
for connector in task.volume_connectors:
|
||||||
if (connector.type in VALID_ISCSI_TYPES
|
if (connector.type in VALID_ISCSI_TYPES
|
||||||
and connector.connector_id is not None):
|
and connector.connector_id is not None):
|
||||||
|
@@ -638,16 +638,9 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
|
|
||||||
def test_get_root_dir(self):
|
def test_get_root_dir(self):
|
||||||
expected_dir = '/tftproot'
|
expected_dir = '/tftproot'
|
||||||
self.config(ipxe_enabled=False, group='pxe')
|
|
||||||
self.config(tftp_root=expected_dir, group='pxe')
|
self.config(tftp_root=expected_dir, group='pxe')
|
||||||
self.assertEqual(expected_dir, pxe_utils.get_root_dir())
|
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):
|
def test_get_pxe_config_file_path(self):
|
||||||
self.assertEqual(os.path.join(CONF.pxe.tftp_root,
|
self.assertEqual(os.path.join(CONF.pxe.tftp_root,
|
||||||
self.node.uuid,
|
self.node.uuid,
|
||||||
@@ -699,7 +692,8 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
self.config(tftp_server='ff80::1', group='pxe')
|
self.config(tftp_server='ff80::1', group='pxe')
|
||||||
self._dhcp_options_for_instance(ip_version=6)
|
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'
|
node_uuid = 'fake-node'
|
||||||
|
|
||||||
driver_info = {
|
driver_info = {
|
||||||
@@ -712,7 +706,8 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
expected[k] = (v, expected_dir + '/fake-node/%s' % k)
|
expected[k] = (v, expected_dir + '/fake-node/%s' % k)
|
||||||
kr_info = pxe_utils.get_kernel_ramdisk_info(node_uuid,
|
kr_info = pxe_utils.get_kernel_ramdisk_info(node_uuid,
|
||||||
driver_info,
|
driver_info,
|
||||||
mode=mode)
|
mode=mode,
|
||||||
|
ipxe_enabled=ipxe_enabled)
|
||||||
self.assertEqual(expected, kr_info)
|
self.assertEqual(expected, kr_info)
|
||||||
|
|
||||||
def test_get_kernel_ramdisk_info(self):
|
def test_get_kernel_ramdisk_info(self):
|
||||||
@@ -722,9 +717,8 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
|
|
||||||
def test_get_kernel_ramdisk_info_ipxe(self):
|
def test_get_kernel_ramdisk_info_ipxe(self):
|
||||||
expected_dir = '/http'
|
expected_dir = '/http'
|
||||||
self.config(ipxe_enabled=True, group='pxe')
|
|
||||||
self.config(http_root=expected_dir, group='deploy')
|
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):
|
def test_get_kernel_ramdisk_info_bad_driver_info(self):
|
||||||
self.config(tftp_root='/tftp', group='pxe')
|
self.config(tftp_root='/tftp', group='pxe')
|
||||||
@@ -742,9 +736,9 @@ class TestPXEUtils(db_base.DbTestCase):
|
|||||||
|
|
||||||
def test_get_rescue_kr_info_ipxe(self):
|
def test_get_rescue_kr_info_ipxe(self):
|
||||||
expected_dir = '/http'
|
expected_dir = '/http'
|
||||||
self.config(ipxe_enabled=True, group='pxe')
|
|
||||||
self.config(http_root=expected_dir, group='deploy')
|
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):
|
def _dhcp_options_for_instance_ipxe(self, task, boot_file, ip_version=4):
|
||||||
self.config(ipxe_enabled=True, group='pxe')
|
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)
|
@mock.patch.object(deploy_utils, 'fetch_images', autospec=True)
|
||||||
def test_cache_ramdisk_kernel_ipxe(self, mock_fetch_image,
|
def test_cache_ramdisk_kernel_ipxe(self, mock_fetch_image,
|
||||||
mock_ensure_tree):
|
mock_ensure_tree):
|
||||||
self.config(ipxe_enabled=True, group='pxe')
|
|
||||||
fake_pxe_info = {'foo': 'bar'}
|
fake_pxe_info = {'foo': 'bar'}
|
||||||
expected_path = os.path.join(CONF.deploy.http_root,
|
expected_path = os.path.join(CONF.deploy.http_root,
|
||||||
self.node.uuid)
|
self.node.uuid)
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
shared=True) as task:
|
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_ensure_tree.assert_called_with(expected_path)
|
||||||
mock_fetch_image.assert_called_once_with(self.context, mock.ANY,
|
mock_fetch_image.assert_called_once_with(self.context, mock.ANY,
|
||||||
list(fake_pxe_info.values()),
|
list(fake_pxe_info.values()),
|
||||||
|
@@ -635,7 +635,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
|
|||||||
dhcp_opts = pxe_utils.dhcp_options_for_instance(
|
dhcp_opts = pxe_utils.dhcp_options_for_instance(
|
||||||
task, ipxe_enabled=True)
|
task, ipxe_enabled=True)
|
||||||
pxe_config_path = pxe_utils.get_pxe_config_file_path(
|
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.properties['capabilities'] = 'boot_mode:bios'
|
||||||
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
|
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
|
||||||
"30212642-09d3-467f-8e09-21685826ab50")
|
"30212642-09d3-467f-8e09-21685826ab50")
|
||||||
@@ -677,7 +677,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
|
|||||||
dhcp_opts = pxe_utils.dhcp_options_for_instance(
|
dhcp_opts = pxe_utils.dhcp_options_for_instance(
|
||||||
task, ipxe_enabled=True)
|
task, ipxe_enabled=True)
|
||||||
pxe_config_path = pxe_utils.get_pxe_config_file_path(
|
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.properties['capabilities'] = 'boot_mode:bios'
|
||||||
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
|
task.node.driver_internal_info['root_uuid_or_disk_id'] = (
|
||||||
"30212642-09d3-467f-8e09-21685826ab50")
|
"30212642-09d3-467f-8e09-21685826ab50")
|
||||||
@@ -792,7 +792,7 @@ class iPXEBootTestCase(db_base.DbTestCase):
|
|||||||
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
|
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
|
||||||
ipxe_enabled=True)
|
ipxe_enabled=True)
|
||||||
pxe_config_path = pxe_utils.get_pxe_config_file_path(
|
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.properties['capabilities'] = 'boot_mode:bios'
|
||||||
task.driver.boot.prepare_instance(task)
|
task.driver.boot.prepare_instance(task)
|
||||||
self.assertFalse(get_image_info_mock.called)
|
self.assertFalse(get_image_info_mock.called)
|
||||||
|
@@ -792,7 +792,7 @@ class PXEBootTestCase(db_base.DbTestCase):
|
|||||||
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
|
dhcp_opts = pxe_utils.dhcp_options_for_instance(task,
|
||||||
ipxe_enabled=True)
|
ipxe_enabled=True)
|
||||||
pxe_config_path = pxe_utils.get_pxe_config_file_path(
|
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.properties['capabilities'] = 'boot_mode:bios'
|
||||||
task.driver.boot.prepare_instance(task)
|
task.driver.boot.prepare_instance(task)
|
||||||
self.assertFalse(get_image_info_mock.called)
|
self.assertFalse(get_image_info_mock.called)
|
||||||
|
@@ -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.
|
Reference in New Issue
Block a user