ironic.common.pxe_utils module

class ironic.common.pxe_utils.TFTPImageCache[source]

Bases: 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(task, ramdisk_params=None)[source]
ironic.common.pxe_utils.build_instance_pxe_options(task, pxe_info, ipxe_enabled=False)[source]
ironic.common.pxe_utils.build_kickstart_config_options(task)[source]

Build the kickstart template options for a node

This method builds the kickstart template options for a node, given all the required parameters.

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

Parameters:

task – A TaskManager object

Returns:

A dictionary of kickstart options to be used in the kickstart template.

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, anaconda_boot=False)[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, http_boot_enabled=False)[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.

Raises:

InvalidParameterValue if the underlying configuration cannot be conveyed to Neutron due to resulting value length.

ironic.common.pxe_utils.ensure_tree(path)[source]
ironic.common.pxe_utils.get_file_path_from_label(node_uuid, root_dir, label)[source]

Generate absolute paths to various images from their name(label)

This method generates absolute file system path on the conductor where various images need to be placed. For example the kickstart template, file and stage2 squashfs.img needs to be placed in the ipxe_root_dir since they will be transferred by anaconda ramdisk over http(s). The generated paths will be added to the image_info dictionary as values.

Parameters:
  • node_uuid – the UUID of the node

  • root_dir – Directory in which the image must be placed

  • label – Name of the image

ironic.common.pxe_utils.get_http_url_path_from_label(http_url, node_uuid, label)[source]

Generate http url path to various image artifacts

This method generates http(s) urls for various image artifacts int the webserver root. The generated urls will be added to the pxe_options dict and used to render pxe/ipxe configuration templates.

Parameters:
  • http_url – URL to access the root of the webserver

  • node_uuid – the UUID of the node

  • label – Name of the image

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_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_pxe_config_file_path(node_uuid, ipxe_enabled=False, http_boot_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_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 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.place_common_config()[source]

Place template generated config which is not node specific.

Currently places the initial grub config for grub network boot.

ironic.common.pxe_utils.place_loaders_for_boot(base_path)[source]

Place configured bootloaders from the host OS.

Example: grubaa64.efi:/path/to/grub-aarch64.efi,…

Parameters:

base_path – Destination path where files should be copied to.

ironic.common.pxe_utils.prepare_instance_kickstart_config(task, image_info, anaconda_boot=False)[source]

Prepare to boot anaconda ramdisk by generating kickstart file

Parameters:
  • task – a task from TaskManager.

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

  • anaconda_boot – if the boot is to a anaconda ramdisk configuration.

ironic.common.pxe_utils.prepare_instance_pxe_config(task, image_info, iscsi_boot=False, ramdisk_boot=False, ipxe_enabled=False, anaconda_boot=False, http_boot_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.

  • anaconda_boot – if the boot is to a anaconda ramdisk configuration.

  • http_boot_enabled – If httpboot models of use are to be used with the underlying boot loaders.

Returns:

None

ironic.common.pxe_utils.validate_kickstart_file(ks_cfg)[source]

Check if the kickstart file is valid

Parameters:

ks_cfg – Contents of kickstart file to validate

Raises:

InvalidKickstartFile

ironic.common.pxe_utils.validate_kickstart_template(ks_template)[source]

Validate the kickstart template

Parameters:

ks_template – Path to the kickstart template

Raises:

InvalidKickstartTemplate