ironic.common.pxe_utils module

class ironic.common.pxe_utils.TFTPImageCache[source]

Bases: ironic.drivers.modules.image_cache.ImageCache

ironic.common.pxe_utils.build_deploy_pxe_options(task, pxe_info, mode='deploy', ipxe_enabled=False)[source]
ironic.common.pxe_utils.build_extra_pxe_options(ramdisk_params=None)[source]
ironic.common.pxe_utils.build_instance_pxe_options(task, pxe_info, ipxe_enabled=False)[source]
ironic.common.pxe_utils.build_pxe_config_options(task, pxe_info, service=False, ipxe_enabled=False, ramdisk_params=None)[source]

Build the PXE config options for a node

This method builds the PXE boot options for a node, given all the required parameters.

The options should then be passed to pxe_utils.create_pxe_config to create the actual config files.

Parameters
  • task – A TaskManager object

  • pxe_info – a dict of values to set on the configuration file

  • service – if True, build “service mode” pxe config for netboot-ed user image and skip adding deployment image kernel and ramdisk info to PXE options.

  • ipxe_enabled – Default false boolean to indicate if ipxe is in use by the caller.

  • ramdisk_params – the parameters to be passed to the ramdisk. as kernel command-line arguments.

Returns

A dictionary of pxe options to be used in the pxe bootfile template.

ironic.common.pxe_utils.build_service_pxe_config(task, instance_image_info, root_uuid_or_disk_id, ramdisk_boot=False, ipxe_enabled=False, is_whole_disk_image=None)[source]
ironic.common.pxe_utils.cache_ramdisk_kernel(task, pxe_info, ipxe_enabled=False)[source]

Fetch the necessary kernels and ramdisks for the instance.

ironic.common.pxe_utils.clean_up_pxe_config(task, ipxe_enabled=False)[source]

Clean up the TFTP environment for the task’s node.

Parameters

task – A TaskManager instance.

ironic.common.pxe_utils.clean_up_pxe_env(task, images_info, ipxe_enabled=False)[source]

Cleanup PXE environment of all the images in images_info.

Cleans up the PXE environment for the mentioned images in images_info.

Parameters
  • task – a TaskManager object

  • images_info – A dictionary of images whose keys are the image names to be cleaned up (kernel, ramdisk, etc) and values are a tuple of identifier and absolute path.

ironic.common.pxe_utils.create_ipxe_boot_script()[source]

Render the iPXE boot script into the HTTP root directory

ironic.common.pxe_utils.create_pxe_config(task, pxe_options, template=None, ipxe_enabled=False)[source]

Generate PXE configuration file and MAC address links for it.

This method will generate the PXE configuration file for the task’s node under a directory named with the UUID of that node. For each MAC address or DHCP IP address (port) of that node, a symlink for the configuration file will be created under the PXE configuration directory, so regardless of which port boots first they’ll get the same PXE configuration. If grub2 bootloader is in use, then its configuration will be created based on DHCP IP address in the form nn.nn.nn.nn.

Parameters
  • task – A TaskManager instance.

  • pxe_options – A dictionary with the PXE configuration parameters.

  • template – The PXE configuration template. If no template is given the node specific template will be used.

ironic.common.pxe_utils.dhcp_options_for_instance(task, ipxe_enabled=False, url_boot=False, ip_version=None)[source]

Retrieves the DHCP PXE boot options.

Parameters
  • task – A TaskManager instance.

  • ipxe_enabled – Default false boolean that signals if iPXE formatting should be returned by the method for DHCP server configuration.

  • url_boot – Default false boolean to inform the method if a URL should be returned to boot the node. If [pxe]ip_version is set to 6, then this option has no effect as url_boot form is required by DHCPv6 standards.

  • ip_version – The IP version of options to return as values differ by IP version. Default to [pxe]ip_version. Possible options are integers 4 or 6.

Returns

Dictionary to be sent to the networking service describing the DHCP options to be set.

ironic.common.pxe_utils.get_image_info(node, mode='deploy', ipxe_enabled=False)[source]

Generate the paths for TFTP files for deploy or rescue images.

This method generates the paths for the deploy (or rescue) kernel and deploy (or rescue) ramdisk.

