summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2022-02-10 18:11:15 +0100
committerDmitry Tantsur <dtantsur@protonmail.com>2022-02-15 12:59:57 +0000
commit968ecdb3f37ddbd380c15cf919018881357939d9 (patch)
treedcbde7349c32694a14c5380d44617e838bf5ebf9
parentb3883cd2774732a1d44f9fff3b3f466a05f761c8 (diff)
downloadironic-968ecdb3f37ddbd380c15cf919018881357939d9.tar.gz
Set correct initrd_filename for iPXE when using Swift
iPXE derives its "file names" from the last component of the URL path. In case of the conductor's local server it's {mode}_{component} where mode = deploy/rescue and component = kernel/ramdisk. However, in case of Swift/Ceph, the last component will be different. This patch accounts for it. Change-Id: I7ba5545032069509a9c302abe1c21537ccb5ec8a (cherry picked from commit c975eaa8c67d917feac75c9053cddcfb708e08a3)
-rw-r--r--ironic/common/pxe_utils.py8
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py11
-rw-r--r--releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml6
3 files changed, 20 insertions, 5 deletions
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 54439ce69..a22691620 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -17,6 +17,7 @@
import copy
import os
import tempfile
+from urllib import parse as urlparse
from ironic_lib import utils as ironic_utils
import jinja2
@@ -767,6 +768,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy',
node = task.node
kernel_label = '%s_kernel' % mode
ramdisk_label = '%s_ramdisk' % mode
+ initrd_filename = ramdisk_label
for label, option in ((kernel_label, 'deployment_aki_path'),
(ramdisk_label, 'deployment_ari_path')):
if ipxe_enabled:
@@ -775,6 +777,10 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy',
and service_utils.is_glance_image(image_href)):
pxe_opts[option] = images.get_temp_url_for_glance_image(
task.context, image_href)
+ if label == ramdisk_label:
+ path = urlparse.urlparse(pxe_opts[option]).path.strip('/')
+ if path:
+ initrd_filename = path.split('/')[-1]
else:
pxe_opts[option] = '/'.join([CONF.deploy.http_url, node.uuid,
label])
@@ -782,7 +788,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy',
pxe_opts[option] = get_path_relative_to_tftp_root(
pxe_info[label][1])
if ipxe_enabled:
- pxe_opts['initrd_filename'] = ramdisk_label
+ pxe_opts['initrd_filename'] = initrd_filename
return pxe_opts
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index a8aa3a558..e4db225b7 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -1774,9 +1774,10 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
self.config(ipxe_use_swift=True, group='pxe')
glance = mock.Mock()
glance_mock.return_value = glance
- glance.swift_temp_url.side_effect = [
- pxe_kernel, pxe_ramdisk] = [
- 'swift_kernel', 'swift_ramdisk']
+ glance.swift_temp_url.side_effect = [pxe_kernel, pxe_ramdisk] = [
+ 'http://example.com/account/swift_kernel',
+ 'http://example.com/account/swift_ramdisk'
+ ]
image_info = {
kernel_label: (uuidutils.generate_uuid(),
os.path.join(root_dir,
@@ -1787,6 +1788,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
self.node.uuid,
ramdisk_label))
}
+ expected_initrd_filename = 'swift_ramdisk'
else:
pxe_kernel = os.path.join(http_url, self.node.uuid,
kernel_label)
@@ -1802,6 +1804,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
self.node.uuid,
ramdisk_label))
}
+ expected_initrd_filename = ramdisk_label
kernel = os.path.join(http_url, self.node.uuid, 'kernel')
ramdisk = os.path.join(http_url, self.node.uuid, 'ramdisk')
@@ -1836,7 +1839,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
'ipxe_timeout': ipxe_timeout_in_ms,
'ari_path': ramdisk,
'aki_path': kernel,
- 'initrd_filename': ramdisk_label,
+ 'initrd_filename': expected_initrd_filename,
}
if mode == 'rescue':
diff --git a/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml b/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml
new file mode 100644
index 000000000..b9eea262e
--- /dev/null
+++ b/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Fixes the ``initrd`` kernel parameter when booting ramdisk directly from
+ Swift/RadosGW using iPXE. Previously it was always ``deploy_ramdisk``,
+ even when the actual file name is different.