ironic.drivers.modules.switch.base module

Base classes for networking service switch drivers.

This module defines the base interface that all switch drivers must implement to provide vendor-specific network switch management functionality.

class ironic.drivers.modules.switch.base.BaseTranslator[source]

Bases: object

Base class for configuration translators.

translate_config(switch_name, config)[source]

Translate a single switch configuration.

Parameters:
  • switch_name – Name of the switch

  • config – Dictionary of configuration options for the switch

Returns:

Dictionary of section_name -> translated_config_dict

translate_configs(switch_configs)[source]

Translate all switch configurations.

Parameters:

switch_configs – Dictionary of switch_name -> config_dict

Returns:

Dictionary of section_name -> translated_config_dict

class ironic.drivers.modules.switch.base.NoOpSwitchDriver[source]

Bases: SwitchDriverBase

No-operation switch driver for testing and development.

This driver implements all required methods but performs no actual switch operations. It’s useful for testing the networking service without requiring actual switch hardware.

DRIVER_NAME = 'noop'
DRIVER_VERSION = '1.0.0'
SUPPORTED = True
delete_lag(switch_ids, lag_name)[source]

LAG deletion without performing actual deletion.

get_switch_ids()[source]

Return a list of switch identifiers.

get_switch_info(switch_id)[source]

Return mock switch information.

classmethod get_translator()[source]

Return the translator.

is_switch_configured(switch_id)[source]

Check if NoOp driver can handle the specified switch.

For testing purposes, the NoOp driver always returns True, meaning it can handle any switch. This simplifies testing and provides a fallback for development environments.

Parameters:

switch_id – Identifier for the switch to check.

Returns:

Always True for testing purposes.

reset_port(switch_id, port_name, native_vlan=None, allowed_vlans=None, default_vlan=None)[source]

Log port reset operation without performing actual reset.

update_lag(switch_ids, lag_name, description, mode, native_vlan, aggregation_mode, allowed_vlans=None, default_vlan=None)[source]

Log LAG update without performing actual configuration.

update_port(switch_id, port_name, description, mode, native_vlan, allowed_vlans=None, default_vlan=None, lag_name=None)[source]

Log port update operation without performing actual change.

class ironic.drivers.modules.switch.base.SwitchDriverBase[source]

Bases: object

Base class for all switch drivers.

Switch drivers provide vendor-specific implementations for managing network switches. They are loaded dynamically by the networking service based on configuration and handle operations like port configuration, VLAN management, and LAG operations.

DRIVER_NAME = None
DRIVER_VERSION = None
SUPPORTED = True
abstract delete_lag(switch_ids, lag_name)[source]

Delete LAG configuration from switches.

Parameters:
  • switch_ids – List of switch identifiers.

  • lag_name – Name of the LAG to delete.

Raises:

ValueError on parameter validation errors.

Raises:

SwitchNotFound if the specified switch does not exist.

Raises:

SwitchDriverException on configuration failures.

abstract get_switch_ids()[source]

Return a list of switch identifiers.

Returns:

List of switch identifiers or an empty list.

abstract get_switch_info(switch_id)[source]

Get information about a switch.

This method should return a dictionary containing information about the specified switch. The dictionary can include various attributes that control the behavior of the networking service for this switch.

Supported attributes: - switch_id: Identifier for the switch - device_name: The name of the switch device - device_type: The type of the switch device - ip: IP address of the switch device

Parameters:

switch_id – Identifier for the switch.

Returns:

Dictionary with switch information or None.

Raises:

SwitchNotFound if the specified switch does not exist.

abstract classmethod get_translator()[source]

Return the translator for this driver’s config entries.

is_switch_configured(switch_id)[source]

Check if this driver is configured to manage the specified switch.

This method should return True if this driver is configured to handle the specified switch. This is used by the driver selection logic to determine which driver should handle a specific switch.

Parameters:

switch_id – Identifier for the switch to check.

Returns:

True if this driver can manage the specified switch, False otherwise.

abstract reset_port(switch_id, port_name, native_vlan=None, allowed_vlans=None, default_vlan=None)[source]

Reset a port configuration on a switch.

Parameters:
  • switch_id – Identifier for the switch.

  • port_name – Name of the port on the switch.

  • native_vlan – VLAN ID to be removed from the port.

  • allowed_vlans – List of allowed VLAN IDs to be removed(optional).

  • default_vlan – VLAN ID to restore onto the port(optional).

Raises:

ValueError on parameter validation errors.

Raises:

SwitchNotFound if the specified switch does not exist.

Raises:

SwitchDriverException on configuration failures.

property supported

Return whether this driver is supported.

abstract update_lag(switch_ids, lag_name, description, mode, native_vlan, aggregation_mode, allowed_vlans=None, default_vlan=None)[source]

Update LAG configuration across switches.

Parameters:
  • switch_ids – List of switch identifiers.

  • lag_name – Name of the LAG.

  • description – Description for the LAG.

  • mode – switchport mode (‘access’ or ‘trunk’).

  • native_vlan – VLAN ID to be set for the LAG.

  • aggregation_mode – Aggregation mode (e.g., ‘lacp’, ‘static’).

  • allowed_vlans – List of allowed VLAN IDs to be added (optional).

  • default_vlan – VLAN ID to removed from the port(optional).

Raises:

ValueError on parameter validation errors.

Raises:

SwitchNotFound if the specified switch does not exist.

Raises:

SwitchDriverException on configuration failures.

abstract update_port(switch_id, port_name, description, mode, native_vlan, allowed_vlans=None, default_vlan=None, lag_name=None)[source]

Update a port configuration on a switch.

Parameters:
  • switch_id – Identifier for the switch.

  • port_name – Name of the port on the switch.

  • description – Description to set for the port.

  • mode – Port mode (‘access’, ‘trunk’, or ‘hybrid’).

  • native_vlan – VLAN ID to be set on the port.

  • allowed_vlans – List of allowed VLAN IDs to be added(optional).

  • default_vlan – VLAN ID to removed from the port(optional).

  • lag_name – LAG name if port is part of a channel.

Raises:

ValueError on parameter validation errors.

Raises:

SwitchNotFound if the specified switch does not exist.

Raises:

SwitchDriverException on configuration failures.

exception ironic.drivers.modules.switch.base.SwitchDriverException(message=None, **kwargs)[source]

Bases: IronicException

exception ironic.drivers.modules.switch.base.SwitchMethodNotImplemented(message=None, **kwargs)[source]

Bases: SwitchDriverException

exception ironic.drivers.modules.switch.base.SwitchNotFound(message=None, **kwargs)[source]

Bases: SwitchDriverException