ironic.conductor.configdrive_utils module¶
- ironic.conductor.configdrive_utils.check_and_fix_configdrive(task, configdrive)[source]¶
Check and fix the supplied config drive.
In certain cases, a caller may supply a horribly broken configuration drive which contains a list of empty dicts or even is an ISO in the same state.
The prupose of this method is to attempt to identify and correct those specific cases to help ensure the instance being deployed has what is necessary to boot.
If this method fails, an internal exception, ConfigDriveRegenerationFailure is raised by the various helper methods used by this method, however this method will just return the user supplied
- Parameters:
task – A Taskmanager object.
configdrive – The supplied configuration drive.
- Returns:
Returns a configuration drive aligning with the type which was originally supplied by the user.
- ironic.conductor.configdrive_utils.check_and_patch_configdrive(task, configdrive)[source]¶
Evaluates and patches an provided ISO9660 configuration drive file.
This method is responsible for taking the user requested configuration drive, performing basic evaluation, attempting to patch/fix the configuration drive to enable the latest metadata written to be valid and correct, which is intended to allow the overall deployment process to proceed with the correct data.
- Parameters:
task – A Taskmanager object.
configdrive – The in-memory configuration drive file which was submitted by the requester.
- Returns:
The submitted configuration drive or a regenerated and patched configuration drive OR the original requested configuration drive if a failure is encountered in the overall process.
- ironic.conductor.configdrive_utils.generate_config_metadata(task)[source]¶
Generates new network config metadata.
This method wraps generate_instance_network_data and performs the logging actions in relation to it, and also performs a post generation sanity check on the network metadata.
When the data is invalid, this method also raises an internal ConfigDriveRegenerationFailure exception which is a signal to the caller method that an issue has occurred. The expectation being that the caller knows how to handle and navigate that issue without failing the deployment operation.
- Parameters:
task – A TaskManager object.
- Returns:
A dictionary object with three keys, ‘links’, ‘networks’, and ‘services’ which contains various related entries as generated by the internal neutron get_neutron_port_data method which is then combined such that bond ports are also honored.
- Raises:
ConfigDriveRegenerationFailure when no metadata is generated or the configuration state of the drivers does not support the generation of network metadata. The purpose of this is to appropriately signal an error to the caller, not fail the overall requested operation by the end user.
- ironic.conductor.configdrive_utils.generate_instance_network_data(task)[source]¶
Generates OpenStack instance network metadata.
This method was added to help facilitate the correction of cases where bad metadata could be supplied to Ironic by a service such as Nova where an instance has been requested, but missing network configuration details harms the viability of the overall instance’s deployment.
This method works by taking the available information which Ironic manages and controls, and reconciles it together into an OpenStack style network_data document which can then be rendered as network_data.json.
- Parameters:
task – A TaskManager class instance.
- Returns:
A dictionary object with three keys, ‘links’, ‘networks’, and ‘services’ which contains various related entries as generated by the internal neutron get_neutron_port_data method which is then combined such that bond ports are also honored.
- ironic.conductor.configdrive_utils.is_invalid_network_metadata(network_data)[source]¶
Return True if network metadata is invalid.
- Parameters:
network_data – A dictionary object containing network_metadata, with three sub-fields, ‘links’, ‘networks’, and ‘services’. Returns True if the document is invalid and missing network metadata.
- Returns:
True when the data supplied is invalid.
- ironic.conductor.configdrive_utils.regenerate_iso(source, dest, override_files)[source]¶
Utility method to regenerate a config drive ISO image.
This method takes the source, extracts the contents in a temporary folder, applies override contents, and then re-packages the contents into the dest file supplied as a parameter.
- Parameters:
source – A PyCdlib class object of an opened ISO file to extract.
dest – The destination filename to write the result to.
override_files – A dictionary of file name keys and contents stored as values paris, which will be used to override contents of the configuration drive for the purpose of patching metadata.