summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules
diff options
context:
space:
mode:
authorIury Gregory Melo Ferreira <imelofer@redhat.com>2022-08-05 02:44:03 -0300
committerIury Gregory Melo Ferreira <imelofer@redhat.com>2022-08-10 19:28:55 -0300
commitc197a2d8b24e2fa4c5e7901e448da1b0c93fcd26 (patch)
tree0bcff1ba6f183a3c4e72db17d1ef1924a70ea93b /ironic/drivers/modules
parent45c9c3029f5363b6e24e578648c09213a7338db1 (diff)
downloadironic-c197a2d8b24e2fa4c5e7901e448da1b0c93fcd26.tar.gz
Override external_http_url at node level
This patch adds support to specify the URL to be used to publish the node image when using virtual media. The option is available under `driver_info['external_http_url']`, if set this value has priority over the values in the configuration file ([deploy]/external_http_url and [deploy]/http_url) Story: 2010221 Task: 45970 Change-Id: If6a117a756b7d2a04251792f88c2ee412a040b28
Diffstat (limited to 'ironic/drivers/modules')
-rw-r--r--ironic/drivers/modules/image_utils.py13
-rw-r--r--ironic/drivers/modules/redfish/boot.py6
2 files changed, 14 insertions, 5 deletions
diff --git a/ironic/drivers/modules/image_utils.py b/ironic/drivers/modules/image_utils.py
index bb0dfa166..304c199bf 100644
--- a/ironic/drivers/modules/image_utils.py
+++ b/ironic/drivers/modules/image_utils.py
@@ -169,7 +169,7 @@ class ImageHandler(object):
return urlparse.urlunparse(parsed_url)
- def publish_image(self, image_file, object_name):
+ def publish_image(self, image_file, object_name, node_http_url=None):
"""Make image file downloadable.
Depending on ironic settings, pushes given file into Swift or copies
@@ -178,6 +178,9 @@ class ImageHandler(object):
:param image_file: path to file to publish
:param object_name: name of the published file
+ :param node_http_url: a url to be used to publish the image. If set,
+ the values from external_http_url and http_url
+ from CONF.deploy won't be used.
:return: a URL to download published file
"""
@@ -220,7 +223,8 @@ class ImageHandler(object):
shutil.copyfile(image_file, published_file)
os.chmod(published_file, self._file_permission)
- http_url = CONF.deploy.external_http_url or CONF.deploy.http_url
+ http_url = (node_http_url or CONF.deploy.external_http_url
+ or CONF.deploy.http_url)
image_url = os.path.join(http_url, self._image_subdir, object_name)
return image_url
@@ -302,8 +306,9 @@ def prepare_floppy_image(task, params=None):
images.create_vfat_image(vfat_image_tmpfile, parameters=params)
img_handler = ImageHandler(task.node.driver)
-
- image_url = img_handler.publish_image(vfat_image_tmpfile, object_name)
+ node_http_url = task.node.driver_info.get("external_http_url")
+ image_url = img_handler.publish_image(vfat_image_tmpfile, object_name,
+ node_http_url)
LOG.debug("Created floppy image %(name)s in Swift for node %(node)s, "
"exposed as temporary URL "
diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py
index 164425eee..a321c08ec 100644
--- a/ironic/drivers/modules/redfish/boot.py
+++ b/ironic/drivers/modules/redfish/boot.py
@@ -53,7 +53,11 @@ OPTIONAL_PROPERTIES = {
"used by ironic when building UEFI-bootable ISO "
"out of kernel and ramdisk. Required for UEFI "
"when deploy_iso is not provided."),
-
+ 'external_http_url': _("External URL that is used when the image could "
+ "be served outside of the provisioning network. "
+ "If set it will have priority over the following "
+ "configs: CONF.deploy.external_http_url and "
+ "CONF.deploy.http_url. Defaults to None.")
}
RESCUE_PROPERTIES = {