ironic.drivers.modules.fake module

Fake driver interfaces used in testing.

This is also an example of some kinds of things which can be done within drivers. For instance, the MultipleVendorInterface class demonstrates how to load more than one interface and wrap them in some logic to route incoming vendor_passthru requests appropriately. This can be useful eg. when mixing functionality between a power interface and a deploy interface, when both rely on separate vendor_passthru methods.

class ironic.drivers.modules.fake.FakeBIOS(*args, **kwargs)[source]

Bases: BIOSInterface

Fake implementation of simple BIOSInterface.

apply_configuration(task, settings)[source]

Validate & apply BIOS settings on the given node.

This method takes the BIOS settings from the settings param and applies BIOS settings on the given node. It may also validate the given bios settings before applying any settings and manage failures when setting an invalid BIOS config. In the case of needing password to update the BIOS config, it will be taken from the driver_info properties. After the BIOS configuration is done, cache_bios_settings will be called to update the node’s BIOS setting table with the BIOS configuration applied on the node.

Parameters:
  • task – a TaskManager instance.

  • settings – Dictionary containing the BIOS configuration.

Raises:

UnsupportedDriverExtension, if the node’s driver doesn’t support BIOS configuration.

Raises:

InvalidParameterValue, if validation of settings fails.

Raises:

MissingParameterValue, if some required parameters are missing.

Returns:

states.CLEANWAIT if BIOS configuration is in progress asynchronously or None if it is complete.

cache_bios_settings(task)[source]

Store or update BIOS properties on the given node.

This method stores BIOS properties to the bios_settings table during ‘cleaning’ operation and updates bios_settings table when apply_configuration() and factory_reset() are called to set new BIOS configurations. It will also update the timestamp of each bios setting.

Parameters:

task – a TaskManager instance.

Raises:

UnsupportedDriverExtension, if the node’s driver doesn’t support getting BIOS properties from bare metal.

Returns:

None.

factory_reset(task)[source]

Reset BIOS configuration to factory default on the given node.

This method resets BIOS configuration to factory default on the given node. After the BIOS reset action is done, cache_bios_settings will be called to update the node’s BIOS settings table with default bios settings.

Parameters:

task – a TaskManager instance.

Raises:

UnsupportedDriverExtension, if the node’s driver doesn’t support BIOS reset.

Returns:

states.CLEANWAIT if BIOS configuration is in progress asynchronously or None if it is complete.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeBoot(*args, **kwargs)[source]

Bases: BootInterface

Example implementation of a simple boot interface.

capabilities = ['ipxe_boot', 'pxe_boot']
clean_up_instance(task)[source]

Cleans up the boot of instance.

This method cleans up the environment that was setup for booting the instance.

Parameters:

task – A task from TaskManager.

Returns:

None

clean_up_ramdisk(task, mode='deploy')[source]

Cleans up the boot of ironic ramdisk.

This method cleans up the environment that was setup for booting the deploy or rescue ramdisk.

Parameters:

task – A task from TaskManager.

Returns:

None

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

prepare_instance(task)[source]

Prepares the boot of instance.

This method prepares the boot of the instance after reading relevant information from the node’s database.

Parameters:

task – A task from TaskManager.

Returns:

None

prepare_ramdisk(task, ramdisk_params, mode='deploy')[source]

Prepares the boot of Ironic ramdisk.

This method prepares the boot of the deploy or rescue ramdisk after reading relevant information from the node’s database.

Parameters:
  • task – A task from TaskManager.

  • ramdisk_params

    The options to be passed to the ironic ramdisk. Different implementations might want to boot the ramdisk in different ways by passing parameters to them. For example,

    When Agent ramdisk is booted to deploy a node, it takes the parameters ipa-api-url, etc.

    Other implementations can make use of ramdisk_params to pass such information. Different implementations of boot interface will have different ways of passing parameters to the ramdisk.

Returns:

None

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeConsole(*args, **kwargs)[source]

Bases: ConsoleInterface

Example implementation of a simple console interface.

get_console(task)[source]

Get connection information about the console.

This method should return the necessary information for the client to access the console.

Parameters:

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

Returns:

