ironic.drivers.modules.agent_base module

class ironic.drivers.modules.agent_base.AgentBaseMixin[source]

Bases: object

Mixin with base methods not relying on any deploy steps.

Provides full support for in-band and out-of-band cleaning and the machinery to support both deploy and clean in-band steps.

clean_up(task)[source]

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

Unlinks TFTP and instance images and triggers image cache cleanup. Removes the TFTP configuration files for this node.

Parameters:

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

execute_clean_step(task, step)[source]

Execute a clean step asynchronously on the agent.

Parameters:
  • task – a TaskManager object containing the node

  • step – a clean step dictionary to execute

Raises:

NodeCleaningFailure if the agent does not return a command status

Returns:

states.CLEANWAIT to signify the step will be completed async

get_clean_steps(task)[source]

Get the list of clean steps from the agent.

Parameters:

task – a TaskManager object containing the node

Raises:

NodeCleaningFailure – if the clean steps are not yet available (cached), for example, when a node has just been enrolled and has not been cleaned yet.

Returns:

A list of clean step dictionaries

get_service_steps(task)[source]

Get the list of clean steps from the agent.

Parameters:

task – a TaskManager object containing the node

Returns:

A list of service step dictionaries, if an error occurs, then an empty list is returned.

prepare_cleaning(task)[source]

Boot into the agent to prepare for cleaning.

Parameters:

task – a TaskManager object containing the node

Raises:

NodeCleaningFailure, NetworkError 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.

Returns:

states.CLEANWAIT to signify an asynchronous prepare

prepare_service(task)[source]

Boot into the agent to prepare for service.

Parameters:

task – a TaskManager object containing the node

Raises:

NodeServiceFailure, NetworkError if: the previous service ports cannot be removed or if new service ports cannot be created.

Raises:

InvalidParameterValue if cleaning network UUID config option has an invalid value.

Returns:

states.SERVICEWAIT to signify an asynchronous prepare

process_next_step(task, step_type, **kwargs)[source]

Start the next clean/deploy step if the previous one is complete.

In order to avoid errors and make agent upgrades painless, the agent compares the version of all hardware managers at the start of the process (the agent’s get_clean|deploy_steps() call) and before executing each step. If the version has changed between steps, the agent is unable to tell if an ordering change will cause an issue so it returns VERSION_MISMATCH. For automated cleaning, we restart the entire cleaning cycle. For manual cleaning or deploy, we don’t.

Additionally, if a step includes the reboot_requested property set to True, this method will coordinate the reboot once the step is completed.

refresh_steps(task, step_type)[source]

Refresh the node’s cached clean/deploy steps from the booted agent.

Gets the node’s steps from the booted agent and caches them. The steps are cached to make get_clean_steps() calls synchronous, and should be refreshed as soon as the agent boots to start cleaning/deploy or if cleaning is restarted because of a hardware manager version mismatch.

Parameters:
  • task – a TaskManager instance

  • step_type – ‘clean’ or ‘deploy’

Raises:

NodeCleaningFailure or InstanceDeployFailure if the agent returns invalid results

should_manage_boot(task)[source]

Whether agent boot is managed by ironic.

take_over(task)[source]

Take over management of this node from a dead conductor.

Parameters:

task – a TaskManager instance.

tear_down(task)[source]

Tear down a previous deployment on the task’s node.

Power off the node. All actual clean-up is done in the clean_up() method which should be called separately.

Parameters:

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

Returns:

deploy state DELETED.

Raises:

NetworkError if the cleaning ports cannot be removed.

Raises:

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

Raises:

StorageError when volume detachment fails.

Raises:

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

tear_down_cleaning(task)[source]

Clean up the PXE and DHCP files after cleaning.

Parameters:

task – a TaskManager object containing the node

Raises:

NodeCleaningFailure, NetworkError if the cleaning ports cannot be removed

tear_down_service(task)[source]

Clean up the PXE and DHCP files after service.

Parameters:

task – a TaskManager object containing the node

Raises:

NodeServiceFailure, NetworkError if the servicing ports cannot be removed

class ironic.drivers.modules.agent_base.AgentDeployMixin[source]

Bases: HeartbeatMixin, AgentOobStepsMixin

Mixin with deploy methods.

configure_local_boot(task, root_uuid=None, efi_system_part_uuid=None, prep_boot_part_uuid=None)[source]

Helper method to configure local boot on the node.

This method triggers bootloader installation on the node. On successful installation of bootloader, this method sets the node to boot from disk.

Parameters:
  • task – a TaskManager object containing the node

  • root_uuid – The UUID of the root partition. This is used for identifying the partition which contains the image deployed or None in case of whole disk images which we expect to already have a bootloader installed.

  • efi_system_part_uuid – The UUID of the efi system partition. This is used only in uefi boot mode.

  • prep_boot_part_uuid – The UUID of the PReP Boot partition. This is used only for booting ppc64* hardware.

Raises:

InstanceDeployFailure if bootloader installation failed or on encountering error while setting the boot device on the node.

execute_deploy_step(task, step)[source]

Execute a deploy step.

We’re trying to find a step among both out-of-band and in-band steps. In case of duplicates, out-of-band steps take priority. This property allows having an out-of-band deploy step that calls into a corresponding in-band step after some preparation (e.g. with additional input).

Parameters:
  • task – a TaskManager object containing the node

  • step – a deploy step dictionary to execute

Raises:

InstanceDeployFailure if the agent does not return a command status

Returns:

states.DEPLOYWAIT to signify the step will be completed async

get_deploy_steps(task)[source]

Get the list of deploy steps from the agent.

Parameters:

task – a TaskManager object containing the node

Raises:

InstanceDeployFailure – if the deploy steps are not yet available (cached), for example, when a node has just been enrolled and has not been deployed yet.

