ironic.drivers.modules.deploy_utils module

class ironic.drivers.modules.deploy_utils.InstanceImageCache[source]

Bases: ImageCache

ironic.drivers.modules.deploy_utils.agent_add_clean_params(task)[source]

Add required config parameters to node’s driver_internal_info.

Adds the required conf options to node’s driver_internal_info. It is Required to pass the information to IPA.

Parameters:

task – a TaskManager instance.

ironic.drivers.modules.deploy_utils.build_agent_options(node)[source]

Build the options to be passed to the agent ramdisk.

Parameters:

node – an ironic node object

Returns:

a dictionary containing the parameters to be passed to agent ramdisk.

ironic.drivers.modules.deploy_utils.build_instance_info_for_deploy(task)[source]

Build instance_info necessary for deploying to a node.

Parameters:

task – a TaskManager object containing the node

Returns:

a dictionary containing the properties to be updated in instance_info

Raises:

exception.ImageRefValidationFailed if image_source is not Glance href and is not HTTP(S) URL.

ironic.drivers.modules.deploy_utils.cache_instance_image(ctx, node, force_raw=None, expected_format=None, expected_checksum=None, expected_checksum_algo=None)[source]

Fetch the instance’s image from Glance

This method pulls the disk image and writes them to the appropriate place on local disk.

Parameters:
  • ctx – context

  • node – an ironic node object

  • force_raw – whether convert image to raw format

  • expected_format – The expected format of the disk image contents.

  • expected_checksum – The expected image checksum, to be used if we need to convert the image to raw prior to deploying.

  • expected_checksum_algo – The checksum algo in use, if separately set.

Returns:

a tuple containing the uuid of the image and the path in the filesystem where image is cached.

Raises:

InvalidImage if the requested image is invalid and cannot be used for deployed based upon contents of the image or the metadata surrounding the image not matching the configured image.

ironic.drivers.modules.deploy_utils.check_for_missing_params(info_dict, error_msg, param_prefix='')[source]

Check for empty params in the provided dictionary.

Parameters:
  • info_dict – The dictionary to inspect.

  • error_msg – The error message to prefix before printing the information about missing parameters.

  • param_prefix – Add this prefix to each parameter for error messages

Raises:

MissingParameterValue, if one or more parameters are empty in the provided dictionary.

ironic.drivers.modules.deploy_utils.check_interface_capability(interface, capability)[source]

Evaluate interface to determine if capability is present.

Parameters:
  • interface – The interface object to check.

  • capability – The value representing the capability that the caller wishes to check if present.

Returns:

True if capability found, otherwise False.

ironic.drivers.modules.deploy_utils.compute_image_checksum(image_path, algorithm='md5')[source]

Compute checksum by given image path and algorithm.

ironic.drivers.modules.deploy_utils.destroy_http_instance_images(node)[source]

Delete instance image file and symbolic link refers to it.

ironic.drivers.modules.deploy_utils.destroy_images(node_uuid)[source]

Delete instance’s image file.

Parameters:

node_uuid – the uuid of the ironic node.

ironic.drivers.modules.deploy_utils.direct_deploy_should_convert_raw_image(node)[source]

Whether converts image to raw format for specified node.

Parameters:

node – ironic node object

Returns:

Boolean, whether the direct deploy interface should convert image to raw.

ironic.drivers.modules.deploy_utils.fetch_images(ctx, cache, images_info, force_raw=True, expected_format=None, expected_checksum=None, expected_checksum_algo=None)[source]

Check for available disk space and fetch images using ImageCache.

Parameters:
  • ctx – context

  • cache – ImageCache instance to use for fetching

  • images_info – list of tuples (image href, destination path)

  • force_raw – boolean value, whether to convert the image to raw format

  • expected_format – The expected format of the image.

  • expected_checksum – The expected image checksum, to be used if we need to convert the image to raw prior to deploying.

  • expected_checksum_algo – The checksum algo in use, if separately set.

Raises:

InstanceDeployFailure if unable to find enough disk space

Raises:

InvalidImage if the supplied image metadata or contents are deemed to be invalid, unsafe, or not matching the expectations asserted by configuration supplied or set.

ironic.drivers.modules.deploy_utils.get_boot_option(node)[source]

Gets the boot option.

Parameters:

node – A single Node.

Raises:

InvalidParameterValue if the capabilities string is not a dict or is malformed.

