switch¶
FABRIC P4 programmable switch abstraction.
This module provides the Switch class for working with P4-programmable network switches in FABRIC. Switches extend the Node class with specialized functionality for programmable data planes.
- class fabrictestbed_extensions.fablib.switch.Switch(slice, node, validate=False, raise_exception=False)[source]¶
Switch constructor, usually invoked by
Slice.add_switch().- Parameters:
- delete()[source]¶
Remove the switch from the slice. All components and interfaces associated with the Node are removed from the Slice.
- generate_template_context(skip=None)[source]¶
Generate the base template context for this switch.
Creates a dictionary context suitable for Jinja2 template rendering, excluding the SSH command and setting an empty components list.
- get_fim()[source]¶
Not recommended for most users.
Gets the node’s FABRIC Information Model (fim) object. This method is used to access data at a lower level than FABlib.
- Returns:
the FABRIC model node
- Return type:
FIMNode
- get_interface(name=None, refresh=False, raise_exception=None)[source]¶
Gets a specific interface by name.
- Parameters:
- Returns:
the interface or None
- Return type:
Optional[Interface]
- Raises:
ResourceNotFoundError – if the interface is not found and raising is enabled
- get_interfaces(include_subs=True, refresh=False, output='list')[source]¶
Gets a list of the interfaces associated with the FABRIC node.
Results are cached. Use refresh=True to force reload.
- static get_node(slice=None, node=None)[source]¶
Returns a new fablib node using existing FABRIC resources.
- static get_pretty_name_dict()[source]¶
Get a mapping of field names to human-readable labels for display.
Returns a dictionary that maps internal field names to user-friendly display names used when rendering tables and formatted output.
- Returns:
Dictionary mapping field names to pretty names
- Return type:
- static new_switch(slice=None, name=None, site=None, avoid=None, validate=False, raise_exception=False)[source]¶
Creates a new FABRIC switch on the slice.
Not intended for API use. Use slice.add_switch() instead.
- Parameters:
slice (Slice) – the fablib slice to build the new switch on
name (str) – the name of the new switch
site (str) – the name of the site to build the switch on
avoid (List[str]) – a list of site names to avoid
validate (bool) – Validate switch can be allocated w.r.t available resources
raise_exception (bool) – Raise exception if validation fails
- Returns:
a new Switch
- Return type:
- class fabrictestbed_extensions.fablib.switch.Switch(slice, node, validate=False, raise_exception=False)[source]
Switch constructor, usually invoked by
Slice.add_switch().- Parameters:
- __str__()[source]
Creates a tabulated string describing the properties of the node.
Intended for printing node information.
- Returns:
Tabulated string of node information
- Return type:
String
- delete()[source]
Remove the switch from the slice. All components and interfaces associated with the Node are removed from the Slice.
- generate_template_context(skip=None)[source]
Generate the base template context for this switch.
Creates a dictionary context suitable for Jinja2 template rendering, excluding the SSH command and setting an empty components list.
- get_fim()[source]
Not recommended for most users.
Gets the node’s FABRIC Information Model (fim) object. This method is used to access data at a lower level than FABlib.
- Returns:
the FABRIC model node
- Return type:
FIMNode
- get_interface(name=None, refresh=False, raise_exception=None)[source]
Gets a specific interface by name.
- Parameters:
- Returns:
the interface or None
- Return type:
Optional[Interface]
- Raises:
ResourceNotFoundError – if the interface is not found and raising is enabled
- get_interfaces(include_subs=True, refresh=False, output='list')[source]
Gets a list of the interfaces associated with the FABRIC node.
Results are cached. Use refresh=True to force reload.
- static get_node(slice=None, node=None)[source]
Returns a new fablib node using existing FABRIC resources.
- static get_pretty_name_dict()[source]
Get a mapping of field names to human-readable labels for display.
Returns a dictionary that maps internal field names to user-friendly display names used when rendering tables and formatted output.
- Returns:
Dictionary mapping field names to pretty names
- Return type:
- static get_switch(slice, node)[source]
Factory method to create a Switch from a FIM node.
- static new_switch(slice=None, name=None, site=None, avoid=None, validate=False, raise_exception=False)[source]
Creates a new FABRIC switch on the slice.
Not intended for API use. Use slice.add_switch() instead.
- Parameters:
slice (Slice) – the fablib slice to build the new switch on
name (str) – the name of the new switch
site (str) – the name of the site to build the switch on
avoid (List[str]) – a list of site names to avoid
validate (bool) – Validate switch can be allocated w.r.t available resources
raise_exception (bool) – Raise exception if validation fails
- Returns:
a new Switch
- Return type:
- toDict(skip=None)[source]
Returns the node attributes as a dictionary.
Results are cached. Cache is invalidated when
_invalidate_cache()is called.
- update(fim_node=None)[source]
Update the switch with new FIM data.
- Parameters:
fim_node (FimNode) – The new FIM node data