test/infamy: add edge type to logical topology (mgmt port selection)

This commit is contained in:
Ahmed Karic
2023-08-16 13:51:00 +02:00
committed by Tobias Waldekranz
parent 769338515a
commit fc7d212696
5 changed files with 32 additions and 17 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ generate_dot()
hostports="<qtap0> qtap0"
targetports="<e0> e0"
edges="host:qtap0 -- target:e0;"
edges="host:qtap0 -- target:e0 [kind=mgmt];"
for tap in $(seq 1 $(($CONFIG_QEMU_NET_TAP_N - 1))); do
hostports="$hostports | <qtap$tap> qtap$tap "
targetports="$targetports | <e$tap> e$tap "
+1 -1
View File
@@ -19,5 +19,5 @@ graph "1x1" {
kind="infix",
];
host:tgt -- target:mgmt
host:tgt -- target:mgmt [kind=mgmt]
}
+1 -1
View File
@@ -19,6 +19,6 @@ graph "1x2" {
kind="infix",
];
host:tgt -- target:mgmt
host:tgt -- target:mgmt [kind=mgmt]
host:data -- target:data
}
+19 -7
View File
@@ -6,15 +6,28 @@ def qstrip(text):
return text[1:-1]
return text
def match_kind(n1attrs, n2attrs):
def match_node(n1attrs, n2attrs):
return n1attrs.get("kind") == n2attrs.get("kind")
def match_edge(e1attrs, e2attrs):
if "kind" in e1attrs or "kind" in e2attrs:
return e1attrs.get("kind") == e2attrs.get("kind")
return True
class Topology:
def __init__(self, dotg):
self.dotg = dotg
edges = { tuple(e.get_source().split(":")): { tuple(e.get_destination().split(":")): { "weight": 1 } } \
for e in self.dotg.get_edges() \
}
edges = {}
for e in self.dotg.get_edges():
attrs = e.get_attributes()
if "weight" not in attrs:
attrs["weight"] = 1
edges[tuple(e.get_source().split(":"))] = { tuple(e.get_destination().split(":")): attrs }
self.g = nx.Graph(edges, weight=1)
for e in list(self.g.edges):
s, d = e
@@ -39,7 +52,7 @@ class Topology:
self.g.add_node(dn, kind=dk)
self.g.add_edge(dn, d, weight=0)
def map_to(self, phy, node_match=match_kind):
def map_to(self, phy):
def _map_node(lnode, pnode):
if lnode in self.mapping:
assert(self.mapping[lnode][None] == pnode)
@@ -55,7 +68,7 @@ class Topology:
else:
self.mapping[lnode][lport] = pport
nxmap = isomorphism.GraphMatcher(phy.g, self.g, node_match=node_match)
nxmap = isomorphism.GraphMatcher(phy.g, self.g, edge_match=match_edge, node_match=match_node)
if not nxmap.subgraph_is_isomorphic():
return False
@@ -136,7 +149,6 @@ if __name__ == "__main__":
log = Topology(pydot.graph_from_dot_file(sys.argv[2])[0])
if log.map_to(phy):
print(json.dumps(log.mapping))
print(json.dumps(tuple(log.get_paths("host", "target"))))
sys.exit(0)
print("{}")
+10 -7
View File
@@ -11,28 +11,31 @@ graph "dual" {
qn_append="quiet";
host [
label="host | { <d1a> d1a | <d1b> d1b | <d2a> d2a | <d2b> d2b }",
label="host | { <d1a> d1a | <d1b> d1b | <d1c> d1c | <d2a> d2a | <d2b> d2b | <d2c> d2c }",
color="grey",fontcolor="grey",pos="0,15!",
kind="controller",
];
dut1 [
label="{ <eth0> eth0 | <eth1> eth1 } | dut1 | { <eth2> eth2 | <eth3> eth3 }",
label="{ <eth0> eth0 | <eth1> eth1 | <eth2> eth2 } | dut1 | { <eth3> eth3 | <eth4> eth4 | <eth5> eth5 }",
pos="10,18!",
kind="infix",
];
dut2 [
label="{ <eth0> eth0 | <eth1> eth1 } | dut2 | { <eth2> eth2 | <eth3> eth3 }",
label="{ <eth0> eth0 | <eth1> eth1 | <eth2> eth2 } | dut2 | { <eth3> eth3 | <eth4> eth4 | <eth5> eth5 }",
pos="10,12!",
kind="infix",
];
host:d1a -- dut1:eth0
host:d1a -- dut1:eth0 [kind=mgmt]
host:d1b -- dut1:eth1
host:d1c -- dut1:eth2
host:d2a -- dut2:eth0
host:d2a -- dut2:eth0 [kind=mgmt]
host:d2b -- dut2:eth1
host:d2c -- dut2:eth2
dut1:eth2 -- dut2:eth3
dut2:eth2 -- dut1:eth3
dut1:eth3 -- dut2:eth5
dut1:eth4 -- dut2:eth4
dut1:eth5 -- dut2:eth3
}