ironic.conductor.utils module

ironic.conductor.utils.abort_on_conductor_take_over(task)[source]

Set node’s state when a task was aborted due to conductor take over.

Parameters

task – a TaskManager instance.

ironic.conductor.utils.add_secret_token(node, pregenerated=False)[source]

Adds a secret token to driver_internal_info for IPA verification.

Parameters
  • node – Node object

  • pregenerated – Boolean value, default False, which indicates if the token should be marked as “pregenerated” in order to facilitate virtual media booting where the token is embedded into the configuration.

ironic.conductor.utils.build_configdrive(node, configdrive)[source]

Build a configdrive from provided meta_data, network_data and user_data.

If uuid or name are not provided in the meta_data, they’re defauled to the node’s uuid and name accordingly.

Parameters
  • node – an Ironic node object.

  • configdrive – A configdrive as a dict with keys meta_data, network_data, user_data and vendor_data (all optional).

Returns

A gzipped and base64 encoded configdrive as a string.

ironic.conductor.utils.cleaning_error_handler(task, msg, tear_down_cleaning=True, set_fail_state=True)[source]

Put a failed node in CLEANFAIL and maintenance.

ironic.conductor.utils.cleanup_after_timeout(task)[source]

Cleanup deploy task after timeout.

Parameters

task – a TaskManager instance.

ironic.conductor.utils.cleanup_cleanwait_timeout(task)[source]

Cleanup a cleaning task after timeout.

Parameters

task – a TaskManager instance.

ironic.conductor.utils.cleanup_rescuewait_timeout(task)[source]

Cleanup rescue task after timeout.

Parameters

task – a TaskManager instance.

ironic.conductor.utils.del_secret_token(node)[source]

Deletes the IPA agent secret token.

Removes the agent token secret from the driver_internal_info field from the Node object.

Parameters

node – Node object

ironic.conductor.utils.deploying_error_handler(task, logmsg, errmsg=None, traceback=False, clean_up=True)[source]

Put a failed node in DEPLOYFAIL.

Parameters
  • task – the task

  • logmsg – message to be logged

  • errmsg – message for the user

  • traceback – Boolean; True to log a traceback

  • clean_up – Boolean; True to clean up

ironic.conductor.utils.fast_track_able(task)[source]

Checks if the operation can be a streamlined deployment sequence.

This is mainly focused on ensuring that we are able to quickly sequence through operations if we already have a ramdisk heartbeating through external means.

Parameters

task – Taskmanager object

Returns

True if [deploy]fast_track is set to True, no iSCSI boot configuration is present, and no last_error is present for the node indicating that there was a recent failure.

ironic.conductor.utils.get_node_next_clean_steps(task, skip_current_step=True)[source]
ironic.conductor.utils.get_node_next_deploy_steps(task, skip_current_step=True)[source]
ironic.conductor.utils.hash_password(password='')[source]

Hashes a supplied password.

Parameters

value – Value to be hashed

ironic.conductor.utils.is_agent_token_pregenerated(node)[source]

Determines if the token was generated for out of band configuration.

Ironic supports the ability to provide configuration data to the agent through the a virtual floppy or as part of the virtual media image which is attached to the BMC.

This method helps us identify WHEN we did so as we don’t need to remove records of the token prior to rebooting the token. This is important as tokens provided through out of band means presist in the virtual media image, are loaded as part of the agent ramdisk, and do not require regeneration of the token upon the initial lookup, ultimately making the overall usage of virtual media and pregenerated tokens far more secure.

Parameters

node – Node Object

Returns

True if the token was pregenerated as indicated by the node’s driver_internal_info field. False in all other cases.

ironic.conductor.utils.is_agent_token_present(node)[source]

Determines if an agent token is present upon a node.

Parameters

node – Node object

Returns

True if an agent_secret_token value is present in a node driver_internal_info field.

ironic.conductor.utils.is_agent_token_supported(agent_version)[source]
ironic.conductor.utils.is_agent_token_valid(node, token)[source]

Validates if a supplied token is valid for the node.

Parameters

node – Node object

Token

A token value to validate against the driver_internal_info field agent_sercret_token.