Returns:

A list of deploy step dictionaries

prepare_instance_to_boot(task, root_uuid, efi_sys_uuid, prep_boot_part_uuid=None)[source]

Prepares instance to boot.

Parameters:
  • task – a TaskManager object containing the node

  • root_uuid – the UUID for root partition

  • efi_sys_uuid – the UUID for the efi partition

Raises:

InvalidState if fails to prepare instance

tear_down_agent(task)[source]

A deploy step to tear down the agent.

Parameters:

task – a TaskManager object containing the node

class ironic.drivers.modules.agent_base.AgentOobStepsMixin[source]

Bases: object

Mixin with out-of-band deploy steps.

boot_instance(task)[source]

Deploy step to boot the final instance.

Parameters:

task – a TaskManager object containing the node

switch_to_tenant_network(task)[source]

Deploy step to switch the node to the tenant network.

Parameters:

task – a TaskManager object containing the node

class ironic.drivers.modules.agent_base.HeartbeatMixin[source]

Bases: object

Mixin class implementing heartbeat processing.

collect_deploy_logs = True
continue_cleaning(task)[source]

Start the next cleaning step if the previous one is complete.

Parameters:

task – a TaskManager instance

continue_servicing(task)[source]

Start the next cleaning step if the previous one is complete.

Parameters:

task – a TaskManager instance

heartbeat(task, callback_url, agent_version, agent_verify_ca=None, agent_status=None, agent_status_message=None)[source]

Process a heartbeat.

Parameters:
  • task – task to work with.

  • callback_url – agent HTTP API URL.

  • agent_version – The version of the agent that is heartbeating

  • agent_verify_ca – TLS certificate for the agent.

  • agent_status – Status of the heartbeating agent

  • agent_status_message – Status message that describes the agent_status

heartbeat_allowed(node)[source]
process_next_step(task, step_type)[source]

Start the next step if the previous one is complete.

Parameters:
  • task – a TaskManager instance

  • step_type – “clean”, “deploy”, “service”

reboot_to_instance(task)[source]

Method invoked after the deployment is completed.

Parameters:

task – a TaskManager instance

refresh_clean_steps(task)[source]

Refresh the node’s cached clean steps

Parameters:

task – a TaskManager instance

refresh_service_steps(task)[source]

Refresh the node’s cached service steps

Parameters:

task – a TaskManager instance

refresh_steps(task, step_type)[source]

Refresh the node’s cached clean steps

Parameters:
  • task – a TaskManager instance

  • step_type – “clean” or “deploy”

ironic.drivers.modules.agent_base.execute_clean_step(task, step)[source]
ironic.drivers.modules.agent_base.execute_step(task, step, step_type, client=None)[source]

Execute a clean or deploy step asynchronously on the agent.

Parameters:
  • task – a TaskManager object containing the node

  • step – a step dictionary to execute

  • step_type – ‘clean’ or ‘deploy’

  • client – agent client (if available)

Raises:

NodeCleaningFailure (clean step) or InstanceDeployFailure (deploy step) if the agent does not return a command status.

Returns:

states.CLEANWAIT/DEPLOYWAIT to signify the step will be completed async

ironic.drivers.modules.agent_base.find_step(task, step_type, interface, name)[source]

Find the given in-band step.

ironic.drivers.modules.agent_base.get_steps(task, step_type, interface=None, override_priorities=None)[source]

Get the list of cached clean or deploy steps from the agent.

The steps cache is updated at the beginning of cleaning or deploy.

Parameters:
  • task – a TaskManager object containing the node

  • step_type – ‘clean’ or ‘deploy’

  • interface – The interface for which clean/deploy steps are to be returned. If this is not provided, it returns the steps for all interfaces.

  • override_priorities – a dictionary with keys being step names and values being new priorities for them. If a step isn’t in this dictionary, the step’s original priority is used.

Returns:

A list of clean/deploy step dictionaries

ironic.drivers.modules.agent_base.log_and_raise_deployment_error(task, msg, collect_logs=True, exc=None)[source]

Helper method to log the error and raise exception.

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

  • msg – the message to set in 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.

  • exc – Exception that caused the failure.

ironic.drivers.modules.agent_base.post_clean_step_hook(interface, step)[source]

Decorator method for adding a post clean step hook.

This is a mechanism for adding a post clean step hook for a particular clean step. The hook will get executed after the clean step gets executed successfully. The hook is not invoked on failure of the clean step.

Any method to be made as a hook may be decorated with @post_clean_step_hook mentioning the interface and step after which the hook should be executed. A TaskManager instance and the object for the last completed command (provided by agent) will be passed to the hook method. The return value of this method will be ignored. Any exception raised by this method will be treated as a failure of the clean step and the node will be moved to CLEANFAIL state.

Parameters:
  • interface – name of the interface

  • step – The name of the step after which it should be executed.

Returns:

A method which registers the given method as a post clean step hook.

ironic.drivers.modules.agent_base.post_deploy_step_hook(interface, step)[source]

Decorator method for adding a post deploy step hook.

This is a mechanism for adding a post deploy step hook for a particular deploy step. The hook will get executed after the deploy step gets executed successfully. The hook is not invoked on failure of the deploy step.

Any method to be made as a hook may be decorated with @post_deploy_step_hook mentioning the interface and step after which the hook should be executed. A TaskManager instance and the object for the last completed command (provided by agent) will be passed to the hook method. The return value of this method will be ignored. Any exception raised by this method will be treated as a failure of the deploy step and the node will be moved to DEPLOYFAIL state.

Parameters:
  • interface – name of the interface

  • step – The name of the step after which it should be executed.

Returns:

A method which registers the given method as a post deploy step hook.