Returns:

A string representing the boot option type. Defaults to configuration setting [deploy]default_boot_mode.

ironic.drivers.modules.deploy_utils.get_disk_label(node)[source]

Return the disk label requested for deploy, if any.

Parameters:

node – a single Node.

Raises:

InvalidParameterValue if the capabilities string is not a dictionary or is malformed.

Returns:

the disk label or None if no disk label was specified.

ironic.drivers.modules.deploy_utils.get_image_download_source(node)[source]

Get the effective value of image_download_source for the node.

ironic.drivers.modules.deploy_utils.get_image_instance_info(node)[source]

Gets the image information from the node.

Get image information for the given node instance from its ‘instance_info’ property.

Parameters:

node – a single Node.

Returns:

A dict with required image properties retrieved from node’s ‘instance_info’.

Raises:

MissingParameterValue, if image_source is missing in node’s instance_info. Also raises same exception if kernel/ramdisk is missing in instance_info for non-glance images.

ironic.drivers.modules.deploy_utils.get_image_properties(ctx, image_href)[source]

Get properties of the image.

Parameters:
  • ctx – security context

  • image_href – reference to the image

Returns:

properties as a dictionary

Raises:

InvalidParameterValue if the image cannot be accessed

ironic.drivers.modules.deploy_utils.get_ipxe_boot_file(node)[source]

Return the iPXE boot file name requested for deploy.

This method returns iPXE boot file name to be used for deploy. Architecture specific boot file is searched first. BIOS/UEFI boot file is used if no valid architecture specific file found.

If no valid value is found, the default reverts to the get_pxe_boot_file method and thus the [pxe]pxe_bootfile_name and [pxe]uefi_ipxe_bootfile_name settings.

Parameters:

node – A single Node.

Returns:

The iPXE boot file name.

ironic.drivers.modules.deploy_utils.get_ipxe_config_template(node)[source]

Return the iPXE config template file name requested of deploy.

This method returns the iPXE configuration template file.

Parameters:

node – A single Node.

Returns:

The iPXE config template file name.

ironic.drivers.modules.deploy_utils.get_ironic_api_url()[source]

Resolve Ironic API endpoint

either from config of from Keystone catalog.

ironic.drivers.modules.deploy_utils.get_pxe_boot_file(node)[source]

Return the PXE boot file name requested for deploy.

This method returns PXE boot file name to be used for deploy. Architecture specific boot file is searched first. BIOS/UEFI boot file is used if no valid architecture specific file found.

Parameters:

node – A single Node.

Returns:

The PXE boot file name.

ironic.drivers.modules.deploy_utils.get_pxe_config_template(node)[source]

Return the PXE config template file name requested for deploy.

This method returns PXE config template file to be used for deploy. First specific pxe template is searched in the node. After that architecture specific template file is searched. BIOS/UEFI template file is used if no valid architecture specific file found.

Parameters:

node – A single Node.

Returns:

The PXE config template file name.

ironic.drivers.modules.deploy_utils.get_remote_boot_volume(task)[source]

Identify a boot volume from any configured volumes.

Returns:

None or the volume target representing the volume.

ironic.drivers.modules.deploy_utils.get_root_device_for_deploy(node)[source]

Get a root device requested for deployment or None.

Raises:

InvalidParameterValue on invalid hints.

Returns:

Parsed root device hints or None if no hints were provided.

ironic.drivers.modules.deploy_utils.get_single_nic_with_vif_port_id(task)[source]

Returns the MAC address of a port which has a VIF port id.

Parameters:

task – a TaskManager instance containing the ports to act on.

Returns:

MAC address of the port connected to deployment network. None if it cannot find any port with vif id.

ironic.drivers.modules.deploy_utils.is_anaconda_deploy(node)[source]

Determine if Anaconda deploy interface is in use for the deployment.

Parameters:

node – A single Node.

Returns:

A boolean value of True when Anaconda deploy interface is in use otherwise False

ironic.drivers.modules.deploy_utils.is_iscsi_boot(task)[source]

Return true if booting from an iscsi volume.

ironic.drivers.modules.deploy_utils.is_ramdisk_deploy(node)[source]
ironic.drivers.modules.deploy_utils.is_software_raid(node)[source]

Determine if software raid is in use for the deployment.

Parameters:

node – A single Node.

Returns:

A boolean value of True when software raid is in use, otherwise False