Returns

True if the supplied token matches the token recorded in the supplied node object.

ironic.conductor.utils.is_fast_track(task)[source]

Checks a fast track is available.

This method first ensures that the node and conductor configuration is valid to perform a fast track sequence meaning that we already have a ramdisk running through another means like discovery. If not valid, False is returned.

The method then checks for the last agent heartbeat, and if it occured within the timeout set by [deploy]fast_track_timeout and the power state for the machine is POWER_ON, then fast track is permitted.

Parameters

task – Taskmanager object

Returns

True if the last heartbeat that was recorded was within the [deploy]fast_track_timeout setting.

ironic.conductor.utils.make_salt()[source]

Generate a random salt with the indicator tag for password type.

Returns

a valid salt for use with crypt.crypt

ironic.conductor.utils.node_get_boot_mode(task)[source]

Read currently set boot mode from a node.

Reads the boot mode for a node. If boot mode can’t be discovered, None is returned.

Parameters

task – a TaskManager instance.

Raises

DriverOperationError or its derivative in case of driver runtime error.

Raises

UnsupportedDriverExtension if current driver does not have management interface or get_boot_mode() method is not supported.

Returns

Boot mode. One of ironic.common.boot_mode or None if boot mode can’t be discovered

ironic.conductor.utils.node_power_action(task, new_state, timeout=None)[source]

Change power state or reset for a node.

Perform the requested power action if the transition is required.

Parameters
  • task – a TaskManager instance containing the node to act on.

  • new_state – Any power state from ironic.common.states.

  • timeout – timeout (in seconds) positive integer (> 0) for any power state. None indicates to use default timeout.

Raises

InvalidParameterValue when the wrong state is specified or the wrong driver info is specified.

Raises

StorageError when a failure occurs updating the node’s storage interface upon setting power on.

Raises

other exceptions by the node’s power driver if something wrong occurred during the power action.

ironic.conductor.utils.node_set_boot_device(task, device, persistent=False)[source]

Set the boot device for a node.

If the node that the boot device change is being requested for is in ADOPTING state, the boot device will not be set as that change could potentially result in the future running state of an adopted node being modified erroneously.

Parameters
  • task – a TaskManager instance.

  • device – Boot device. Values are vendor-specific.

  • persistent – Whether to set next-boot, or make the change permanent. Default: False.

Raises

InvalidParameterValue if the validation of the ManagementInterface fails.

ironic.conductor.utils.node_set_boot_mode(task, mode)[source]

Set the boot mode for a node.

Sets the boot mode for a node if the node’s driver interface contains a ‘management’ interface.

If the node that the boot mode change is being requested for is in ADOPTING state, the boot mode will not be set as that change could potentially result in the future running state of an adopted node being modified erroneously.

Parameters
Raises

InvalidParameterValue if the validation of the ManagementInterface fails.

Raises

DriverOperationError or its derivative in case of driver runtime error.

Raises

UnsupportedDriverExtension if current driver does not have vendor interface or method is unsupported.

ironic.conductor.utils.node_wait_for_power_state(task, new_state, timeout=None)[source]

Wait for node to be in new power state.

Parameters
  • task – a TaskManager instance.

  • new_state – the desired new power state, one of the power states in ironic.common.states.

  • timeout – number of seconds to wait before giving up. If not specified, uses the conductor.power_state_change_timeout config value.

Raises

PowerStateFailure if timed out

ironic.conductor.utils.notify_conductor_resume_clean(task)[source]
ironic.conductor.utils.notify_conductor_resume_deploy(task)[source]
ironic.conductor.utils.notify_conductor_resume_operation(task, operation)[source]

Notify the conductor to resume an operation.

Parameters
  • task – the task

  • operation – the operation, a string

ironic.conductor.utils.power_on_node_if_needed(task)[source]

Powers on node if it is powered off and has a Smart NIC port

Parameters

task – A TaskManager object

Returns

the previous power state or None if no changes were made

Raises

exception.NetworkError if agent status didn’t match the required status after max retry attempts.

ironic.conductor.utils.power_state_error_handler(e, node, power_state)[source]

