ironic.drivers.modules.deploy_utils module

ironic.drivers.modules.deploy_utils module

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.agent_execute_clean_step(task, step)[source]

Execute a clean step asynchronously on the agent.

#TODO(JoshNang) move to BootInterface

Parameters:
  • task – a TaskManager object containing the node
  • step – a clean step dictionary to execute
Raises:

NodeCleaningFailure if the agent does not return a command status

Returns:

states.CLEANWAIT to signify the step will be completed async

ironic.drivers.modules.deploy_utils.agent_get_clean_steps(task, interface=None, override_priorities=None)[source]

Get the list of cached clean steps from the agent.

#TODO(JoshNang) move to BootInterface

The clean steps cache is updated at the beginning of cleaning.

Parameters:
  • task – a TaskManager object containing the node
  • interface – The interface for which clean steps are to be returned. If this is not provided, it returns the clean steps for all interfaces.
  • override_priorities – a dictionary with keys being step names and values being new priorities for them. If a step isn’t in this dictionary, the step’s original priority is used.
Raises:

NodeCleaningFailure – if the clean steps are not yet cached, for example, when a node has just been enrolled and has not been cleaned yet.

Returns:

A list of clean step dictionaries

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(*args, **kwargs)[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.check_file_system_for_iscsi_device(portal_address, portal_port, target_iqn)[source]

Ensure the file system sees the iSCSI block device.

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.delete_iscsi(portal_address, portal_port, target_iqn)[source]

Delete the iSCSI target.

ironic.drivers.modules.deploy_utils.deploy_disk_image(address, port, iqn, lun, image_path, node_uuid, configdrive=None)[source]

All-in-one function to deploy a whole disk image to a node.

Parameters:
  • address – The iSCSI IP address.
  • port – The iSCSI port number.
  • iqn – The iSCSI qualified name.
  • lun – The iSCSI logical unit number.
  • image_path – Path for the instance’s disk image.
  • node_uuid – node’s uuid.
  • configdrive – Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL.
Returns:

a dictionary containing the key ‘disk identifier’ to identify the disk which was used for deployment.

ironic.drivers.modules.deploy_utils.deploy_partition_image(address, port, iqn, lun, image_path, root_mb, swap_mb, ephemeral_mb, ephemeral_format, node_uuid, preserve_ephemeral=False, configdrive=None, boot_option=None, boot_mode='bios', disk_label=None, cpu_arch='')[source]

All-in-one function to deploy a partition image to a node.

Parameters:
  • address – The iSCSI IP address.
  • port – The iSCSI port number.
  • iqn – The iSCSI qualified name.
  • lun – The iSCSI logical unit number.
  • image_path – Path for the instance’s disk image.
  • root_mb – Size of the root partition in megabytes.
  • swap_mb – Size of the swap partition in megabytes.
  • ephemeral_mb – Size of the ephemeral partition in megabytes. If 0, no ephemeral partition will be created.
  • ephemeral_format – The type of file system to format the ephemeral partition.
  • node_uuid – node’s uuid. Used for logging.
  • preserve_ephemeral – If True, no filesystem is written to the ephemeral block device, preserving whatever content it had (if the partition table has not changed).
  • configdrive – Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL.
  • boot_option – Can be “local” or “netboot”. “netboot” by default.
  • boot_mode – Can be “bios” or “uefi”. “bios” by default.
  • disk_label – The disk label to be used when creating the partition table. Valid values are: “msdos”, “gpt” or None; If None ironic will figure it out according to the boot_mode parameter.
  • cpu_arch – Architecture of the node being deployed to.
Raises:

InstanceDeployFailure if image virtual size is bigger than root partition size.

Returns:

a dictionary containing the following keys: ‘root uuid’: UUID of root partition ‘efi system partition uuid’: UUID of the uefi system partition (if boot mode is uefi). NOTE: If key exists but value is None, it means partition doesn’t exist.

ironic.drivers.modules.deploy_utils.discovery(portal_address, portal_port)[source]

Do iSCSI discovery on portal.

ironic.drivers.modules.deploy_utils.fetch_images(ctx, cache, images_info, force_raw=True)[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
Raises:

InstanceDeployFailure if unable to find enough disk space

ironic.drivers.modules.deploy_utils.force_iscsi_lun_update(target_iqn)[source]

force iSCSI initiator to re-read luns.

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 ‘netboot’.
ironic.drivers.modules.deploy_utils.get_default_boot_option()[source]

Gets the default boot option.

ironic.drivers.modules.deploy_utils.get_dev(address, port, iqn, lun)[source]

Returns a device path for given parameters.

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_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_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. Architecture specific template file is searched first. 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_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_iscsi_boot(task)[source]

Return true if booting from an iscsi volume.

ironic.drivers.modules.deploy_utils.login_iscsi(portal_address, portal_port, target_iqn)[source]

Login to an iSCSI target.

ironic.drivers.modules.deploy_utils.logout_iscsi(portal_address, portal_port, target_iqn)[source]

Logout from an iSCSI target.

ironic.drivers.modules.deploy_utils.parse_instance_info(node)[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.
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_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.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.switch_pxe_config(path, root_uuid_or_disk_id, boot_mode, is_whole_disk_image, trusted_boot=False, iscsi_boot=False, ramdisk_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.
  • trusted_boot – if boot with trusted_boot or not. The usage of is_whole_disk_image and trusted_boot are mutually exclusive. You can have one or neither, but not both.
  • iscsi_boot – if boot is from an iSCSI volume or not.
  • ramdisk_boot – if the boot is to be to a ramdisk 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. 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_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(ctx, deploy_info, properties)[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:
  • ctx – security context
  • deploy_info – the deploy_info to be validated
  • properties – the list of image meta-properties 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.

ironic.drivers.modules.deploy_utils.verify_iscsi_connection(target_iqn)[source]

Verify iscsi connection.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.