Files
Tobias Waldekranz fb394db981 test: lag_*: Ensure that links making up a LAG are compatible
Do not allow the topology matcher to setup a LAG where one link is
running at 10G while the other one runs at 1G, since the bond will
never use the 1G port as long as there the 10G link is up.
2025-02-12 23:22:10 +01:00

27 lines
828 B
Python

from . import topology
def edge_mappings(les, pes):
"""Specialized topology edge mapper for LAG tests
In addition to the standard provides/requires validation, ensure
that for all logical ports marked with a "lag" attribute, the
corresponding physical ports are all of the same link type
(e.g. "link-10gbase-r").
"""
def links_compatible(candidate):
seen = None
for (le, pe) in candidate:
if le.get("lag"):
link = set(filter(lambda f: f.startswith("link-"), pe["provides"]))
if seen is None:
seen = link
elif link != seen:
return False
return True
for candidate in topology.edge_mappings(les, pes):
if links_compatible(candidate):
yield candidate