Set the node’s power states if error occurs.

This hook gets called upon an exception being raised when spawning the worker thread to change the power state of a node.

Parameters
  • e – the exception object that was raised.

  • node – an Ironic node object.

  • power_state – the power state to set on the node.

ironic.conductor.utils.power_state_for_network_configuration(task)[source]

Handle the power state for a node reconfiguration.

Powers the node on if and only if it has a Smart NIC port. Yields for the actual reconfiguration, then restores the power state.

Parameters

task – A TaskManager object.

ironic.conductor.utils.provisioning_error_handler(e, node, provision_state, target_provision_state)[source]

Set the node’s provisioning states if error occurs.

This hook gets called upon an exception being raised when spawning the worker to do some provisioning to a node like deployment, tear down, or cleaning.

Parameters
  • e – the exception object that was raised.

  • node – an Ironic node object.

  • provision_state – the provision state to be set on the node.

  • target_provision_state – the target provision state to be set on the node.

ironic.conductor.utils.remove_agent_url(node)[source]

Helper to remove the agent_url record.

ironic.conductor.utils.remove_node_rescue_password(node, save=True)[source]

Helper to remove rescue password from a node.

Removes rescue password from node. It saves node by default. If node should not be saved, then caller needs to explicitly indicate it.

Parameters
  • node – an Ironic node object.

  • save – Boolean; True (default) to save the node; False otherwise.

ironic.conductor.utils.rescuing_error_handler(task, msg, set_fail_state=True)[source]

Cleanup rescue task after timeout or failure.

Parameters
  • task – a TaskManager instance.

  • msg – a message to set into node’s last_error field

  • set_fail_state – a boolean flag to indicate if node needs to be transitioned to a failed state. By default node would be transitioned to a failed state.

ironic.conductor.utils.restore_power_state_if_needed(task, power_state_to_restore)[source]

Change the node’s power state if power_state_to_restore is not None

Parameters
  • task – A TaskManager object

  • power_state_to_restore – power state

ironic.conductor.utils.skip_automated_cleaning(node)[source]

Checks if node cleaning needs to be skipped for an specific node.

Parameters

node – the node to consider

ironic.conductor.utils.spawn_cleaning_error_handler(e, node)[source]

Handle spawning error for node cleaning.

ironic.conductor.utils.spawn_deploying_error_handler(e, node)[source]

Handle spawning error for node deploying.

ironic.conductor.utils.spawn_rescue_error_handler(e, node)[source]

Handle spawning error for node rescue.

ironic.conductor.utils.validate_instance_info_traits(node)[source]

Validate traits in instance_info.

All traits in instance_info must also exist as node traits.

Parameters

node – an Ironic node object.

Raises

InvalidParameterValue if the instance traits are badly formatted, or contain traits that are not set on the node.

ironic.conductor.utils.validate_port_physnet(task, port_obj)[source]

Validate the consistency of physical networks of ports in a portgroup.

Validate the consistency of a port’s physical network with other ports in the same portgroup. All ports in a portgroup should have the same value (which may be None) for their physical_network field.

During creation or update of a port in a portgroup we apply the following validation criteria:

  • If the portgroup has existing ports with different physical networks, we raise PortgroupPhysnetInconsistent. This shouldn’t ever happen.

  • If the port has a physical network that is inconsistent with other ports in the portgroup, we raise exception.Conflict.

If a port’s physical network is None, this indicates that ironic’s VIF attachment mapping algorithm should operate in a legacy (physical network unaware) mode for this port or portgroup. This allows existing ironic nodes to continue to function after an upgrade to a release including physical network support.

Parameters
  • task – a TaskManager instance

  • port_obj – a port object to be validated.

Raises

Conflict if the port is a member of a portgroup which is on a different physical network.

Raises

PortgroupPhysnetInconsistent if the port’s portgroup has ports which are not all assigned the same physical network.

ironic.conductor.utils.value_within_timeout(value, timeout)[source]

Checks if the time is within the previous timeout seconds from now.

Parameters
  • value – a string representing date and time or None.

  • timeout – timeout in seconds.