ironic.drivers.modules.network.switchport_config module

SwitchPortConfig - parsed representation of switchport configuration.

This module provides a dataclass for representing and parsing the switchport configuration format used by the Ironic Networking interface:

{access|trunk|hybrid}/native_vlan=VLAN_ID[/allowed_vlans=V1,V2,Vn-Vm,…] [/mtu=MTU]

class ironic.drivers.modules.network.switchport_config.SwitchPortConfig(mode, native_vlan=None, allowed_vlans=None, mtu=None)[source]

Bases: object

Parsed representation of a switchport configuration value.

Instances can be created from a configuration string via from_string() or from a switchport dict via from_switchport().

allowed_vlans = None
classmethod from_string(value, network_type='unknown')[source]

Parse a network config string into a SwitchPortConfig.

Parameters:
  • value – String in format {access|trunk|hybrid}/native_vlan=N [/allowed_vlans=V1,V2,Vn-Vm][/mtu=MTU]

  • network_type – Network type label used in error messages.

Returns:

A SwitchPortConfig instance.

Raises:

InvalidParameterValue if the format is invalid.

classmethod from_switchport(switchport)[source]

Create a SwitchPortConfig from a switchport configuration dict.

Parameters:

switchport – A dict with optional keys mode, native_vlan, allowed_vlans, and mtu.

Returns:

A SwitchPortConfig instance, or None if the dict does not contain a mode key.

Raises:

InvalidParameterValue if mode is not a valid mode or native_vlan is not an integer.

property is_valid

True if the config has the required fields for its mode.

For access mode, native_vlan must be set. For trunk or hybrid mode, allowed_vlans must be set.

mode
mtu = None
native_vlan = None