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
This commit is contained in:
parent
a4a89d6b20
commit
c975eaa8c6
@ -18,6 +18,7 @@ import copy
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from ironic_lib import utils as ironic_utils
|
||||
import jinja2
|
||||
@ -744,6 +745,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:
|
||||
@ -752,6 +754,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])
|
||||
@ -759,7 +765,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy',
|
||||
pxe_opts[option] = os.path.relpath(pxe_info[label][1],
|
||||
CONF.pxe.tftp_root)
|
||||
if ipxe_enabled:
|
||||
pxe_opts['initrd_filename'] = ramdisk_label
|
||||
pxe_opts['initrd_filename'] = initrd_filename
|
||||
return pxe_opts
|
||||
|
||||
|
||||
|
@ -1916,9 +1916,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,
|
||||
@ -1929,6 +1930,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)
|
||||
@ -1944,6 +1946,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')
|
||||
@ -1978,7 +1981,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':
|
||||
|
6
releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml
Normal file
6
releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml
Normal file
@ -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.
|
Loading…
x
Reference in New Issue
Block a user