ironic.drivers.modules.deploy_utils.needs_agent_ramdisk(node, mode='deploy')[source]

Checks whether the node requires an agent ramdisk now.

ironic.drivers.modules.deploy_utils.parse_instance_info(node, image_deploy=True)[source]

Gets the instance specific Node deployment info.

This method validates whether the ‘instance_info’ property of the supplied node contains the required information for this driver to deploy images to the node.

Parameters:
  • node – a single Node.

  • image_deploy – If the deployment interface is aware this is an image based deployment, default True.

Returns:

A dict with the instance_info values.

Raises:

MissingParameterValue, if any of the required parameters are missing.

Raises:

InvalidParameterValue, if any of the parameters have invalid value.

ironic.drivers.modules.deploy_utils.populate_storage_driver_internal_info(task)[source]

Set node driver_internal_info for boot from volume parameters.

Parameters:

task – a TaskManager object containing the node.

Raises:

StorageError when a node has an iSCSI or FibreChannel boot volume defined but is not capable to support it.

ironic.drivers.modules.deploy_utils.prepare_agent_boot(task)[source]

Prepare booting the agent on the node.

Parameters:

task – a TaskManager instance.

ironic.drivers.modules.deploy_utils.prepare_inband_cleaning(task, manage_boot=True)[source]

Prepares the node to boot into agent for in-band cleaning.

This method does the following: 1. Prepares the cleaning ports for the bare metal node and updates the clean parameters in node’s driver_internal_info. 2. If ‘manage_boot’ parameter is set to true, it also calls the ‘prepare_ramdisk’ method of boot interface to boot the agent ramdisk. 3. Reboots the bare metal node.

Parameters:
  • task – a TaskManager object containing the node

  • manage_boot – If this is set to True, this method calls the ‘prepare_ramdisk’ method of boot interface to boot the agent ramdisk. If False, it skips preparing the boot agent ramdisk using boot interface, and assumes that the environment is setup to automatically boot agent ramdisk every time bare metal node is rebooted.

Returns:

states.CLEANWAIT to signify an asynchronous prepare.

Raises:

NetworkError, NodeCleaningFailure if the previous cleaning ports cannot be removed or if new cleaning ports cannot be created.

Raises:

InvalidParameterValue if cleaning network UUID config option has an invalid value.

ironic.drivers.modules.deploy_utils.prepare_inband_service(task)[source]

Boot a service ramdisk on the node.

Parameters:

task – a TaskManager instance.

Raises:

NetworkError if the tenant ports cannot be removed.

Raises:

InvalidParameterValue when the wrong power state is specified or the wrong driver info is specified for power management.

Raises:

other exceptions by the node’s power driver if something wrong occurred during the power action.

Raises:

any boot interface’s prepare_ramdisk exceptions.

Returns:

Returns states.SERVICEWAIT

ironic.drivers.modules.deploy_utils.reboot_to_finish_step(task, timeout=None)[source]

Reboot the node into IPA to finish a deploy/clean step.

Parameters:
  • task – a TaskManager instance.

  • timeout – timeout (in seconds) positive integer (> 0) for any power state. None indicates to use default timeout.

Returns:

states.CLEANWAIT if cleaning operation in progress or states.DEPLOYWAIT if deploy operation in progress.

ironic.drivers.modules.deploy_utils.rescue_or_deploy_mode(node)[source]
ironic.drivers.modules.deploy_utils.set_failed_state(task, msg, collect_logs=True)[source]

Sets the deploy status as failed with relevant messages.

This method sets the deployment as fail with the given message. It sets node’s provision_state to DEPLOYFAIL and updates last_error with the given error message. It also powers off the baremetal node.

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

  • msg – the message to set in logs and last_error of the node.

  • collect_logs – Boolean indicating whether to attempt to collect logs from IPA-based ramdisk. Defaults to True. Actual log collection is also affected by CONF.agent.deploy_logs_collect config option.

ironic.drivers.modules.deploy_utils.step_error_handler(task, logmsg, errmsg=None)[source]

Run the correct handler for the current step.

Parameters:
  • task – a TaskManager instance.

  • logmsg – Message to be logged.

  • errmsg – Message for the user. Optional, if not provided logmsg is used.

