ironic.drivers.modules.agent_client module¶
- class ironic.drivers.modules.agent_client.AgentClient[source]¶
- Bases: - object- Client for interacting with nodes via a REST API. - collect_system_logs(node)[source]¶
- Collect and package diagnostic and support data from the ramdisk. - Parameters:
- node – A Node object. 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 - execute_clean_step(step, node, ports)[source]¶
- Execute specified clean step. - Parameters:
- step – A clean step dictionary to execute. 
- node – A Node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'clean_result': <the result of execution, step specific>, 'clean_step': <the clean step issued to agent> } 
 
 - execute_deploy_step(step, node, ports)[source]¶
- Execute specified deploy step. - Parameters:
- step – A deploy step dictionary to execute. 
- node – A Node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'deploy_result': <the result of execution, step specific>, 'deploy_step': <the deploy step issued to agent> } 
 
 - execute_service_step(step, node, ports)[source]¶
- Execute specified service step. - Parameters:
- step – A service step dictionary to execute. 
- node – A Node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'service_result': <the result of execution, step specific>, 'service_step': <the service step issued to agent> } 
 
 - finalize_rescue(node)[source]¶
- Instruct the ramdisk to finalize entering of rescue mode. - Parameters:
- node – A Node object. 
- Raises:
- IronicException if rescue_password is missing, or when failed to issue the request, or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Raises:
- InstanceRescueFailure when the agent ramdisk is too old to support transmission of the rescue password. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 - get_clean_steps(node, ports)[source]¶
- Get clean steps from agent. - Parameters:
- node – A node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'clean_steps': <a list of clean steps>, 'hardware_manager_version': <manager version> } 
 
 - get_commands_status(node, retry_connection=True, expect_errors=False)[source]¶
- Get command status from agent. - Parameters:
- node – A Node object. 
- retry_connection – Whether to retry connection problems. 
- expect_errors – If True, do not log connection problems as errors. 
 
- Returns:
- A list of command results, each result is related to a command been issued to agent. A typical result can be: - { 'command_name': <command name related to the result>, 'command_params': <params related with the command>, 'command_status': <current command status, e.g. 'RUNNING', 'SUCCEEDED', 'FAILED'>, 'command_error': <error message if command execution failed>, 'command_result': <command result if command execution succeeded, the value is command specific, e.g.: * a dictionary containing keys clean_result and clean_step for the command clean.execute_clean_step; * a dictionary containing keys deploy_result and deploy_step for the command deploy.execute_deploy_step; * a string representing result message for the command standby.cache_image; * None for the command standby.sync.> } 
 
 - get_deploy_steps(node, ports)[source]¶
- Get deploy steps from agent. - Parameters:
- node – A node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentConnectionFailed when an a transient connection failure breaks the connection while the request is being processed. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'deploy_steps': <a list of deploy steps>, 'hardware_manager_version': <manager version> } 
 
 - get_last_command_status(node, method)[source]¶
- Get the last status for the given command. - Parameters:
- node – A Node object. 
- method – Command name. 
 
- Returns:
- A dict containing command status from agent or None if the command was not found. 
 
 - get_partition_uuids(node)[source]¶
- Get deploy steps from agent. - Parameters:
- node – A node object. 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. 
 
 - get_service_steps(node, ports)[source]¶
- Get service steps from agent. - Parameters:
- node – A node object. 
- ports – Ports associated with the node. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample. The value of key command_result is in the form of:- { 'service_steps': <a list of service steps>, 'hardware_manager_version': <manager version> } 
 
 - install_bootloader(node, root_uuid, target_boot_mode, efi_system_part_uuid=None, prep_boot_part_uuid=None, software_raid=False)[source]¶
- Install a boot loader on the image. - Parameters:
- node – A node object. 
- root_uuid – The UUID of the root partition. 
- target_boot_mode – The target deployment boot mode. 
- efi_system_part_uuid – The UUID of the efi system partition where the bootloader will be installed to, only used for uefi boot mode. 
- prep_boot_part_uuid – The UUID of the PReP Boot partition where the bootloader will be installed to when local booting a partition image on a ppc64* system. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 - lockdown(node, fail_if_unavailable=True)[source]¶
- Lock down the agent so that it’s not usable any more. - Parameters:
- node – A Node object. 
- fail_if_unavailable – Whether to fail this call if the agent is already unavailable. 
 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
 
 - power_off(node)[source]¶
- Soft powers off the bare metal node by shutting down ramdisk OS. - Parameters:
- node – A Node object. 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 - reboot(node)[source]¶
- Soft reboots the bare metal node by shutting down ramdisk OS. - Parameters:
- node – A Node object. 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 - sync(node)[source]¶
- Flush file system buffers forcing changed blocks to disk. - Parameters:
- node – A Node object. 
- Raises:
- IronicException when failed to issue the request or there was a malformed response from the agent. 
- Raises:
- AgentAPIError when agent failed to execute specified command. 
- Raises:
- AgentInProgress when the command fails to execute as the agent is presently executing the prior command. 
- Returns:
- A dict containing command response from agent. See - get_commands_status()for a command result sample.
 
 