the console connection information.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

start_console(task)[source]

Start a remote console for the task’s node.

This method should not raise an exception if console already started.

Parameters:

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

stop_console(task)[source]

Stop the remote console session for the task’s node.

Parameters:

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

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeDeploy(*args, **kwargs)[source]

Bases: DeployInterface

Class for a fake deployment driver.

Example implementation of a deploy interface that uses a separate power interface.

clean_up(task)[source]

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

If preparation of the deployment environment ahead of time is possible, this method should be implemented by the driver. It should erase anything cached by the prepare method.

If implemented, this method must be idempotent. It may be called multiple times for the same node on the same conductor, and it may be called by multiple conductors in parallel. Therefore, it must not require an exclusive lock.

This method is called before tear_down.

Parameters:

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

deploy(task)[source]

Perform a deployment to the task’s node.

Perform the necessary work to deploy an image onto the specified node. This method will be called after prepare(), which may have already performed any preparatory steps, such as pre-caching some data for the node.

Parameters:

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

Returns:

status of the deploy. One of ironic.common.states.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

prepare(task)[source]

Prepare the deployment environment for the task’s node.

If preparation of the deployment environment ahead of time is possible, this method should be implemented by the driver.

If implemented, this method must be idempotent. It may be called multiple times for the same node on the same conductor.

This method is called before deploy.

Parameters:

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

take_over(task)[source]

Take over management of this task’s node from a dead conductor.

If conductors’ hosts maintain a static relationship to nodes, this method should be implemented by the driver to allow conductors to perform the necessary work during the remapping of nodes to conductors when a conductor joins or leaves the cluster.

For example, the PXE driver has an external dependency:

Neutron must forward DHCP BOOT requests to a conductor which has prepared the tftpboot environment for the given node. When a conductor goes offline, another conductor must change this setting in Neutron as part of remapping that node’s control to itself. This is performed within the takeover method.

Parameters:

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

tear_down(task)[source]

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

Given a node that has been previously deployed to, do all cleanup and tear down necessary to “un-deploy” that node.

Parameters:

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

Returns:

status of the deploy. One of ironic.common.states.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeFirmware(*args, **kwargs)[source]

Bases: FirmwareInterface

Example implementation of a simple firmware interface.

cache_firmware_components(task)[source]

Store or update Firmware Components on the given node.

This method stores Firmware Components to the firmware_information table during ‘cleaning’ operation. It will also update the timestamp of each Firmware Component.

Parameters:

task – a TaskManager instance.

Raises:

UnsupportedDriverExtension, if the node’s driver doesn’t support getting Firmware Components from bare metal.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

update(task, settings)[source]

Update the Firmware on the given using the settings for components.

Parameters:
  • task – a TaskManager instance.

  • settings – a list of dictionaries, each dictionary contains the component name and the url that will be used to update the firmware.

Raises:

UnsupportedDriverExtension, if the node’s driver doesn’t support update via the interface.

Raises:

InvalidParameterValue, if validation of the settings fails.

Raises:

MissingParamterValue, if some required parameters are missing.

Returns:

states.CLEANWAIT if Firmware update with the settings is in progress asynchronously of None if it is complete.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeInspect(*args, **kwargs)[source]

Bases: InspectInterface

Example implementation of a simple inspect interface.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

inspect_hardware(task)[source]

Inspect hardware.

Inspect hardware to obtain the essential & additional hardware properties.

Parameters:

task – A task from TaskManager.

Raises:

HardwareInspectionFailure, if unable to get essential hardware properties.

Returns:

Resulting state of the inspection i.e. states.MANAGEABLE or None.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeManagement(*args, **kwargs)[source]

Bases: ManagementInterface

Example implementation of a simple management interface.

get_boot_device(task)[source]

Get the current boot device for a node.

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

Parameters:

task – A task from TaskManager.

Raises:

MissingParameterValue if a required parameter is missing

Returns:

A dictionary containing:

boot_device:

Ahe 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_indicator_state(task, component, indicator)[source]

Get current state of the indicator of the hardware component.

Parameters:
  • task – A task from TaskManager.

  • component – The hardware component, one of ironic.common.components.

  • indicator – Indicator ID (as reported by get_supported_indicators).

