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.
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=True)[source]¶ Fetch the instance’s image from Glance
This method pulls the AMI 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
- Returns
a tuple containing the uuid of the image and the path in the filesystem where image is cached.
-
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)[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.
get_async_step_return_state
(node)[source]¶ Returns state based on operation (cleaning/deployment) being invoked
- Parameters
node – an ironic node object.
- Returns
states.CLEANWAIT if cleaning operation in progress or states.DEPLOYWAIT if deploy operation in progress.
-
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_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. 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_iscsi_boot
(task)[source]¶ Return true if booting from an iscsi volume.
-
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.
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.
set_async_step_flags
(node, reboot=None, skip_current_step=None, polling=None)[source]¶ Sets appropriate reboot flags in driver_internal_info based on operation
- Parameters
node – an ironic node object.
reboot – Boolean value to set for node’s driver_internal_info flag cleaning_reboot or deployment_reboot based on cleaning or deployment operation in progress. If it is None, corresponding reboot flag is not set in node’s driver_internal_info.
skip_current_step – Boolean value to set for node’s driver_internal_info flag skip_current_clean_step or skip_current_deploy_step based on cleaning or deployment operation in progress. If it is None, corresponding skip step flag is not set in node’s driver_internal_info.
polling – Boolean value to set for node’s driver_internal_info flag deployment_polling or cleaning_polling. If it is None, the corresponding polling flag is not set in the node’s driver_internal_info.
-
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, ipxe_enabled=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.
ipxe_enabled – A default False boolean value to tell the method if the caller is using iPXE.
-
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_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.