The ironic.drivers.modules.ssh Module

Ironic SSH power manager.

Provides basic power control of virtual machines via SSH.

For use in dev and test environments.

Currently supported environments are:
Virtual Box (vbox) Virsh (virsh) VMware (vmware) Parallels (parallels) XenServer (xenserver)
class ironic.drivers.modules.ssh.SSHManagement[source]

Bases: ironic.drivers.base.ManagementInterface

get_boot_device(task)[source]

Get the current boot device for the task’s node.

Provides the current boot device of the node. Be aware that not all drivers support this.

Parameters:task – a task from TaskManager.
Raises:InvalidParameterValue if any connection parameters are incorrect.
Raises:MissingParameterValue if a required parameter is missing
Raises:SSHConnectFailed if ssh failed to connect to the node.
Raises:SSHCommandFailed on an error from ssh.
Raises:NodeNotFound if could not find a VM corresponding to any of the provided MACs.
Returns:a dictionary containing:
boot_device:the boot device, one of ironic.common.boot_devices or None if it is unknown.
persistent:Whether the boot device will persist to all future boots or not, None if it is unknown.
get_properties()[source]
get_sensors_data(task)[source]

Get sensors data.

Not implemented by this driver.

Parameters:task – a TaskManager instance.
get_supported_boot_devices(task)[source]

Get a list of the supported boot devices.

Parameters:task – a task from TaskManager.
Returns:A list with the supported boot devices defined in ironic.common.boot_devices.
set_boot_device(*args, **kwargs)[source]

Set the boot device for the task’s node.

Set the boot device to use on next reboot of the node.

Parameters:
  • task – a task from TaskManager.
  • device – the boot device, one of ironic.common.boot_devices.
  • persistent – Boolean value. True if the boot device will persist to all future boots, False if not. Default: False. Ignored by this driver.
Raises:

InvalidParameterValue if an invalid boot device is specified or if any connection parameters are incorrect.

Raises:

MissingParameterValue if a required parameter is missing

Raises:

SSHConnectFailed if ssh failed to connect to the node.

Raises:

SSHCommandFailed on an error from ssh.

Raises:

NotImplementedError if the virt_type does not support setting the boot device.

Raises:

NodeNotFound if could not find a VM corresponding to any of the provided MACs.

validate(task)[source]

Check that ‘driver_info’ contains SSH credentials.

Validates whether the ‘driver_info’ property of the supplied task’s node contains the required credentials information.

Parameters:task – a task from TaskManager.
Raises:InvalidParameterValue if any connection parameters are incorrect.
Raises:MissingParameterValue if a required parameter is missing
class ironic.drivers.modules.ssh.SSHPower[source]

Bases: ironic.drivers.base.PowerInterface

SSH Power Interface.

This PowerInterface class provides a mechanism for controlling the power state of virtual machines via SSH.

NOTE: This driver supports VirtualBox and Virsh commands. NOTE: This driver does not currently support multi-node operations.

get_power_state(task)[source]

Get the current power state of the task’s node.

Poll the host for the current power state of the task’s node.

Parameters:task – a TaskManager instance containing the node to act on.
Returns:power state. One of ironic.common.states.
Raises:InvalidParameterValue if any connection parameters are incorrect.
Raises:MissingParameterValue when a required parameter is missing
Raises:NodeNotFound if could not find a VM corresponding to any of the provided MACs.
Raises:SSHCommandFailed on an error from ssh.
Raises:SSHConnectFailed if ssh failed to connect to the node.
get_properties()[source]
reboot(*args, **kwargs)[source]

Cycles the power to the task’s node.

Power cycles a node.

Parameters:task – a TaskManager instance containing the node to act on.
Raises:InvalidParameterValue if any connection parameters are incorrect.
Raises:MissingParameterValue when a required parameter is missing
Raises:NodeNotFound if could not find a VM corresponding to any of the provided MACs.
Raises:PowerStateFailure if it failed to set power state to POWER_ON.
Raises:SSHCommandFailed on an error from ssh.
Raises:SSHConnectFailed if ssh failed to connect to the node.
set_power_state(*args, **kwargs)[source]

Turn the power on or off.

Set the power state of the task’s node.

Parameters:
  • task – a TaskManager instance containing the node to act on.
  • pstate – Either POWER_ON or POWER_OFF from :class: ironic.common.states.
Raises:

InvalidParameterValue if any connection parameters are incorrect, or if the desired power state is invalid.

Raises:

MissingParameterValue when a required parameter is missing

Raises:

NodeNotFound if could not find a VM corresponding to any of the provided MACs.

Raises:

PowerStateFailure if it failed to set power state to pstate.

Raises:

SSHCommandFailed on an error from ssh.

Raises:

SSHConnectFailed if ssh failed to connect to the node.

validate(task)[source]

Check that the node’s ‘driver_info’ is valid.

Check that the node’s ‘driver_info’ contains the requisite fields and that an SSH connection to the node can be established.

Parameters:task – a TaskManager instance containing the node to act on.
Raises:InvalidParameterValue if any connection parameters are incorrect or if ssh failed to connect to the node.
Raises:MissingParameterValue if no ports are enrolled for the given node.
class ironic.drivers.modules.ssh.ShellinaboxConsole[source]

Bases: ironic.drivers.base.ConsoleInterface

A ConsoleInterface that uses ssh and shellinabox.

get_console(task)[source]

Get the type and connection information about the console.

Parameters:task – a task from TaskManager
Raises:MissingParameterValue if required ssh parameters are missing
Raises:InvalidParameterValue if required parameter are invalid.
get_properties()[source]
start_console(task)[source]

Start a remote console for the node.

Parameters:task – a task from TaskManager
Raises:MissingParameterValue if required ssh parameters are missing
Raises:ConsoleError if the directory for the PID file cannot be created
Raises:ConsoleSubprocessFailed when invoking the subprocess failed
Raises:InvalidParameterValue if required parameters are invalid.
stop_console(task)[source]

Stop the remote console session for the node.

Parameters:task – a task from TaskManager
Raises:ConsoleError if unable to stop the console
validate(task)[source]

Validate the Node console info.

Parameters:task – a task from TaskManager.
Raises:MissingParameterValue if required ssh parameters are missing
Raises:InvalidParameterValue if required parameters are invalid.