Raises:

InvalidParameterValue if an invalid component or indicator is specified.

Raises:

MissingParameterValue if a required parameter is missing

Returns:

Current state of the indicator, one of ironic.common.indicator_states.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

get_sensors_data(task)[source]

Get sensors data method.

Parameters:

task – A TaskManager instance.

Raises:

FailedToGetSensorData when getting the sensor data fails.

Raises:

FailedToParseSensorData when parsing sensor data fails.

Returns:

Returns a consistent format dict of sensor data grouped by sensor type, which can be processed by Ceilometer. eg,

{
  'Sensor Type 1': {
    'Sensor ID 1': {
      'Sensor Reading': 'current value',
      'key1': 'value1',
      'key2': 'value2'
    },
    'Sensor ID 2': {
      'Sensor Reading': 'current value',
      'key1': 'value1',
      'key2': 'value2'
    }
  },
  'Sensor Type 2': {
    'Sensor ID 3': {
      'Sensor Reading': 'current value',
      'key1': 'value1',
      'key2': 'value2'
    },
    'Sensor ID 4': {
      'Sensor Reading': 'current value',
      'key1': 'value1',
      'key2': 'value2'
    }
  }
}

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.

get_supported_indicators(task, component=None)[source]

Get a map of the supported indicators (e.g. LEDs).

Parameters:
  • task – A task from TaskManager.

  • component – If not None, return indicator information for just this component, otherwise return indicators for all existing components.

Returns:

A dictionary of hardware components (ironic.common.components) as keys with values being dictionaries having indicator IDs as keys and indicator properties as values.

{
    'chassis': {
        'enclosure-0': {
            "readonly": true,
            "states": [
                "off",
                "on"
            ]
        }
    },
    'system':
        'blade-A': {
            "readonly": true,
            "states": [
                "pff",
                "on"
            ]
        }
    },
    'drive':
        'ssd0': {
            "readonly": true,
            "states": [
                "off",
                "on"
            ]
        }
    }
}

set_boot_device(task, device, persistent=False)[source]

Set the boot device for a 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.

Raises:

InvalidParameterValue if an invalid boot device is specified.

Raises:

MissingParameterValue if a required parameter is missing

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakePower(*args, **kwargs)[source]

Bases: PowerInterface

Example implementation of a simple power interface.

get_power_state(task)[source]

Return the power state of the task’s node.

Parameters:

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

Raises:

MissingParameterValue if a required parameter is missing.

Returns:

A power state. One of ironic.common.states.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

get_supported_power_states(task)[source]

Get a list of the supported power states.

Parameters:

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

Returns:

A list with the supported power states defined in ironic.common.states.

reboot(task, timeout=None)[source]

Perform a hard reboot of the task’s node.

Drivers are expected to properly handle case when node is powered off by powering it on.

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

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

Raises:

MissingParameterValue if a required parameter is missing.

set_power_state(task, power_state, timeout=None)[source]

Set the power state of the task’s node.

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

  • power_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:

MissingParameterValue if a required parameter is missing.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeRAID(*args, **kwargs)[source]

Bases: RAIDInterface

Example implementation of simple RAIDInterface.

create_configuration(task, create_root_volume=True, create_nonroot_volumes=True)[source]

Creates RAID configuration on the given node.

This method creates a RAID configuration on the given node. It assumes that the target RAID configuration is already available in node.target_raid_config. Implementations of this interface are supposed to read the RAID configuration from node.target_raid_config. After the RAID configuration is done (either in this method OR in a call-back method), ironic.common.raid.update_raid_info() may be called to sync the node’s RAID-related information with the RAID configuration applied on the node.

Parameters:
  • task – A TaskManager instance.

  • create_root_volume – Setting this to False indicates not to create root volume that is specified in the node’s target_raid_config. Default value is True.

  • create_nonroot_volumes – Setting this to False indicates not to create non-root volumes (all except the root volume) in the node’s target_raid_config. Default value is True.

  • delete_existing – Setting this to True indicates to delete RAID configuration prior to creating the new configuration.