Parameters
  • node – a node object

  • mode – Label indicating a deploy or rescue operation being carried out on the node. Supported values are ‘deploy’ and ‘rescue’. Defaults to ‘deploy’, indicating deploy operation is being carried out.

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

Returns

a dictionary whose keys are the names of the images (deploy_kernel, deploy_ramdisk, or rescue_kernel, rescue_ramdisk) and values are the absolute paths of them.

Raises

MissingParameterValue, if deploy_kernel/deploy_ramdisk or rescue_kernel/rescue_ramdisk is missing in node’s driver_info.

ironic.common.pxe_utils.get_instance_image_info(task, ipxe_enabled=False)[source]

Generate the paths for TFTP files for instance related images.

This method generates the paths for instance kernel and instance ramdisk. This method also updates the node, so caller should already have a non-shared lock on the node.

Parameters
  • task – A TaskManager instance containing node and context.

  • ipxe_enabled – Default false boolean to indicate if ipxe is in use by the caller.

Returns

a dictionary whose keys are the names of the images (kernel, ramdisk) and values are the absolute paths of them. If it’s a whole disk image or node is configured for localboot, it returns an empty dictionary.

ironic.common.pxe_utils.get_ipxe_root_dir()[source]
ironic.common.pxe_utils.get_kernel_ramdisk_info(node_uuid, driver_info, mode='deploy', ipxe_enabled=False)[source]

Get href and tftp path for deploy or rescue kernel and ramdisk.

Parameters
  • node_uuid – UUID of the node

  • driver_info – Node’s driver_info dict

  • mode – A label to indicate whether paths for deploy or rescue ramdisk are being requested. Supported values are ‘deploy’ ‘rescue’. Defaults to ‘deploy’, indicating deploy paths will be returned.

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

Returns

a dictionary whose keys are deploy_kernel and deploy_ramdisk or rescue_kernel and rescue_ramdisk and whose values are the absolute paths to them.

Note: driver_info should be validated outside of this method.

ironic.common.pxe_utils.get_path_relative_to_tftp_root(file_path)[source]

Return file relative path to CONF.pxe.tftp_root

Parameters

file_path – full file path to be made relative path.

Returns

The path relative to CONF.pxe.tftp_root

ironic.common.pxe_utils.get_pxe_config_file_path(node_uuid, ipxe_enabled=False)[source]

Generate the path for the node’s PXE configuration file.

Parameters
  • node_uuid – the UUID of the node.

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

Returns

The path to the node’s PXE configuration file.

ironic.common.pxe_utils.get_root_dir()[source]

Returns the directory where the config files and images will live.

ironic.common.pxe_utils.get_tftp_path_prefix()[source]

Adds trailing slash (if needed) necessary for path-prefix

Returns

CONF.pxe.tftp_root ensured to have a trailing slash

ironic.common.pxe_utils.get_volume_pxe_options(task)[source]

Identify volume information for iPXE template generation.

ironic.common.pxe_utils.is_ipxe_enabled(task)[source]

Return true if ipxe is set.

Parameters

task – A TaskManager object

Returns

boolean true if [pxe]ipxe_enabled is configured or if the task driver instance is the iPXE driver.

ironic.common.pxe_utils.parse_driver_info(node, mode='deploy')[source]

Gets the driver specific Node deployment info.

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

Parameters
  • node – a single Node.

  • mode – Label indicating a deploy or rescue operation being carried out on the node. Supported values are ‘deploy’ and ‘rescue’. Defaults to ‘deploy’, indicating deploy operation is being carried out.

Returns

A dict with the driver_info values.

Raises

MissingParameterValue

ironic.common.pxe_utils.prepare_instance_pxe_config(task, image_info, iscsi_boot=False, ramdisk_boot=False, ipxe_enabled=False)[source]

Prepares the config file for PXE boot

Parameters
  • task – a task from TaskManager.

  • image_info – a dict of values of instance image metadata to set on the configuration file.

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

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

  • ipxe_enabled – Default false boolean to indicate if ipxe is in use by the caller.

Returns

None

ironic.common.pxe_utils.validate_boot_parameters_for_trusted_boot(node)[source]

Check if boot parameters are valid for trusted boot.