Allow ramdisk_image_download_source in instance_info for ramdisk deploy

Change-Id: Ie0697d25787ebfdfb80f84b93c0cb8c2f45ad090
This commit is contained in:
Dmitry Tantsur 2021-06-22 18:50:16 +02:00
parent 416a0951c8
commit f8e2bc99d8
4 changed files with 37 additions and 4 deletions

View File

@ -92,6 +92,14 @@ For example,
--instance-info boot_iso=http://path/to/boot.iso
baremetal node deploy <NODE>
By default the Bare Metal service will cache the ISO locally and serve from its
HTTP server. If you want to avoid that, set the following:
.. code-block:: shell
baremetal node set <NODE> \
--instance-info ramdisk_image_download_source=http
.. warning::
This feature, when utilized with the ``ipxe`` ``boot_interface``,
will only allow a kernel and ramdisk to be booted from the

View File

@ -424,9 +424,18 @@ def _prepare_iso_image(task, kernel_href, ramdisk_href,
"building ISO, or explicit ISO for %(node)s") %
{'node': task.node.uuid})
i_info = task.node.instance_info
boot_option = deploy_utils.get_boot_option(task.node)
if boot_option == 'ramdisk':
download_source = (i_info.get('ramdisk_image_download_source')
or CONF.deploy.ramdisk_image_download_source)
else:
download_source = CONF.deploy.ramdisk_image_download_source
# NOTE(rpittau): if base_iso is defined as http address, we just access
# it directly.
if base_iso and CONF.deploy.ramdisk_image_download_source == 'http':
if base_iso and download_source == 'http':
if base_iso.startswith(('http://', 'https://')):
return base_iso
LOG.debug("ramdisk_image_download_source set to http but "
@ -435,11 +444,9 @@ def _prepare_iso_image(task, kernel_href, ramdisk_href,
img_handler = ImageHandler(task.node.driver)
i_info = task.node.instance_info
# NOTE(TheJulia): Until we support modifying a base iso, most of
# this logic actually does nothing in the end. But it should!
if deploy_utils.get_boot_option(task.node) == "ramdisk":
if boot_option == "ramdisk":
if not base_iso:
kernel_params = "root=/dev/ram0 text "
kernel_params += i_info.get("ramdisk_kernel_arguments", "")

View File

@ -23,6 +23,7 @@ from oslo_utils import importutils
from ironic.common import images
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules import image_utils
from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils as db_utils
@ -610,6 +611,17 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
base_iso=base_image_url)
self.assertEqual(url, base_image_url)
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
def test__prepare_iso_image_bootable_iso_with_instance_info(self):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
base_image_url = 'http://bearmetal.net/boot.iso'
task.node.instance_info['ramdisk_image_download_source'] = 'http'
url = image_utils._prepare_iso_image(
task, None, None, bootloader_href=None, root_uuid=None,
base_iso=base_image_url)
self.assertEqual(url, base_image_url)
@mock.patch.object(image_utils.ImageHandler, 'publish_image',
autospec=True)
@mock.patch.object(images, 'create_boot_iso', autospec=True)

View File

@ -0,0 +1,6 @@
---
features:
- |
For the ``ramdisk`` deploy interface, the ``ramdisk_image_download_source``
option can now be provided in the node's ``instance_info`` in addition
to the global configuration.