Returns:

states.CLEANWAIT (cleaning) or states.DEPLOYWAIT (deployment) if RAID configuration is in progress asynchronously, or None if it is complete.

delete_configuration(task)[source]

Deletes RAID configuration on the given node.

This method deletes the RAID configuration on the give node. After RAID configuration is deleted, node.raid_config should be cleared by the implementation.

Parameters:

task – A TaskManager instance.

Returns:

states.CLEANWAIT (cleaning) or states.DEPLOYWAIT (deployment) if deletion is in progress asynchronously, or None if it is complete.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

class ironic.drivers.modules.fake.FakeRescue(*args, **kwargs)[source]

Bases: RescueInterface

Example implementation of a simple rescue interface.

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

rescue(task)[source]

Boot the task’s node into a rescue environment.

Parameters:

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

Raises:

InstanceRescueFailure if node validation or rescue operation fails.

Returns:

states.RESCUEWAIT if rescue is in progress asynchronously or states.RESCUE if it is complete.

unrescue(task)[source]

Tear down the rescue environment, and return to normal.

Parameters:

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

Raises:

InstanceUnrescueFailure if node validation or unrescue operation fails.

Returns:

states.ACTIVE if it is successful.

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeStorage(*args, **kwargs)[source]

Bases: StorageInterface

Example implementation of simple storage Interface.

attach_volumes(task)[source]

Informs the storage subsystem to attach all volumes for the node.

Parameters:

task – A TaskManager instance.

Raises:

UnsupportedDriverExtension

detach_volumes(task)[source]

Informs the storage subsystem to detach all volumes for the node.

Parameters:

task – A TaskManager instance.

Raises:

UnsupportedDriverExtension

get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

should_write_image(task)[source]

Determines if deploy should perform the image write-out.

Parameters:

task – A TaskManager instance.

Returns:

Boolean value to indicate if the interface expects the image to be written by Ironic.

Raises:

UnsupportedDriverExtension

validate(task)[source]

Validate the driver-specific Node deployment info.

This method validates whether the ‘driver_info’ and/or ‘instance_info’ properties of the task’s node contains the required information for this interface to function.

This method is often executed synchronously in API requests, so it should not conduct long-running checks.

Parameters:

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

Raises:

InvalidParameterValue on malformed parameter(s)

Raises:

MissingParameterValue on missing parameter(s)

class ironic.drivers.modules.fake.FakeVendorA(*args, **kwargs)[source]

Bases: VendorInterface

Example implementation of a vendor passthru interface.

first_method(task, http_method, bar)[source]
get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

validate(task, method, **kwargs)[source]

Validate vendor-specific actions.

If invalid, raises an exception; otherwise returns None.

Parameters:
  • task – A task from TaskManager.

  • method – Method to be validated

  • kwargs – Info for action.

Raises:

UnsupportedDriverExtension if ‘method’ can not be mapped to the supported interfaces.

Raises:

InvalidParameterValue if kwargs does not contain ‘method’.

Raises:

MissingParameterValue

class ironic.drivers.modules.fake.FakeVendorB(*args, **kwargs)[source]

Bases: VendorInterface

Example implementation of a secondary vendor passthru.

fourth_method_shared_lock(task, http_method, bar)[source]
get_properties()[source]

Return the properties of the interface.

Returns:

dictionary of <property name>:<property description> entries.

log_passthrough(task, **kwargs)[source]
second_method(task, http_method, bar)[source]
third_method_sync(task, http_method, bar)[source]
trigger_servicewait(task, **kwargs)[source]
validate(task, method, **kwargs)[source]

Validate vendor-specific actions.

If invalid, raises an exception; otherwise returns None.

Parameters:
  • task – A task from TaskManager.

  • method – Method to be validated

  • kwargs – Info for action.

Raises:

UnsupportedDriverExtension if ‘method’ can not be mapped to the supported interfaces.

Raises:

InvalidParameterValue if kwargs does not contain ‘method’.

Raises:

MissingParameterValue

ironic.drivers.modules.fake.parse_sleep_range(sleep_range)[source]
ironic.drivers.modules.fake.sleep(sleep_range)[source]