ironic.drivers.modules.image_utils module

class ironic.drivers.modules.image_utils.ISOImageCache[source]

Bases: ImageCache

class ironic.drivers.modules.image_utils.ImageHandler(driver)[source]

Bases: object

publish_image(image_file, object_name, node_http_url=None)[source]

Make image file downloadable.

Depending on ironic settings, pushes given file into Swift or copies it over to local HTTP server’s document root and returns publicly accessible URL leading to the given file.

Parameters:
  • image_file – path to file to publish

  • object_name – name of the published file

  • 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.

Returns:

a URL to download published file

unpublish_image(object_name)[source]

Withdraw the image previously made downloadable.

Depending on ironic settings, removes previously published file from where it has been published - Swift or local HTTP server’s document root.

Parameters:

object_name – name of the published file (optional)

classmethod unpublish_image_for_node(node, prefix='', suffix='')[source]

Withdraw the image previously made downloadable.

Depending on ironic settings, removes previously published file from where it has been published - Swift or local HTTP server’s document root.

Parameters:
  • node – the node for which image was published.

  • prefix – object name prefix.

  • suffix – object name suffix.

update_driver_config(driver)[source]
ironic.drivers.modules.image_utils.cleanup_disk_image(task, prefix=None)[source]

Deletes the image if it was created for the node.

Parameters:
  • task – an ironic node object.

  • prefix – Prefix to use for the object name.

ironic.drivers.modules.image_utils.cleanup_floppy_image(task)[source]

Deletes the floppy image if it was created for the node.

Parameters:

task – an ironic node object.

ironic.drivers.modules.image_utils.cleanup_iso_image(task)[source]

Deletes the ISO if it was created for the instance.

Parameters:

task – A task from TaskManager.

ironic.drivers.modules.image_utils.cleanup_remote_image(task, file_name)[source]

Cleanup image created via prepare_remote_image.

ironic.drivers.modules.image_utils.override_api_url(params)[source]
ironic.drivers.modules.image_utils.prepare_boot_iso(task, d_info, root_uuid=None)[source]

Prepare boot ISO image

Build bootable ISO out of [instance_info]/kernel, [instance_info]/ramdisk and [driver_info]/bootloader if present. Otherwise, read kernel_id and ramdisk_id from [instance_info]/image_source Glance image metadata.

Push produced ISO image up to Glance and return temporary Swift URL to the image.

Parameters:
  • task – a TaskManager instance containing the node to act on.

  • d_info – Deployment information of the node

  • root_uuid – Root UUID

Returns:

bootable ISO HTTP URL.

Raises:

MissingParameterValue, if any of the required parameters are missing.

Raises:

InvalidParameterValue, if any of the parameters have invalid value.

Raises:

ImageCreationFailed, if creating ISO image failed.

ironic.drivers.modules.image_utils.prepare_configdrive_image(task, content)[source]

Prepare an image with configdrive.

Decodes base64 contents and writes it into a disk image that can be attached e.g. to a virtual USB device. Images stored in Swift are downloaded first.

Parameters:
  • task – a TaskManager instance containing the node to act on.

  • content – Config drive as a base64-encoded string.

Raises:

ImageCreationFailed, if it failed while creating the image.

Raises:

SwiftOperationError, if any operation with Swift fails.

Returns:

image URL for the image.

ironic.drivers.modules.image_utils.prepare_deploy_iso(task, params, mode, d_info)[source]

Prepare deploy or rescue ISO image

Build bootable ISO out of [driver_info]/deploy_kernel/[driver_info]/deploy_ramdisk or [driver_info]/rescue_kernel/[driver_info]/rescue_ramdisk and [driver_info]/bootloader, then push built image up to Glance and return temporary Swift URL to the image.

If network interface supplies network configuration (network_data), a network_data.json will be written into an appropriate location on the final ISO.

Parameters:
  • task – a TaskManager instance containing the node to act on.

  • params – a dictionary containing ‘parameter name’->’value’ mapping to be passed to kernel command line.

  • mode – either ‘deploy’ or ‘rescue’.

  • d_info – Deployment information of the node

Returns:

bootable ISO HTTP URL.

Raises:

MissingParameterValue, if any of the required parameters are missing.

Raises:

InvalidParameterValue, if any of the parameters have invalid value.

Raises:

ImageCreationFailed, if creating ISO image failed.

ironic.drivers.modules.image_utils.prepare_disk_image(task, content, prefix=None)[source]

Prepare an image with the given content.

If content is already an HTTP URL, return it unchanged.

Parameters:
  • task – a TaskManager instance containing the node to act on.

  • content – Content as a string with a file name or bytes with contents.

  • prefix – Prefix to use for the object name.

Raises:

ImageCreationFailed, if it failed while creating the image.

Raises:

SwiftOperationError, if any operation with Swift fails.

Returns:

image URL for the image.

ironic.drivers.modules.image_utils.prepare_floppy_image(task, params=None)[source]

Prepares the floppy image for passing the parameters.

This method prepares a temporary VFAT filesystem image and adds a file into the image which contains parameters to be passed to the ramdisk. Then this method uploads built image to Swift ‘[redfish]swift_container’, setting it to auto expire after ‘[redfish]swift_object_expiry_timeout’ seconds. Finally, a temporary Swift URL is returned addressing Swift object just created.

Parameters:
  • task – a TaskManager instance containing the node to act on.

  • params – a dictionary containing ‘parameter name’->’value’ mapping to be passed to deploy or rescue image via floppy image.

Raises:

ImageCreationFailed, if it failed while creating the floppy image.

Raises:

SwiftOperationError, if any operation with Swift fails.

Returns:

image URL for the floppy image.

ironic.drivers.modules.image_utils.prepare_remote_image(task, image_url, file_name='boot.iso', download_source='local', cache=None)[source]

Generic function for publishing remote images.

Given the image provided by the user, generate a URL to pass to the BMC or a remote agent.

Parameters:
  • task – TaskManager instance.

  • image_url – The original URL or a glance UUID.

  • file_name – File name to use when publishing.

  • download_source – How the image will be published: ‘http’ (via a plain HTTP link, preverving remote links), ‘local’ (via the local HTTP server even if the remote link is HTTP), ‘swift’ (same as ‘http’, but Glance images are published via Swift temporary URLs).

  • cache – Image cache to use. Defaults to the ISO image cache.

Returns:

The new URL (possibly the same as the old one).