ironic.drivers.modules.deploy_utils.switch_pxe_config(path, root_uuid_or_disk_id, boot_mode, is_whole_disk_image, iscsi_boot=False, ramdisk_boot=False, ipxe_enabled=False, anaconda_boot=False)[source]

Switch a pxe config from deployment mode to service mode.

Parameters:
  • path – path to the pxe config file in tftpboot.

  • root_uuid_or_disk_id – root uuid in case of partition image or disk_id in case of whole disk image.

  • boot_mode – if boot mode is uefi or bios.

  • is_whole_disk_image – if the image is a whole disk image or not.

  • iscsi_boot – if boot is from an iSCSI volume or not.

  • ramdisk_boot – if the boot is to be to a ramdisk configuration.

  • ipxe_enabled – A default False boolean value to tell the method if the caller is using iPXE.

  • anaconda_boot – if the boot is to be to an anaconda configuration.

ironic.drivers.modules.deploy_utils.tear_down_inband_cleaning(task, manage_boot=True)[source]

Tears down the environment setup for in-band cleaning.

This method does the following: 1. Powers off the bare metal node (unless the node is fast tracked or there was a cleaning failure). 2. If ‘manage_boot’ parameter is set to true, it also calls the ‘clean_up_ramdisk’ method of boot interface to clean up the environment that was set for booting agent ramdisk. 3. Deletes the cleaning ports which were setup as part of cleaning.

Parameters:
  • task – a TaskManager object containing the node

  • manage_boot – If this is set to True, this method calls the ‘clean_up_ramdisk’ method of boot interface to boot the agent ramdisk. If False, it skips this step.

Raises:

NetworkError, NodeCleaningFailure if the cleaning ports cannot be removed.

ironic.drivers.modules.deploy_utils.tear_down_inband_service(task)[source]

Tears down the environment setup for in-band service.

This method does the following: 1. Powers off the bare metal node (unless the node is fast tracked or there was a service failure). 2. If ‘manage_boot’ parameter is set to true, it also calls the ‘clean_up_ramdisk’ method of boot interface to clean up the environment that was set for booting agent ramdisk. 3. Deletes the cleaning ports which were setup as part of cleaning.

Parameters:

task – a TaskManager object containing the node

Raises:

NetworkError, NodeServiceFailure if the cleaning ports cannot be removed.

ironic.drivers.modules.deploy_utils.tear_down_storage_configuration(task)[source]

Clean up storage configuration.

Remove entries from driver_internal_info for storage and deletes the volume targets from the database. This is done to ensure a clean state for the next boot of the machine.

ironic.drivers.modules.deploy_utils.try_set_boot_device(task, device, persistent=True)[source]

Tries to set the boot device on the node.

This method tries to set the boot device on the node to the given boot device. Under uefi boot mode, setting of boot device may differ between different machines. IPMI does not work for setting boot devices in uefi mode for certain machines. This method ignores the expected IPMI failure for uefi boot mode and just logs a message. In error cases, it is expected the operator has to manually set the node to boot from the correct device.

Parameters:
  • task – a TaskManager object containing the node

  • device – the boot device

  • persistent – Whether to set the boot device persistently

Raises:

Any exception from set_boot_device except IPMIFailure (setting of boot device using ipmi is expected to fail).

ironic.drivers.modules.deploy_utils.validate_capabilities(node)[source]

Validates that specified supported capabilities have valid value

This method checks if the any of the supported capability is present in Node capabilities. For all supported capabilities specified for a Node, it validates that it has a valid value. The node can have capability as part of the ‘properties’ or ‘instance_info’ or both. Note that the actual value of a capability does not need to be the same in the node’s ‘properties’ and ‘instance_info’.

Parameters:

node – an ironic node object.

Raises:

InvalidParameterValue, if the capability is not set to a valid value.

ironic.drivers.modules.deploy_utils.validate_image_properties(task, deploy_info)[source]

Validate the image.

For Glance images it checks that the image exists in Glance and its properties or deployment info contain the properties passed. If it’s not a Glance image, it checks that deployment info contains needed properties.

Parameters:
  • task – TaskManager instance with a valid node

  • deploy_info – the deploy_info to be validated

Raises:

InvalidParameterValue if: * connection to glance failed; * authorization for accessing image failed; * HEAD request to image URL failed or returned response code != 200; * HEAD request response does not contain Content-Length header; * the protocol specified in image URL is not supported.

Raises:

MissingParameterValue if the image doesn’t contain the mentioned properties.