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,…]
- class ironic.drivers.modules.network.switchport_config.SwitchPortConfig(mode: str, native_vlan: int | None = None, allowed_vlans: list | None = None)[source]¶
Bases:
objectParsed representation of a switchport configuration value.
Instances can be created from a configuration string via
from_string()or from a switchport dict viafrom_switchport().- allowed_vlans: list | None = 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]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, andallowed_vlans.- Returns:
A SwitchPortConfig instance, or None if the dict does not contain a
modekey.- Raises:
InvalidParameterValue if
modeis not a valid mode ornative_vlanis not an integer.
- property is_valid¶
True if the config has the required fields for its mode.
For
accessmode,native_vlanmust be set. Fortrunkorhybridmode,allowed_vlansmust be set.
- mode: str¶
- native_vlan: int | None = None¶