controller: allow markers and packet filters on Ethernet switch links

The brctl Ethernet switch runs a per-port uBridge relay, so it can host
the mark filter and packet filters like any uBridge-backed node. Add
ethernet_switch to _MARKER_CAPABLE_TYPES and _get_filter_node, narrow the
UDPLink.update() NIO-PUT skip down to the Dynamips-hosted ethernet_hub,
and expose the matching compute endpoints: PUT nio (filter/marker
reapply) plus the per-marker toggle/pause/resume/delete/rebuild routes.

The ethernet_hub keeps its exclusion: its routes still wire into the
Dynamips hub, which has no uBridge of its own.
This commit is contained in:
YueGuobin committed 2026-08-21 21:41:51 +08:00
1 parent 210103058f
commit 72dc10a669
9 files changed
+282 -17

No files matched your search

+49
View File
@@ -451,6 +451,55 @@ async def test_update(project):
}, timeout=120)
@pytest.mark.asyncio
async def test_update_ethernet_switch_nio(project):
"""
Link updates must reach an Ethernet switch endpoint: the brctl switch has
a PUT NIO route, so only the Dynamips-hosted hub side stays skipped.
"""
compute1 = MagicMock()
node_vpcs = Node(project, compute1, "node1", node_type="vpcs")
node_vpcs._ports = [EthernetPort("E0", 0, 0, 4)]
node_switch = Node(project, compute1, "node2", node_type="ethernet_switch")
node_switch._ports = [EthernetPort("E0", 0, 3, 1)]
async def subnet_callback(compute2):
return ("192.168.1.1", "192.168.1.2")
compute1.get_ip_on_same_subnet.side_effect = subnet_callback
async def compute1_callback(path, data={}, **kwargs):
if "/ports/udp" in path:
response = MagicMock()
response.json = {"udp_port": 1024}
return response
compute1.post.side_effect = compute1_callback
compute1.put = AsyncioMagicMock()
compute1.host = "example.com"
link = UDPLink(project)
await link.add_node(node_vpcs, 0, 4)
await link.add_node(node_switch, 3, 1)
assert link.created
await link.update_filters({"delay": [10, 0]})
compute1.put.assert_any_call(
"/projects/{}/ethernet_switch/nodes/{}/adapters/3/ports/1/nio".format(project.id, node_switch.id),
data={
"lport": 1024,
"rhost": "192.168.1.1",
"rport": 1024,
"type": "nio_udp",
"suspend": False,
"markers": {},
"filters": {}
}, timeout=221
)
@pytest.mark.asyncio
async def test_update_suspend(project):
compute1 = MagicMock()