From d25518c7b6586339cfe034fd5700e4212213f60d Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Thu, 5 Dec 2024 13:59:42 -0600 Subject: [PATCH 01/19] * Support VLAN lists and groups too --- netsim/extra/repeater/defaults.yml | 9 + netsim/extra/repeater/plugin.py | 75 ++ tests/topology/expected/repeater-plugin.yml | 1023 +++++++++++++++++++ tests/topology/input/repeater-plugin.yml | 28 + 4 files changed, 1135 insertions(+) create mode 100644 netsim/extra/repeater/defaults.yml create mode 100644 netsim/extra/repeater/plugin.py create mode 100644 tests/topology/expected/repeater-plugin.yml create mode 100644 tests/topology/input/repeater-plugin.yml diff --git a/netsim/extra/repeater/defaults.yml b/netsim/extra/repeater/defaults.yml new file mode 100644 index 000000000..da25e9296 --- /dev/null +++ b/netsim/extra/repeater/defaults.yml @@ -0,0 +1,9 @@ +# repeater plugin attributes and defaults +# +--- +attributes: + node: + repeat: int # Create N copies of this node anywhere it's used in groups or links + +repeater: + node_name_pattern: "{name}-{id}" \ No newline at end of file diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py new file mode 100644 index 000000000..28370d771 --- /dev/null +++ b/netsim/extra/repeater/plugin.py @@ -0,0 +1,75 @@ +import typing +from box import Box +from netsim import api,data +from netsim.utils import log,strings +from netsim.augment import links + +def clone_interfaces( link_data: Box, nodename: str, clones: list ) -> list: + + """ + update_ifindex - update any custom ifindex on the given interface + """ + def update_ifindex(intf:Box,c:int) -> Box: + ifindex = intf.get('ifindex',None) + if ifindex is not None: + intf.ifindex = ifindex + c + 1 + return intf + + ifs = [] + if nodename in [ i.node for i in link_data.interfaces ]: + link_data.pop('_linkname',None) + for c,clone in enumerate(clones): + l = data.get_box(link_data) + l.interfaces = [ { 'node': clone } ] + [ update_ifindex(i,c) for i in link_data.interfaces if i.node!=nodename ] + ifs.append(l) + return ifs + +def update_vlan_access_links(topology: Box, nodename: str, clones: list) -> None: + for vname,vdata in topology.vlans.items(): # Iterate over global VLANs + if not isinstance(vdata,Box): # VLAN not yet a dictionary? + continue # ... no problem, skip it + if not 'links' in vdata: # No VLAN links? + continue # ... no problem, move on + + for cnt,l in enumerate(vdata.links): # So far so good, now iterate over the links + link_data = links.adjust_link_object( # Create link data from link definition + l=l, + linkname=f'vlans.{vname}.links[{cnt+1}]', + nodes=topology.nodes) + if link_data is not None: + ifs = clone_interfaces(link_data,nodename,clones) + vdata.links += ifs + +def repeat_node( node: Box, topology: Box ) -> None: + count = node.pop('repeat',None) + clones = [] + for c in range(2,count+2): # Existing node is '1' + clone = data.get_box(node) + clone.name = strings.eval_format(topology.defaults.repeater.node_name_pattern, node + { 'id': c } ) + clone.interfaces = [] # Start clean, remove reference to original node + if 'id' in node: + clone.id = node.id + c # Update any explicit node ID sequentially + topology.nodes += { clone.name: clone } + clones.append( clone.name ) + + for link in list(topology.get('links',[])): + link_data = links.adjust_link_object(link,f'repeater{c}',topology.nodes) + if 'lag' in link_data: + log.error("LAG links not yet supported by repeater plugin, ignoring...", + category=Warning, module='repeater') + continue + ifs = clone_interfaces(link_data,node.name,clones) + topology.links += ifs + + if 'groups' in topology: + for group in topology.groups.values(): + if node.name in group.members: + group.members.extend( clones ) + + if 'vlans' in topology: + update_vlan_access_links(topology,node.name,clones) + +def topology_expand(topology: Box) -> None: + for node in list(topology.nodes.values()): + if 'repeat' in node: + repeat_node( node, topology ) diff --git a/tests/topology/expected/repeater-plugin.yml b/tests/topology/expected/repeater-plugin.yml new file mode 100644 index 000000000..dda20c43e --- /dev/null +++ b/tests/topology/expected/repeater-plugin.yml @@ -0,0 +1,1023 @@ +groups: + hosts: + members: + - h + - h-2 + - h-3 + - h-4 +input: +- topology/input/repeater-plugin.yml +- package:topology-defaults.yml +lag: + lacp: fast + lacp_mode: active + mode: 802.3ad +links: +- _linkname: links[1] + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.2/30 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.1/30 + node: h + linkindex: 1 + node_count: 2 + prefix: + ipv4: 10.1.0.0/30 + type: p2p +- _linkname: links[2] + interfaces: + - ifindex: 20 + ifname: eth20 + ipv4: 10.1.0.6/30 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.5/30 + node: h + linkindex: 2 + node_count: 2 + prefix: + ipv4: 10.1.0.4/30 + type: p2p +- _linkname: links[3] + bridge: input_3 + interfaces: + - ifindex: 30000 + ifname: bond1 + ipv4: 10.1.0.9/30 + node: r + - ifindex: 30000 + ifname: bond1 + ipv4: 10.1.0.10/30 + node: h + lag: + ifindex: 1 + linkindex: 3 + node_count: 2 + prefix: + ipv4: 10.1.0.8/30 + type: lag +- _linkname: links[4] + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.13/30 + node: h-2 + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.14/30 + node: r + linkindex: 4 + node_count: 2 + prefix: + ipv4: 10.1.0.12/30 + type: p2p +- _linkname: links[5] + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.17/30 + node: h-3 + - ifindex: 3 + ifname: eth3 + ipv4: 10.1.0.18/30 + node: r + linkindex: 5 + node_count: 2 + prefix: + ipv4: 10.1.0.16/30 + type: p2p +- _linkname: links[6] + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.21/30 + node: h-4 + - ifindex: 4 + ifname: eth4 + ipv4: 10.1.0.22/30 + node: r + linkindex: 6 + node_count: 2 + prefix: + ipv4: 10.1.0.20/30 + type: p2p +- _linkname: links[7] + interfaces: + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.25/30 + node: h-2 + - ifindex: 21 + ifname: eth21 + ipv4: 10.1.0.26/30 + node: r + linkindex: 7 + node_count: 2 + prefix: + ipv4: 10.1.0.24/30 + type: p2p +- _linkname: links[8] + interfaces: + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.29/30 + node: h-3 + - ifindex: 23 + ifname: eth23 + ipv4: 10.1.0.30/30 + node: r + linkindex: 8 + node_count: 2 + prefix: + ipv4: 10.1.0.28/30 + type: p2p +- _linkname: links[9] + interfaces: + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.33/30 + node: h-4 + - ifindex: 26 + ifname: eth26 + ipv4: 10.1.0.34/30 + node: r + linkindex: 9 + node_count: 2 + prefix: + ipv4: 10.1.0.32/30 + type: p2p +- _linkname: links[3].lag[1] + interfaces: + - ifindex: 5 + ifname: eth5 + node: r + - ifindex: 3 + ifname: eth3 + node: h + lag: + _parentindex: 3 + linkindex: 10 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[3].lag[2] + interfaces: + - ifindex: 6 + ifname: eth6 + node: r + - ifindex: 4 + ifname: eth4 + node: h + lag: + _parentindex: 3 + linkindex: 11 + node_count: 2 + prefix: false + type: p2p +- _linkname: vlans.red.links[1] + bridge: input_12 + interfaces: + - _vlan_mode: irb + ifindex: 7 + ifname: eth7 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - _vlan_mode: irb + ifindex: 5 + ifname: eth5 + ipv4: 172.16.0.2/24 + node: h + vlan: + access: red + linkindex: 12 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[2] + bridge: input_13 + interfaces: + - _vlan_mode: irb + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.3/24 + node: h-2 + vlan: + access: red + - _vlan_mode: irb + ifindex: 8 + ifname: eth8 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + linkindex: 13 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[3] + bridge: input_14 + interfaces: + - _vlan_mode: irb + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.4/24 + node: h-3 + vlan: + access: red + - _vlan_mode: irb + ifindex: 9 + ifname: eth9 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + linkindex: 14 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[4] + bridge: input_15 + interfaces: + - _vlan_mode: irb + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.5/24 + node: h-4 + vlan: + access: red + - _vlan_mode: irb + ifindex: 10 + ifname: eth10 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + linkindex: 15 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +module: +- lag +- vlan +name: input +nodes: + h: + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 2 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.1/30 + linkindex: 1 + name: h -> r + neighbors: + - ifname: eth1 + ipv4: 10.1.0.2/30 + node: r + type: p2p + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.5/30 + linkindex: 2 + name: h -> r + neighbors: + - ifname: eth20 + ipv4: 10.1.0.6/30 + node: r + type: p2p + - ifindex: 30000 + ifname: bond1 + ipv4: 10.1.0.10/30 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: h -> r + neighbors: + - ifname: bond1 + ipv4: 10.1.0.9/30 + node: r + type: lag + virtual_interface: true + - ifindex: 3 + ifname: eth3 + lag: + _parentindex: 3 + linkindex: 10 + name: h -> r + neighbors: + - ifname: eth5 + node: r + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 3 + linkindex: 11 + name: h -> r + neighbors: + - ifname: eth6 + node: r + type: p2p + - bridge: input_12 + ifindex: 5 + ifname: eth5 + linkindex: 12 + name: '[Access VLAN red] h -> r' + neighbors: + - ifname: eth7 + ipv4: 172.16.0.1/24 + node: r + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 6 + ifname: vlan1000 + ipv4: 172.16.0.2/24 + name: VLAN red (1000) -> [r,h-2,h-3,h-4] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-2 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-3 + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h-4 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.2/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.102 + mac: 08:4f:a9:00:00:02 + module: + - lag + - vlan + name: h + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + h-2: + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 3 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.13/30 + linkindex: 4 + name: h-2 -> r + neighbors: + - ifname: eth2 + ipv4: 10.1.0.14/30 + node: r + type: p2p + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.25/30 + linkindex: 7 + name: h-2 -> r + neighbors: + - ifname: eth21 + ipv4: 10.1.0.26/30 + node: r + type: p2p + - bridge: input_13 + ifindex: 3 + ifname: eth3 + linkindex: 13 + name: '[Access VLAN red] h-2 -> r' + neighbors: + - ifname: eth8 + ipv4: 172.16.0.1/24 + node: r + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 4 + ifname: vlan1000 + ipv4: 172.16.0.3/24 + name: VLAN red (1000) -> [h,r,h-3,h-4] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-3 + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h-4 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.3/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.103 + mac: 08:4f:a9:00:00:03 + module: + - lag + - vlan + name: h-2 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + h-3: + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 4 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.17/30 + linkindex: 5 + name: h-3 -> r + neighbors: + - ifname: eth3 + ipv4: 10.1.0.18/30 + node: r + type: p2p + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.29/30 + linkindex: 8 + name: h-3 -> r + neighbors: + - ifname: eth23 + ipv4: 10.1.0.30/30 + node: r + type: p2p + - bridge: input_14 + ifindex: 3 + ifname: eth3 + linkindex: 14 + name: '[Access VLAN red] h-3 -> r' + neighbors: + - ifname: eth9 + ipv4: 172.16.0.1/24 + node: r + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 4 + ifname: vlan1000 + ipv4: 172.16.0.4/24 + name: VLAN red (1000) -> [h,r,h-2,h-4] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-2 + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h-4 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.4/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.104 + mac: 08:4f:a9:00:00:04 + module: + - lag + - vlan + name: h-3 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + h-4: + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 5 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.21/30 + linkindex: 6 + name: h-4 -> r + neighbors: + - ifname: eth4 + ipv4: 10.1.0.22/30 + node: r + type: p2p + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.33/30 + linkindex: 9 + name: h-4 -> r + neighbors: + - ifname: eth26 + ipv4: 10.1.0.34/30 + node: r + type: p2p + - bridge: input_15 + ifindex: 3 + ifname: eth3 + linkindex: 15 + name: '[Access VLAN red] h-4 -> r' + neighbors: + - ifname: eth10 + ipv4: 172.16.0.1/24 + node: r + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 4 + ifname: vlan1000 + ipv4: 172.16.0.5/24 + name: VLAN red (1000) -> [h,r,h-2,h-3] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-2 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-3 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.5/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.105 + mac: 08:4f:a9:00:00:05 + module: + - lag + - vlan + name: h-4 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + r: + _set_ifindex: true + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 1 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.2/30 + linkindex: 1 + name: r -> h + neighbors: + - ifname: eth1 + ipv4: 10.1.0.1/30 + node: h + type: p2p + - ifindex: 2 + ifname: eth2 + ipv4: 10.1.0.14/30 + linkindex: 4 + name: r -> h-2 + neighbors: + - ifname: eth1 + ipv4: 10.1.0.13/30 + node: h-2 + type: p2p + - ifindex: 3 + ifname: eth3 + ipv4: 10.1.0.18/30 + linkindex: 5 + name: r -> h-3 + neighbors: + - ifname: eth1 + ipv4: 10.1.0.17/30 + node: h-3 + type: p2p + - ifindex: 4 + ifname: eth4 + ipv4: 10.1.0.22/30 + linkindex: 6 + name: r -> h-4 + neighbors: + - ifname: eth1 + ipv4: 10.1.0.21/30 + node: h-4 + type: p2p + - ifindex: 5 + ifname: eth5 + lag: + _parentindex: 3 + linkindex: 10 + name: r -> h + neighbors: + - ifname: eth3 + node: h + type: p2p + - ifindex: 6 + ifname: eth6 + lag: + _parentindex: 3 + linkindex: 11 + name: r -> h + neighbors: + - ifname: eth4 + node: h + type: p2p + - bridge: input_12 + ifindex: 7 + ifname: eth7 + linkindex: 12 + name: '[Access VLAN red] r -> h' + neighbors: + - ifname: eth5 + ipv4: 172.16.0.2/24 + node: h + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_13 + ifindex: 8 + ifname: eth8 + linkindex: 13 + name: '[Access VLAN red] r -> h-2' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.3/24 + node: h-2 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_14 + ifindex: 9 + ifname: eth9 + linkindex: 14 + name: '[Access VLAN red] r -> h-3' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.4/24 + node: h-3 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_15 + ifindex: 10 + ifname: eth10 + linkindex: 15 + name: '[Access VLAN red] r -> h-4' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.5/24 + node: h-4 + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 11 + ifname: vlan1000 + ipv4: 172.16.0.1/24 + name: VLAN red (1000) -> [h,h-2,h-3,h-4] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-2 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-3 + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h-4 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + - ifindex: 12 + ifname: eth12 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 13 + ifname: eth13 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 14 + ifname: eth14 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 15 + ifname: eth15 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 16 + ifname: eth16 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 17 + ifname: eth17 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 18 + ifname: eth18 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 19 + ifname: eth19 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 20 + ifname: eth20 + ipv4: 10.1.0.6/30 + linkindex: 2 + name: r -> h + neighbors: + - ifname: eth2 + ipv4: 10.1.0.5/30 + node: h + type: p2p + - ifindex: 21 + ifname: eth21 + ipv4: 10.1.0.26/30 + linkindex: 7 + name: r -> h-2 + neighbors: + - ifname: eth2 + ipv4: 10.1.0.25/30 + node: h-2 + type: p2p + - ifindex: 22 + ifname: eth22 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 23 + ifname: eth23 + ipv4: 10.1.0.30/30 + linkindex: 8 + name: r -> h-3 + neighbors: + - ifname: eth2 + ipv4: 10.1.0.29/30 + node: h-3 + type: p2p + - ifindex: 24 + ifname: eth24 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 25 + ifname: eth25 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 26 + ifname: eth26 + ipv4: 10.1.0.34/30 + linkindex: 9 + name: r -> h-4 + neighbors: + - ifname: eth2 + ipv4: 10.1.0.33/30 + node: h-4 + type: p2p + - ifindex: 30000 + ifname: bond1 + ipv4: 10.1.0.9/30 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: r -> h + neighbors: + - ifname: bond1 + ipv4: 10.1.0.10/30 + node: h + type: lag + virtual_interface: true + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + libvirt: + nic_adapter_count: 27 + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.1/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.101 + mac: 08:4f:a9:00:00:01 + module: + - lag + - vlan + name: r + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 +plugin: +- repeater +provider: libvirt +vlans: + red: + host_count: 0 + id: 1000 + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-2 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-3 + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h-4 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/repeater-plugin.yml b/tests/topology/input/repeater-plugin.yml new file mode 100644 index 000000000..c6d2087b1 --- /dev/null +++ b/tests/topology/input/repeater-plugin.yml @@ -0,0 +1,28 @@ +--- +plugin: [ repeater ] + +module: [lag,vlan] + +vlans: + red: + links: [r-h] # VLAN links get updated + +groups: + hosts: + members: [h] # Gets updated with cloned nodes + +nodes: + r: + device: frr + + h: + device: frr + repeat: 3 # Create 3 copies -> 4 hosts total + +links: +- r-h # Plugin supports different styles of specifying links, all normalized +- r: + ifindex: 20 # Custom port on router -> gets incremented + h: + +- lag.members: [ r-h, r-h ] # TODO lags need special work, not supported yet -> plugin issues a warning and doesn't modify them \ No newline at end of file From 0feee577fd37495d49f351deed734f5ebd5abe9c Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Thu, 5 Dec 2024 14:09:24 -0600 Subject: [PATCH 02/19] Fix typing --- netsim/extra/repeater/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py index 28370d771..dcd74a2e4 100644 --- a/netsim/extra/repeater/plugin.py +++ b/netsim/extra/repeater/plugin.py @@ -4,8 +4,7 @@ from netsim.utils import log,strings from netsim.augment import links -def clone_interfaces( link_data: Box, nodename: str, clones: list ) -> list: - +def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: """ update_ifindex - update any custom ifindex on the given interface """ @@ -53,7 +52,9 @@ def repeat_node( node: Box, topology: Box ) -> None: clones.append( clone.name ) for link in list(topology.get('links',[])): - link_data = links.adjust_link_object(link,f'repeater{c}',topology.nodes) + link_data = links.adjust_link_object(link,f'repeater{c}',topology.nodes) + if link_data is None: + continue if 'lag' in link_data: log.error("LAG links not yet supported by repeater plugin, ignoring...", category=Warning, module='repeater') From 0a0885216ed2d3c83042cb44e22cf2612ade6115 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Thu, 5 Dec 2024 14:20:51 -0600 Subject: [PATCH 03/19] Bugfix: Need to clone interface, else ifindex references previous objects --- netsim/extra/repeater/plugin.py | 14 +++++--- tests/topology/expected/repeater-plugin.yml | 39 +++++---------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py index dcd74a2e4..e300a99aa 100644 --- a/netsim/extra/repeater/plugin.py +++ b/netsim/extra/repeater/plugin.py @@ -8,9 +8,10 @@ def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[B """ update_ifindex - update any custom ifindex on the given interface """ - def update_ifindex(intf:Box,c:int) -> Box: + def update_ifindex(intf:Box, c:int) -> Box: ifindex = intf.get('ifindex',None) if ifindex is not None: + intf = data.get_box(intf) # Need to make a fresh copy intf.ifindex = ifindex + c + 1 return intf @@ -39,15 +40,18 @@ def update_vlan_access_links(topology: Box, nodename: str, clones: list) -> None ifs = clone_interfaces(link_data,nodename,clones) vdata.links += ifs -def repeat_node( node: Box, topology: Box ) -> None: +""" +repeat_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes +""" +def repeat_node(node: Box, topology: Box) -> None: count = node.pop('repeat',None) clones = [] - for c in range(2,count+2): # Existing node is '1' + for c in range(2,count+2): # Existing node is '1' clone = data.get_box(node) clone.name = strings.eval_format(topology.defaults.repeater.node_name_pattern, node + { 'id': c } ) - clone.interfaces = [] # Start clean, remove reference to original node + clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: - clone.id = node.id + c # Update any explicit node ID sequentially + clone.id = node.id + c # Update any explicit node ID sequentially topology.nodes += { clone.name: clone } clones.append( clone.name ) diff --git a/tests/topology/expected/repeater-plugin.yml b/tests/topology/expected/repeater-plugin.yml index dda20c43e..96e931dca 100644 --- a/tests/topology/expected/repeater-plugin.yml +++ b/tests/topology/expected/repeater-plugin.yml @@ -127,8 +127,8 @@ links: ifname: eth2 ipv4: 10.1.0.29/30 node: h-3 - - ifindex: 23 - ifname: eth23 + - ifindex: 22 + ifname: eth22 ipv4: 10.1.0.30/30 node: r linkindex: 8 @@ -142,8 +142,8 @@ links: ifname: eth2 ipv4: 10.1.0.33/30 node: h-4 - - ifindex: 26 - ifname: eth26 + - ifindex: 23 + ifname: eth23 ipv4: 10.1.0.34/30 node: r linkindex: 9 @@ -527,7 +527,7 @@ nodes: linkindex: 8 name: h-3 -> r neighbors: - - ifname: eth23 + - ifname: eth22 ipv4: 10.1.0.30/30 node: r type: p2p @@ -619,7 +619,7 @@ nodes: linkindex: 9 name: h-4 -> r neighbors: - - ifname: eth26 + - ifname: eth23 ipv4: 10.1.0.34/30 node: r type: p2p @@ -909,13 +909,6 @@ nodes: type: p2p - ifindex: 22 ifname: eth22 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 23 - ifname: eth23 ipv4: 10.1.0.30/30 linkindex: 8 name: r -> h-3 @@ -924,22 +917,8 @@ nodes: ipv4: 10.1.0.29/30 node: h-3 type: p2p - - ifindex: 24 - ifname: eth24 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 25 - ifname: eth25 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 26 - ifname: eth26 + - ifindex: 23 + ifname: eth23 ipv4: 10.1.0.34/30 linkindex: 9 name: r -> h-4 @@ -969,7 +948,7 @@ nodes: lacp_mode: active mode: 802.3ad libvirt: - nic_adapter_count: 27 + nic_adapter_count: 24 loopback: ifindex: 0 ifname: lo From 24bcab0baeb6029dcddd85e30e609d60542063e4 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Thu, 5 Dec 2024 14:28:04 -0600 Subject: [PATCH 04/19] Remove unused imports, add documentation --- netsim/extra/repeater/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py index e300a99aa..a128d99ae 100644 --- a/netsim/extra/repeater/plugin.py +++ b/netsim/extra/repeater/plugin.py @@ -1,6 +1,5 @@ -import typing from box import Box -from netsim import api,data +from netsim import data from netsim.utils import log,strings from netsim.augment import links @@ -74,6 +73,9 @@ def repeat_node(node: Box, topology: Box) -> None: if 'vlans' in topology: update_vlan_access_links(topology,node.name,clones) +""" +topology_expand - Main plugin function, expands the topology with cloned nodes and interfaces +""" def topology_expand(topology: Box) -> None: for node in list(topology.nodes.values()): if 'repeat' in node: From 390964ff3f864b68f22adda479f190e0f36f0607 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Thu, 5 Dec 2024 14:41:11 -0600 Subject: [PATCH 05/19] * Adjust node ID offset * Copy any interface attributes from the original node too --- netsim/extra/repeater/plugin.py | 5 +- tests/topology/expected/repeater-plugin.yml | 104 +++++++++++--------- tests/topology/input/repeater-plugin.yml | 2 + 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py index a128d99ae..1fcb07e02 100644 --- a/netsim/extra/repeater/plugin.py +++ b/netsim/extra/repeater/plugin.py @@ -17,9 +17,10 @@ def update_ifindex(intf:Box, c:int) -> Box: ifs = [] if nodename in [ i.node for i in link_data.interfaces ]: link_data.pop('_linkname',None) + atts = [ i for i in link_data.interfaces if i.node==nodename ][0] # Copy any interface atts for c,clone in enumerate(clones): l = data.get_box(link_data) - l.interfaces = [ { 'node': clone } ] + [ update_ifindex(i,c) for i in link_data.interfaces if i.node!=nodename ] + l.interfaces = [ atts+{ 'node': clone } ] + [ update_ifindex(i,c) for i in link_data.interfaces if i.node!=nodename ] ifs.append(l) return ifs @@ -50,7 +51,7 @@ def repeat_node(node: Box, topology: Box) -> None: clone.name = strings.eval_format(topology.defaults.repeater.node_name_pattern, node + { 'id': c } ) clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: - clone.id = node.id + c # Update any explicit node ID sequentially + clone.id = node.id + c - 1 # Update any explicit node ID sequentially topology.nodes += { clone.name: clone } clones.append( clone.name ) diff --git a/tests/topology/expected/repeater-plugin.yml b/tests/topology/expected/repeater-plugin.yml index 96e931dca..15b2d2185 100644 --- a/tests/topology/expected/repeater-plugin.yml +++ b/tests/topology/expected/repeater-plugin.yml @@ -37,6 +37,7 @@ links: - ifindex: 2 ifname: eth2 ipv4: 10.1.0.5/30 + mtu: 1600 node: h linkindex: 2 node_count: 2 @@ -111,6 +112,7 @@ links: - ifindex: 2 ifname: eth2 ipv4: 10.1.0.25/30 + mtu: 1600 node: h-2 - ifindex: 21 ifname: eth21 @@ -126,6 +128,7 @@ links: - ifindex: 2 ifname: eth2 ipv4: 10.1.0.29/30 + mtu: 1600 node: h-3 - ifindex: 22 ifname: eth22 @@ -141,6 +144,7 @@ links: - ifindex: 2 ifname: eth2 ipv4: 10.1.0.33/30 + mtu: 1600 node: h-4 - ifindex: 23 ifname: eth23 @@ -192,7 +196,7 @@ links: - _vlan_mode: irb ifindex: 5 ifname: eth5 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h vlan: access: red @@ -210,7 +214,7 @@ links: - _vlan_mode: irb ifindex: 3 ifname: eth3 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 vlan: access: red @@ -235,7 +239,7 @@ links: - _vlan_mode: irb ifindex: 3 ifname: eth3 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 vlan: access: red @@ -260,7 +264,7 @@ links: - _vlan_mode: irb ifindex: 3 ifname: eth3 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 vlan: access: red @@ -289,7 +293,7 @@ nodes: ipv4: true box: generic/ubuntu2004 device: frr - id: 2 + id: 10 interfaces: - ifindex: 1 ifname: eth1 @@ -305,6 +309,7 @@ nodes: ifname: eth2 ipv4: 10.1.0.5/30 linkindex: 2 + mtu: 1600 name: h -> r neighbors: - ifname: eth20 @@ -363,20 +368,20 @@ nodes: - bridge_group: 1 ifindex: 6 ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 name: VLAN red (1000) -> [r,h-2,h-3,h-4] neighbors: - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 - ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 - ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 type: svi virtual_interface: true @@ -390,14 +395,14 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.2/32 + ipv4: 10.0.0.10/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.102 - mac: 08:4f:a9:00:00:02 + ipv4: 192.168.121.110 + mac: 08:4f:a9:00:00:0a module: - lag - vlan @@ -417,7 +422,7 @@ nodes: ipv4: true box: generic/ubuntu2004 device: frr - id: 3 + id: 11 interfaces: - ifindex: 1 ifname: eth1 @@ -433,6 +438,7 @@ nodes: ifname: eth2 ipv4: 10.1.0.25/30 linkindex: 7 + mtu: 1600 name: h-2 -> r neighbors: - ifname: eth21 @@ -455,20 +461,20 @@ nodes: - bridge_group: 1 ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 name: VLAN red (1000) -> [h,r,h-3,h-4] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 - ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 type: svi virtual_interface: true @@ -482,14 +488,14 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.3/32 + ipv4: 10.0.0.11/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.103 - mac: 08:4f:a9:00:00:03 + ipv4: 192.168.121.111 + mac: 08:4f:a9:00:00:0b module: - lag - vlan @@ -509,7 +515,7 @@ nodes: ipv4: true box: generic/ubuntu2004 device: frr - id: 4 + id: 12 interfaces: - ifindex: 1 ifname: eth1 @@ -525,6 +531,7 @@ nodes: ifname: eth2 ipv4: 10.1.0.29/30 linkindex: 8 + mtu: 1600 name: h-3 -> r neighbors: - ifname: eth22 @@ -547,20 +554,20 @@ nodes: - bridge_group: 1 ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 name: VLAN red (1000) -> [h,r,h-2,h-4] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 - ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 type: svi virtual_interface: true @@ -574,14 +581,14 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.4/32 + ipv4: 10.0.0.12/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.104 - mac: 08:4f:a9:00:00:04 + ipv4: 192.168.121.112 + mac: 08:4f:a9:00:00:0c module: - lag - vlan @@ -601,7 +608,7 @@ nodes: ipv4: true box: generic/ubuntu2004 device: frr - id: 5 + id: 13 interfaces: - ifindex: 1 ifname: eth1 @@ -617,6 +624,7 @@ nodes: ifname: eth2 ipv4: 10.1.0.33/30 linkindex: 9 + mtu: 1600 name: h-4 -> r neighbors: - ifname: eth23 @@ -639,20 +647,20 @@ nodes: - bridge_group: 1 ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 name: VLAN red (1000) -> [h,r,h-2,h-3] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 - ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 type: svi virtual_interface: true @@ -666,14 +674,14 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.5/32 + ipv4: 10.0.0.13/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.105 - mac: 08:4f:a9:00:00:05 + ipv4: 192.168.121.113 + mac: 08:4f:a9:00:00:0d module: - lag - vlan @@ -763,7 +771,7 @@ nodes: name: '[Access VLAN red] r -> h' neighbors: - ifname: eth5 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h type: lan vlan: @@ -776,7 +784,7 @@ nodes: name: '[Access VLAN red] r -> h-2' neighbors: - ifname: eth3 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 type: lan vlan: @@ -789,7 +797,7 @@ nodes: name: '[Access VLAN red] r -> h-3' neighbors: - ifname: eth3 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 type: lan vlan: @@ -802,7 +810,7 @@ nodes: name: '[Access VLAN red] r -> h-4' neighbors: - ifname: eth3 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 type: lan vlan: @@ -815,16 +823,16 @@ nodes: name: VLAN red (1000) -> [h,h-2,h-3,h-4] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h - ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 - ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 - ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 type: svi virtual_interface: true @@ -983,19 +991,19 @@ vlans: id: 1000 neighbors: - ifname: vlan1000 - ipv4: 172.16.0.2/24 + ipv4: 172.16.0.10/24 node: h - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.11/24 node: h-2 - ifname: vlan1000 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.12/24 node: h-3 - ifname: vlan1000 - ipv4: 172.16.0.5/24 + ipv4: 172.16.0.13/24 node: h-4 prefix: allocation: id_based diff --git a/tests/topology/input/repeater-plugin.yml b/tests/topology/input/repeater-plugin.yml index c6d2087b1..cb4a02b64 100644 --- a/tests/topology/input/repeater-plugin.yml +++ b/tests/topology/input/repeater-plugin.yml @@ -18,11 +18,13 @@ nodes: h: device: frr repeat: 3 # Create 3 copies -> 4 hosts total + id: 10 # Starting at ID 10 links: - r-h # Plugin supports different styles of specifying links, all normalized - r: ifindex: 20 # Custom port on router -> gets incremented h: + mtu: 1600 # Interface atts get copied too - lag.members: [ r-h, r-h ] # TODO lags need special work, not supported yet -> plugin issues a warning and doesn't modify them \ No newline at end of file From ad5cfeb2886f8af9fd80c6b34138aab2e8b959ef Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Fri, 6 Dec 2024 15:25:04 -0600 Subject: [PATCH 06/19] BUGFIX: Groups may include 'bool' flags, test for that --- netsim/extra/repeater/plugin.py | 2 +- tests/topology/input/repeater-plugin.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py index 1fcb07e02..c0e672cc6 100644 --- a/netsim/extra/repeater/plugin.py +++ b/netsim/extra/repeater/plugin.py @@ -68,7 +68,7 @@ def repeat_node(node: Box, topology: Box) -> None: if 'groups' in topology: for group in topology.groups.values(): - if node.name in group.members: + if isinstance(group,Box) and node.name in group.get('members',[]): # Groups can include 'bool flags too group.members.extend( clones ) if 'vlans' in topology: diff --git a/tests/topology/input/repeater-plugin.yml b/tests/topology/input/repeater-plugin.yml index cb4a02b64..ad5cf2ed5 100644 --- a/tests/topology/input/repeater-plugin.yml +++ b/tests/topology/input/repeater-plugin.yml @@ -8,6 +8,7 @@ vlans: links: [r-h] # VLAN links get updated groups: + _auto_create: True # Test presence of bool flag hosts: members: [h] # Gets updated with cloned nodes From 094ddc711e7b42bd4870977d664115e39c920504 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Fri, 6 Dec 2024 15:33:40 -0600 Subject: [PATCH 07/19] Shorten node names to 16 characters --- netsim/extra/repeater/defaults.yml | 2 +- tests/topology/expected/repeater-plugin.yml | 408 ++++++++++---------- tests/topology/input/repeater-plugin.yml | 16 +- 3 files changed, 213 insertions(+), 213 deletions(-) diff --git a/netsim/extra/repeater/defaults.yml b/netsim/extra/repeater/defaults.yml index da25e9296..02f41b46b 100644 --- a/netsim/extra/repeater/defaults.yml +++ b/netsim/extra/repeater/defaults.yml @@ -6,4 +6,4 @@ attributes: repeat: int # Create N copies of this node anywhere it's used in groups or links repeater: - node_name_pattern: "{name}-{id}" \ No newline at end of file + node_name_pattern: "{name[:13]}-{id:02x}" \ No newline at end of file diff --git a/tests/topology/expected/repeater-plugin.yml b/tests/topology/expected/repeater-plugin.yml index 15b2d2185..62cbf1fc3 100644 --- a/tests/topology/expected/repeater-plugin.yml +++ b/tests/topology/expected/repeater-plugin.yml @@ -1,10 +1,10 @@ groups: hosts: members: - - h - - h-2 - - h-3 - - h-4 + - host_w_long_name + - host_w_long_n-02 + - host_w_long_n-03 + - host_w_long_n-04 input: - topology/input/repeater-plugin.yml - package:topology-defaults.yml @@ -22,7 +22,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 10.1.0.1/30 - node: h + node: host_w_long_name linkindex: 1 node_count: 2 prefix: @@ -38,7 +38,7 @@ links: ifname: eth2 ipv4: 10.1.0.5/30 mtu: 1600 - node: h + node: host_w_long_name linkindex: 2 node_count: 2 prefix: @@ -54,7 +54,7 @@ links: - ifindex: 30000 ifname: bond1 ipv4: 10.1.0.10/30 - node: h + node: host_w_long_name lag: ifindex: 1 linkindex: 3 @@ -67,7 +67,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 10.1.0.13/30 - node: h-2 + node: host_w_long_n-02 - ifindex: 2 ifname: eth2 ipv4: 10.1.0.14/30 @@ -82,7 +82,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 10.1.0.17/30 - node: h-3 + node: host_w_long_n-03 - ifindex: 3 ifname: eth3 ipv4: 10.1.0.18/30 @@ -97,7 +97,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 10.1.0.21/30 - node: h-4 + node: host_w_long_n-04 - ifindex: 4 ifname: eth4 ipv4: 10.1.0.22/30 @@ -113,7 +113,7 @@ links: ifname: eth2 ipv4: 10.1.0.25/30 mtu: 1600 - node: h-2 + node: host_w_long_n-02 - ifindex: 21 ifname: eth21 ipv4: 10.1.0.26/30 @@ -129,7 +129,7 @@ links: ifname: eth2 ipv4: 10.1.0.29/30 mtu: 1600 - node: h-3 + node: host_w_long_n-03 - ifindex: 22 ifname: eth22 ipv4: 10.1.0.30/30 @@ -145,7 +145,7 @@ links: ifname: eth2 ipv4: 10.1.0.33/30 mtu: 1600 - node: h-4 + node: host_w_long_n-04 - ifindex: 23 ifname: eth23 ipv4: 10.1.0.34/30 @@ -162,7 +162,7 @@ links: node: r - ifindex: 3 ifname: eth3 - node: h + node: host_w_long_name lag: _parentindex: 3 linkindex: 10 @@ -176,7 +176,7 @@ links: node: r - ifindex: 4 ifname: eth4 - node: h + node: host_w_long_name lag: _parentindex: 3 linkindex: 11 @@ -197,7 +197,7 @@ links: ifindex: 5 ifname: eth5 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name vlan: access: red linkindex: 12 @@ -215,7 +215,7 @@ links: ifindex: 3 ifname: eth3 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 vlan: access: red - _vlan_mode: irb @@ -240,7 +240,7 @@ links: ifindex: 3 ifname: eth3 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 vlan: access: red - _vlan_mode: irb @@ -265,7 +265,7 @@ links: ifindex: 3 ifname: eth3 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 vlan: access: red - _vlan_mode: irb @@ -288,77 +288,41 @@ module: - vlan name: input nodes: - h: + host_w_long_n-02: af: ipv4: true box: generic/ubuntu2004 device: frr - id: 10 + id: 11 interfaces: - ifindex: 1 ifname: eth1 - ipv4: 10.1.0.1/30 - linkindex: 1 - name: h -> r + ipv4: 10.1.0.13/30 + linkindex: 4 + name: host_w_long_n-02 -> r neighbors: - - ifname: eth1 - ipv4: 10.1.0.2/30 + - ifname: eth2 + ipv4: 10.1.0.14/30 node: r type: p2p - ifindex: 2 ifname: eth2 - ipv4: 10.1.0.5/30 - linkindex: 2 + ipv4: 10.1.0.25/30 + linkindex: 7 mtu: 1600 - name: h -> r + name: host_w_long_n-02 -> r neighbors: - - ifname: eth20 - ipv4: 10.1.0.6/30 + - ifname: eth21 + ipv4: 10.1.0.26/30 node: r type: p2p - - ifindex: 30000 - ifname: bond1 - ipv4: 10.1.0.10/30 - lag: - ifindex: 1 - lacp: fast - lacp_mode: active - mode: 802.3ad - linkindex: 3 - name: h -> r - neighbors: - - ifname: bond1 - ipv4: 10.1.0.9/30 - node: r - type: lag - virtual_interface: true - - ifindex: 3 + - bridge: input_13 + ifindex: 3 ifname: eth3 - lag: - _parentindex: 3 - linkindex: 10 - name: h -> r - neighbors: - - ifname: eth5 - node: r - type: p2p - - ifindex: 4 - ifname: eth4 - lag: - _parentindex: 3 - linkindex: 11 - name: h -> r - neighbors: - - ifname: eth6 - node: r - type: p2p - - bridge: input_12 - ifindex: 5 - ifname: eth5 - linkindex: 12 - name: '[Access VLAN red] h -> r' + linkindex: 13 + name: '[Access VLAN red] host_w_long_n-02 -> r' neighbors: - - ifname: eth7 + - ifname: eth8 ipv4: 172.16.0.1/24 node: r type: lan @@ -366,23 +330,23 @@ nodes: access: red access_id: 1000 - bridge_group: 1 - ifindex: 6 + ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.10/24 - name: VLAN red (1000) -> [r,h-2,h-3,h-4] + ipv4: 172.16.0.11/24 + name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-03,host_w_long_n-04] neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.10/24 + node: host_w_long_name - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: h-2 - ifname: vlan1000 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 - ifname: vlan1000 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 type: svi virtual_interface: true vlan: @@ -395,18 +359,18 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.10/32 + ipv4: 10.0.0.11/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.110 - mac: 08:4f:a9:00:00:0a + ipv4: 192.168.121.111 + mac: 08:4f:a9:00:00:0b module: - lag - vlan - name: h + name: host_w_long_n-02 vlan: max_bridge_group: 1 vlans: @@ -417,41 +381,41 @@ nodes: prefix: allocation: id_based ipv4: 172.16.0.0/24 - h-2: + host_w_long_n-03: af: ipv4: true box: generic/ubuntu2004 device: frr - id: 11 + id: 12 interfaces: - ifindex: 1 ifname: eth1 - ipv4: 10.1.0.13/30 - linkindex: 4 - name: h-2 -> r + ipv4: 10.1.0.17/30 + linkindex: 5 + name: host_w_long_n-03 -> r neighbors: - - ifname: eth2 - ipv4: 10.1.0.14/30 + - ifname: eth3 + ipv4: 10.1.0.18/30 node: r type: p2p - ifindex: 2 ifname: eth2 - ipv4: 10.1.0.25/30 - linkindex: 7 + ipv4: 10.1.0.29/30 + linkindex: 8 mtu: 1600 - name: h-2 -> r + name: host_w_long_n-03 -> r neighbors: - - ifname: eth21 - ipv4: 10.1.0.26/30 + - ifname: eth22 + ipv4: 10.1.0.30/30 node: r type: p2p - - bridge: input_13 + - bridge: input_14 ifindex: 3 ifname: eth3 - linkindex: 13 - name: '[Access VLAN red] h-2 -> r' + linkindex: 14 + name: '[Access VLAN red] host_w_long_n-03 -> r' neighbors: - - ifname: eth8 + - ifname: eth9 ipv4: 172.16.0.1/24 node: r type: lan @@ -461,21 +425,21 @@ nodes: - bridge_group: 1 ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.11/24 - name: VLAN red (1000) -> [h,r,h-3,h-4] + ipv4: 172.16.0.12/24 + name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-02,host_w_long_n-04] neighbors: - ifname: vlan1000 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: h-3 + ipv4: 172.16.0.11/24 + node: host_w_long_n-02 - ifname: vlan1000 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 type: svi virtual_interface: true vlan: @@ -488,18 +452,18 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.11/32 + ipv4: 10.0.0.12/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.111 - mac: 08:4f:a9:00:00:0b + ipv4: 192.168.121.112 + mac: 08:4f:a9:00:00:0c module: - lag - vlan - name: h-2 + name: host_w_long_n-03 vlan: max_bridge_group: 1 vlans: @@ -510,41 +474,41 @@ nodes: prefix: allocation: id_based ipv4: 172.16.0.0/24 - h-3: + host_w_long_n-04: af: ipv4: true box: generic/ubuntu2004 device: frr - id: 12 + id: 13 interfaces: - ifindex: 1 ifname: eth1 - ipv4: 10.1.0.17/30 - linkindex: 5 - name: h-3 -> r + ipv4: 10.1.0.21/30 + linkindex: 6 + name: host_w_long_n-04 -> r neighbors: - - ifname: eth3 - ipv4: 10.1.0.18/30 + - ifname: eth4 + ipv4: 10.1.0.22/30 node: r type: p2p - ifindex: 2 ifname: eth2 - ipv4: 10.1.0.29/30 - linkindex: 8 + ipv4: 10.1.0.33/30 + linkindex: 9 mtu: 1600 - name: h-3 -> r + name: host_w_long_n-04 -> r neighbors: - - ifname: eth22 - ipv4: 10.1.0.30/30 + - ifname: eth23 + ipv4: 10.1.0.34/30 node: r type: p2p - - bridge: input_14 + - bridge: input_15 ifindex: 3 ifname: eth3 - linkindex: 14 - name: '[Access VLAN red] h-3 -> r' + linkindex: 15 + name: '[Access VLAN red] host_w_long_n-04 -> r' neighbors: - - ifname: eth9 + - ifname: eth10 ipv4: 172.16.0.1/24 node: r type: lan @@ -554,21 +518,21 @@ nodes: - bridge_group: 1 ifindex: 4 ifname: vlan1000 - ipv4: 172.16.0.12/24 - name: VLAN red (1000) -> [h,r,h-2,h-4] + ipv4: 172.16.0.13/24 + name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-02,host_w_long_n-03] neighbors: - ifname: vlan1000 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: h-4 + ipv4: 172.16.0.12/24 + node: host_w_long_n-03 type: svi virtual_interface: true vlan: @@ -581,18 +545,18 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.12/32 + ipv4: 10.0.0.13/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.112 - mac: 08:4f:a9:00:00:0c + ipv4: 192.168.121.113 + mac: 08:4f:a9:00:00:0d module: - lag - vlan - name: h-3 + name: host_w_long_n-04 vlan: max_bridge_group: 1 vlans: @@ -603,41 +567,77 @@ nodes: prefix: allocation: id_based ipv4: 172.16.0.0/24 - h-4: + host_w_long_name: af: ipv4: true box: generic/ubuntu2004 device: frr - id: 13 + id: 10 interfaces: - ifindex: 1 ifname: eth1 - ipv4: 10.1.0.21/30 - linkindex: 6 - name: h-4 -> r + ipv4: 10.1.0.1/30 + linkindex: 1 + name: host_w_long_name -> r neighbors: - - ifname: eth4 - ipv4: 10.1.0.22/30 + - ifname: eth1 + ipv4: 10.1.0.2/30 node: r type: p2p - ifindex: 2 ifname: eth2 - ipv4: 10.1.0.33/30 - linkindex: 9 + ipv4: 10.1.0.5/30 + linkindex: 2 mtu: 1600 - name: h-4 -> r + name: host_w_long_name -> r neighbors: - - ifname: eth23 - ipv4: 10.1.0.34/30 + - ifname: eth20 + ipv4: 10.1.0.6/30 node: r type: p2p - - bridge: input_15 - ifindex: 3 + - ifindex: 30000 + ifname: bond1 + ipv4: 10.1.0.10/30 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: host_w_long_name -> r + neighbors: + - ifname: bond1 + ipv4: 10.1.0.9/30 + node: r + type: lag + virtual_interface: true + - ifindex: 3 ifname: eth3 - linkindex: 15 - name: '[Access VLAN red] h-4 -> r' + lag: + _parentindex: 3 + linkindex: 10 + name: host_w_long_name -> r neighbors: - - ifname: eth10 + - ifname: eth5 + node: r + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 3 + linkindex: 11 + name: host_w_long_name -> r + neighbors: + - ifname: eth6 + node: r + type: p2p + - bridge: input_12 + ifindex: 5 + ifname: eth5 + linkindex: 12 + name: '[Access VLAN red] host_w_long_name -> r' + neighbors: + - ifname: eth7 ipv4: 172.16.0.1/24 node: r type: lan @@ -645,23 +645,23 @@ nodes: access: red access_id: 1000 - bridge_group: 1 - ifindex: 4 + ifindex: 6 ifname: vlan1000 - ipv4: 172.16.0.13/24 - name: VLAN red (1000) -> [h,r,h-2,h-3] + ipv4: 172.16.0.10/24 + name: VLAN red (1000) -> [r,host_w_long_n-02,host_w_long_n-03,host_w_long_n-04] neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: h - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 - ifname: vlan1000 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 + - ifname: vlan1000 + ipv4: 172.16.0.13/24 + node: host_w_long_n-04 type: svi virtual_interface: true vlan: @@ -674,18 +674,18 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.13/32 + ipv4: 10.0.0.10/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.113 - mac: 08:4f:a9:00:00:0d + ipv4: 192.168.121.110 + mac: 08:4f:a9:00:00:0a module: - lag - vlan - name: h-4 + name: host_w_long_name vlan: max_bridge_group: 1 vlans: @@ -708,71 +708,71 @@ nodes: ifname: eth1 ipv4: 10.1.0.2/30 linkindex: 1 - name: r -> h + name: r -> host_w_long_name neighbors: - ifname: eth1 ipv4: 10.1.0.1/30 - node: h + node: host_w_long_name type: p2p - ifindex: 2 ifname: eth2 ipv4: 10.1.0.14/30 linkindex: 4 - name: r -> h-2 + name: r -> host_w_long_n-02 neighbors: - ifname: eth1 ipv4: 10.1.0.13/30 - node: h-2 + node: host_w_long_n-02 type: p2p - ifindex: 3 ifname: eth3 ipv4: 10.1.0.18/30 linkindex: 5 - name: r -> h-3 + name: r -> host_w_long_n-03 neighbors: - ifname: eth1 ipv4: 10.1.0.17/30 - node: h-3 + node: host_w_long_n-03 type: p2p - ifindex: 4 ifname: eth4 ipv4: 10.1.0.22/30 linkindex: 6 - name: r -> h-4 + name: r -> host_w_long_n-04 neighbors: - ifname: eth1 ipv4: 10.1.0.21/30 - node: h-4 + node: host_w_long_n-04 type: p2p - ifindex: 5 ifname: eth5 lag: _parentindex: 3 linkindex: 10 - name: r -> h + name: r -> host_w_long_name neighbors: - ifname: eth3 - node: h + node: host_w_long_name type: p2p - ifindex: 6 ifname: eth6 lag: _parentindex: 3 linkindex: 11 - name: r -> h + name: r -> host_w_long_name neighbors: - ifname: eth4 - node: h + node: host_w_long_name type: p2p - bridge: input_12 ifindex: 7 ifname: eth7 linkindex: 12 - name: '[Access VLAN red] r -> h' + name: '[Access VLAN red] r -> host_w_long_name' neighbors: - ifname: eth5 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name type: lan vlan: access: red @@ -781,11 +781,11 @@ nodes: ifindex: 8 ifname: eth8 linkindex: 13 - name: '[Access VLAN red] r -> h-2' + name: '[Access VLAN red] r -> host_w_long_n-02' neighbors: - ifname: eth3 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 type: lan vlan: access: red @@ -794,11 +794,11 @@ nodes: ifindex: 9 ifname: eth9 linkindex: 14 - name: '[Access VLAN red] r -> h-3' + name: '[Access VLAN red] r -> host_w_long_n-03' neighbors: - ifname: eth3 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 type: lan vlan: access: red @@ -807,11 +807,11 @@ nodes: ifindex: 10 ifname: eth10 linkindex: 15 - name: '[Access VLAN red] r -> h-4' + name: '[Access VLAN red] r -> host_w_long_n-04' neighbors: - ifname: eth3 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 type: lan vlan: access: red @@ -820,20 +820,20 @@ nodes: ifindex: 11 ifname: vlan1000 ipv4: 172.16.0.1/24 - name: VLAN red (1000) -> [h,h-2,h-3,h-4] + name: VLAN red (1000) -> [host_w_long_name,host_w_long_n-02,host_w_long_n-03,host_w_long_n-04] neighbors: - ifname: vlan1000 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name - ifname: vlan1000 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 - ifname: vlan1000 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 - ifname: vlan1000 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 type: svi virtual_interface: true vlan: @@ -899,41 +899,41 @@ nodes: ifname: eth20 ipv4: 10.1.0.6/30 linkindex: 2 - name: r -> h + name: r -> host_w_long_name neighbors: - ifname: eth2 ipv4: 10.1.0.5/30 - node: h + node: host_w_long_name type: p2p - ifindex: 21 ifname: eth21 ipv4: 10.1.0.26/30 linkindex: 7 - name: r -> h-2 + name: r -> host_w_long_n-02 neighbors: - ifname: eth2 ipv4: 10.1.0.25/30 - node: h-2 + node: host_w_long_n-02 type: p2p - ifindex: 22 ifname: eth22 ipv4: 10.1.0.30/30 linkindex: 8 - name: r -> h-3 + name: r -> host_w_long_n-03 neighbors: - ifname: eth2 ipv4: 10.1.0.29/30 - node: h-3 + node: host_w_long_n-03 type: p2p - ifindex: 23 ifname: eth23 ipv4: 10.1.0.34/30 linkindex: 9 - name: r -> h-4 + name: r -> host_w_long_n-04 neighbors: - ifname: eth2 ipv4: 10.1.0.33/30 - node: h-4 + node: host_w_long_n-04 type: p2p - ifindex: 30000 ifname: bond1 @@ -944,11 +944,11 @@ nodes: lacp_mode: active mode: 802.3ad linkindex: 3 - name: r -> h + name: r -> host_w_long_name neighbors: - ifname: bond1 ipv4: 10.1.0.10/30 - node: h + node: host_w_long_name type: lag virtual_interface: true lag: @@ -992,19 +992,19 @@ vlans: neighbors: - ifname: vlan1000 ipv4: 172.16.0.10/24 - node: h + node: host_w_long_name - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: vlan1000 ipv4: 172.16.0.11/24 - node: h-2 + node: host_w_long_n-02 - ifname: vlan1000 ipv4: 172.16.0.12/24 - node: h-3 + node: host_w_long_n-03 - ifname: vlan1000 ipv4: 172.16.0.13/24 - node: h-4 + node: host_w_long_n-04 prefix: allocation: id_based ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/repeater-plugin.yml b/tests/topology/input/repeater-plugin.yml index ad5cf2ed5..d01f17155 100644 --- a/tests/topology/input/repeater-plugin.yml +++ b/tests/topology/input/repeater-plugin.yml @@ -5,27 +5,27 @@ module: [lag,vlan] vlans: red: - links: [r-h] # VLAN links get updated + links: [r-host_w_long_name] # VLAN links get updated groups: _auto_create: True # Test presence of bool flag hosts: - members: [h] # Gets updated with cloned nodes + members: [host_w_long_name] # Gets updated with cloned nodes nodes: r: device: frr - h: + host_w_long_name: # Test that node names get shortened to at most 16 chars device: frr - repeat: 3 # Create 3 copies -> 4 hosts total - id: 10 # Starting at ID 10 + repeat: 3 # Create 3 copies -> 4 hosts total + id: 10 # Starting at ID 10 links: -- r-h # Plugin supports different styles of specifying links, all normalized +- r-host_w_long_name # Plugin supports different styles of specifying links, all normalized - r: ifindex: 20 # Custom port on router -> gets incremented - h: + host_w_long_name: mtu: 1600 # Interface atts get copied too -- lag.members: [ r-h, r-h ] # TODO lags need special work, not supported yet -> plugin issues a warning and doesn't modify them \ No newline at end of file +- lag.members: [ r-host_w_long_name, r-host_w_long_name ] # TODO lags need special work, not supported yet -> plugin issues a warning and doesn't modify them \ No newline at end of file From 0eb271ba95084221ddb363fec3d0ae0fed719dd9 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Sat, 7 Dec 2024 10:48:39 -0600 Subject: [PATCH 08/19] * Renamed to 'node.clone' * Add clone.count, clone.start and clone.step parameters * Replace cloned node by first clone (implies LAG links now generate an error, cannot leave them in place) * Keep link names * Simplify link cloning logic * Update documentation TODO: Generate errors when unsupported constructs are used in topology --- docs/plugins.md | 1 + docs/plugins/node.clone.md | 65 + netsim/extra/node.clone/defaults.yml | 11 + netsim/extra/node.clone/plugin.py | 98 ++ netsim/extra/repeater/defaults.yml | 9 - netsim/extra/repeater/plugin.py | 83 -- tests/topology/expected/node.clone-plugin.yml | 1227 +++++++++++++++++ tests/topology/expected/repeater-plugin.yml | 1010 -------------- tests/topology/input/node.clone-plugin.yml | 35 + tests/topology/input/repeater-plugin.yml | 31 - 10 files changed, 1437 insertions(+), 1133 deletions(-) create mode 100644 docs/plugins/node.clone.md create mode 100644 netsim/extra/node.clone/defaults.yml create mode 100644 netsim/extra/node.clone/plugin.py delete mode 100644 netsim/extra/repeater/defaults.yml delete mode 100644 netsim/extra/repeater/plugin.py create mode 100644 tests/topology/expected/node.clone-plugin.yml delete mode 100644 tests/topology/expected/repeater-plugin.yml create mode 100644 tests/topology/input/node.clone-plugin.yml delete mode 100644 tests/topology/input/repeater-plugin.yml diff --git a/docs/plugins.md b/docs/plugins.md index 29d21c3ed..4244c8126 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -14,6 +14,7 @@ plugins/check.config.md plugins/fabric.md plugins/multilab.md + plugins/node.clone.md plugins/vrrp.version.md ``` diff --git a/docs/plugins/node.clone.md b/docs/plugins/node.clone.md new file mode 100644 index 000000000..5311562f3 --- /dev/null +++ b/docs/plugins/node.clone.md @@ -0,0 +1,65 @@ +(plugin-node-clone)= +# Dealing with large amounts of identical devices + +The *node.clone* plugin avoids tedious repetitive work by allowing users to mark any node for cloning. Any node with a **clone** attribute gets cloned N times, duplicating links and any group memberships. + +```eval_rst +.. contents:: Table of Contents + :depth: 2 + :local: + :backlinks: none +``` + +## Using the Plugin + +* Add `plugin: [ node.clone ]` to the lab topology. +* Include the **clone** attribute in any nodes that need to be replicated multiple times. + +The plugin is invoked early in the _netlab_ topology transformation process and updates groups and adds nodes and links to the lab topology. + +### Supported attributes + +The naming of cloned nodes can be controlled through global **clone.node_name_pattern**, default "{name[:13]}_{id:02d}". +It is recommended to ensure this generates valid identifiers (of max length 16) + +The plugin adds the following node attributes: +* **clone.count** is a required int (>0) that defines the number of clones to create +* **clone.start** is the index to start at, default 1 +* **clone.step** is an optional step increase between clones, default 1 + +### Caveats + +The plugin does not yet support: +* *lag* module links +* link groups +* VRF links +* components + +## Examples + +(host-cluster)= +### Connect Multiple Hosts to a ToR + +The following lab topology has a cluster of 10 hosts all connected to a Top-of-Rack switch in the same way. +The clones will be called H_01, H_02, ... + +```yaml +plugin: [ node.clone ] + +vlans: + v1: + +nodes: + ToR: + device: frr + module: [ vlan ] + H: + device: linux + clone.count: 10 + +links: +- ToR: + ifindex: 4 # Start from port 4 + vlan.access: v1 + H: +``` diff --git a/netsim/extra/node.clone/defaults.yml b/netsim/extra/node.clone/defaults.yml new file mode 100644 index 000000000..1dd08f5be --- /dev/null +++ b/netsim/extra/node.clone/defaults.yml @@ -0,0 +1,11 @@ +# node.clone plugin attributes and defaults +# +--- +clone: + node_name_pattern: "{name[:13]}_{id:02d}" # Result should be a valid identifier, can use '-' in node names if needed + + attributes: + node: + clone: { type: int, min_value: 1, _required: True } # Create N copies of this node anywhere it's used in groups or links + start: int # Optional ID to start with, default 1 + step: int # Optional increment between clones, default 1 diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py new file mode 100644 index 000000000..e524ba39a --- /dev/null +++ b/netsim/extra/node.clone/plugin.py @@ -0,0 +1,98 @@ +from box import Box +from netsim import data +from netsim.utils import log,strings +from netsim.augment import links + +def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: + ifs = [] + if nodename in [ i.node for i in link_data.get('interfaces',[]) ]: + for c,clone in enumerate(clones): + l = data.get_box(link_data) + l.interfaces = [] + for intf in link_data.interfaces: + intf_clone = data.get_box(intf) + if intf.node == nodename: + intf_clone.node = clone + elif 'ifindex' in intf: + intf_clone.ifindex = intf.ifindex + c + l.interfaces.append(intf_clone) + ifs.append(l) + return ifs + +def update_vlan_access_links(topology: Box, nodename: str, clones: list) -> None: + for vname,vdata in topology.vlans.items(): # Iterate over global VLANs + if not isinstance(vdata,Box): # VLAN not yet a dictionary? + continue # ... no problem, skip it + if not 'links' in vdata: # No VLAN links? + continue # ... no problem, move on + + for cnt,l in enumerate(list(vdata.links)): # So far so good, now iterate over the links + link_data = links.adjust_link_object( # Create link data from link definition + l=l, + linkname=f'vlans.{vname}.links[{cnt+1}]', + nodes=topology.nodes) + if link_data is not None: + ifs = clone_interfaces(link_data,nodename,clones) + if ifs: + vdata.links.remove(l) + vdata.links += ifs + +""" +clone_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes +""" +def clone_node(node: Box, topology: Box) -> None: + _p = { 'start': 1, 'step': 1 } + node.pop('clone',{}) # Define cloning parameters + if 'count' not in _p: + log.error("Node {node.name} missing required attribute clone.count", # Not validated by Netlab yet + category=AttributeError, module='node.clone') + return + + name_format = topology.defaults.clone.node_name_pattern + + orig_name = node.name + node.name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 + topology.nodes += { node.name: node } + + clones = [ node.name ] + for c in range(_p.start+1,_p.start+_p.count+2,_p.step): # Existing node is '1' + clone = data.get_box(node) + clone.name = strings.eval_format(name_format, node + { 'id': c } ) + clone.interfaces = [] # Start clean, remove reference to original node + if 'id' in node: + clone.id = node.id + c - 1 # Update any explicit node ID sequentially + topology.nodes += { clone.name: clone } + clones.append( clone.name ) + + for link in list(topology.get('links',[])): # Make a copy of links list + link_data = links.adjust_link_object(link,f'clone[{orig_name}]',topology.nodes) + if link_data is None: + continue + if 'lag' in link_data: + log.error("LAG links not yet supported by node.clone plugin", + category=AttributeError, module='node.clone') + continue + ifs = clone_interfaces(link_data,orig_name,clones) + if ifs: + topology.links.remove(link) # Remove the original link + topology.links += ifs + + if 'groups' in topology: + for groupname,gdata in topology.groups.items(): + if groupname[0]=='_': # Skip flags and other special items + continue + if orig_name in gdata.get('members',[]): + gdata.members.remove( orig_name ) + gdata.members.extend( clones ) + + if 'vlans' in topology: + update_vlan_access_links(topology,orig_name,clones) + + topology.nodes.pop(orig_name,None) # Finally + +""" +topology_expand - Main plugin function, expands the topology with cloned nodes and interfaces +""" +def topology_expand(topology: Box) -> None: + for node in list(topology.nodes.values()): + if 'clone' in node: + clone_node( node, topology ) diff --git a/netsim/extra/repeater/defaults.yml b/netsim/extra/repeater/defaults.yml deleted file mode 100644 index 02f41b46b..000000000 --- a/netsim/extra/repeater/defaults.yml +++ /dev/null @@ -1,9 +0,0 @@ -# repeater plugin attributes and defaults -# ---- -attributes: - node: - repeat: int # Create N copies of this node anywhere it's used in groups or links - -repeater: - node_name_pattern: "{name[:13]}-{id:02x}" \ No newline at end of file diff --git a/netsim/extra/repeater/plugin.py b/netsim/extra/repeater/plugin.py deleted file mode 100644 index c0e672cc6..000000000 --- a/netsim/extra/repeater/plugin.py +++ /dev/null @@ -1,83 +0,0 @@ -from box import Box -from netsim import data -from netsim.utils import log,strings -from netsim.augment import links - -def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: - """ - update_ifindex - update any custom ifindex on the given interface - """ - def update_ifindex(intf:Box, c:int) -> Box: - ifindex = intf.get('ifindex',None) - if ifindex is not None: - intf = data.get_box(intf) # Need to make a fresh copy - intf.ifindex = ifindex + c + 1 - return intf - - ifs = [] - if nodename in [ i.node for i in link_data.interfaces ]: - link_data.pop('_linkname',None) - atts = [ i for i in link_data.interfaces if i.node==nodename ][0] # Copy any interface atts - for c,clone in enumerate(clones): - l = data.get_box(link_data) - l.interfaces = [ atts+{ 'node': clone } ] + [ update_ifindex(i,c) for i in link_data.interfaces if i.node!=nodename ] - ifs.append(l) - return ifs - -def update_vlan_access_links(topology: Box, nodename: str, clones: list) -> None: - for vname,vdata in topology.vlans.items(): # Iterate over global VLANs - if not isinstance(vdata,Box): # VLAN not yet a dictionary? - continue # ... no problem, skip it - if not 'links' in vdata: # No VLAN links? - continue # ... no problem, move on - - for cnt,l in enumerate(vdata.links): # So far so good, now iterate over the links - link_data = links.adjust_link_object( # Create link data from link definition - l=l, - linkname=f'vlans.{vname}.links[{cnt+1}]', - nodes=topology.nodes) - if link_data is not None: - ifs = clone_interfaces(link_data,nodename,clones) - vdata.links += ifs - -""" -repeat_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes -""" -def repeat_node(node: Box, topology: Box) -> None: - count = node.pop('repeat',None) - clones = [] - for c in range(2,count+2): # Existing node is '1' - clone = data.get_box(node) - clone.name = strings.eval_format(topology.defaults.repeater.node_name_pattern, node + { 'id': c } ) - clone.interfaces = [] # Start clean, remove reference to original node - if 'id' in node: - clone.id = node.id + c - 1 # Update any explicit node ID sequentially - topology.nodes += { clone.name: clone } - clones.append( clone.name ) - - for link in list(topology.get('links',[])): - link_data = links.adjust_link_object(link,f'repeater{c}',topology.nodes) - if link_data is None: - continue - if 'lag' in link_data: - log.error("LAG links not yet supported by repeater plugin, ignoring...", - category=Warning, module='repeater') - continue - ifs = clone_interfaces(link_data,node.name,clones) - topology.links += ifs - - if 'groups' in topology: - for group in topology.groups.values(): - if isinstance(group,Box) and node.name in group.get('members',[]): # Groups can include 'bool flags too - group.members.extend( clones ) - - if 'vlans' in topology: - update_vlan_access_links(topology,node.name,clones) - -""" -topology_expand - Main plugin function, expands the topology with cloned nodes and interfaces -""" -def topology_expand(topology: Box) -> None: - for node in list(topology.nodes.values()): - if 'repeat' in node: - repeat_node( node, topology ) diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml new file mode 100644 index 000000000..8b14ff454 --- /dev/null +++ b/tests/topology/expected/node.clone-plugin.yml @@ -0,0 +1,1227 @@ +groups: + hosts: + members: + - host_w_long_n_01 + - host_w_long_n_02 + - host_w_long_n_03 + - host_w_long_n_04 + - host_w_long_n_05 + - host_w_long_n_06 +input: +- topology/input/node.clone-plugin.yml +- package:topology-defaults.yml +lag: + lacp: fast + lacp_mode: active + mode: 802.3ad +links: +- _linkname: links[1] + bridge: input_1 + gateway: + ipv4: 172.16.1.1/24 + interfaces: + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.1.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.1.10/24 + node: host_w_long_n_01 + linkindex: 1 + node_count: 2 + prefix: + ipv4: 172.16.1.0/24 + role: stub + type: lan +- _linkname: links[2] + bridge: input_2 + gateway: + ipv4: 172.16.2.1/24 + interfaces: + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.2.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.2.11/24 + node: host_w_long_n_02 + linkindex: 2 + node_count: 2 + prefix: + ipv4: 172.16.2.0/24 + role: stub + type: lan +- _linkname: links[3] + bridge: input_3 + gateway: + ipv4: 172.16.3.1/24 + interfaces: + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.3.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.3.12/24 + node: host_w_long_n_03 + linkindex: 3 + node_count: 2 + prefix: + ipv4: 172.16.3.0/24 + role: stub + type: lan +- _linkname: links[4] + bridge: input_4 + gateway: + ipv4: 172.16.4.1/24 + interfaces: + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.4.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.4.13/24 + node: host_w_long_n_04 + linkindex: 4 + node_count: 2 + prefix: + ipv4: 172.16.4.0/24 + role: stub + type: lan +- _linkname: links[5] + bridge: input_5 + gateway: + ipv4: 172.16.5.1/24 + interfaces: + - ifindex: 5 + ifname: eth5 + ipv4: 172.16.5.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.5.14/24 + node: host_w_long_n_05 + linkindex: 5 + node_count: 2 + prefix: + ipv4: 172.16.5.0/24 + role: stub + type: lan +- _linkname: links[6] + bridge: input_6 + gateway: + ipv4: 172.16.6.1/24 + interfaces: + - ifindex: 6 + ifname: eth6 + ipv4: 172.16.6.1/24 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.6.15/24 + node: host_w_long_n_06 + linkindex: 6 + node_count: 2 + prefix: + ipv4: 172.16.6.0/24 + role: stub + type: lan +- _linkname: links[7] + bridge: input_7 + gateway: + ipv4: 172.16.7.1/24 + interfaces: + - ifindex: 20 + ifname: eth20 + ipv4: 172.16.7.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.7.10/24 + mtu: 1600 + node: host_w_long_n_01 + linkindex: 7 + node_count: 2 + prefix: + ipv4: 172.16.7.0/24 + role: stub + type: lan +- _linkname: links[8] + bridge: input_8 + gateway: + ipv4: 172.16.8.1/24 + interfaces: + - ifindex: 21 + ifname: eth21 + ipv4: 172.16.8.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.8.11/24 + mtu: 1600 + node: host_w_long_n_02 + linkindex: 8 + node_count: 2 + prefix: + ipv4: 172.16.8.0/24 + role: stub + type: lan +- _linkname: links[9] + bridge: input_9 + gateway: + ipv4: 172.16.9.1/24 + interfaces: + - ifindex: 22 + ifname: eth22 + ipv4: 172.16.9.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.9.12/24 + mtu: 1600 + node: host_w_long_n_03 + linkindex: 9 + node_count: 2 + prefix: + ipv4: 172.16.9.0/24 + role: stub + type: lan +- _linkname: links[10] + bridge: input_10 + gateway: + ipv4: 172.16.10.1/24 + interfaces: + - ifindex: 23 + ifname: eth23 + ipv4: 172.16.10.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.10.13/24 + mtu: 1600 + node: host_w_long_n_04 + linkindex: 10 + node_count: 2 + prefix: + ipv4: 172.16.10.0/24 + role: stub + type: lan +- _linkname: links[11] + bridge: input_11 + gateway: + ipv4: 172.16.11.1/24 + interfaces: + - ifindex: 24 + ifname: eth24 + ipv4: 172.16.11.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.11.14/24 + mtu: 1600 + node: host_w_long_n_05 + linkindex: 11 + node_count: 2 + prefix: + ipv4: 172.16.11.0/24 + role: stub + type: lan +- _linkname: links[12] + bridge: input_12 + gateway: + ipv4: 172.16.12.1/24 + interfaces: + - ifindex: 25 + ifname: eth25 + ipv4: 172.16.12.1/24 + node: r + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.12.15/24 + mtu: 1600 + node: host_w_long_n_06 + linkindex: 12 + node_count: 2 + prefix: + ipv4: 172.16.12.0/24 + role: stub + type: lan +- _linkname: vlans.red.links[1] + bridge: input_13 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 7 + ifname: eth7 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + linkindex: 13 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[2] + bridge: input_14 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 8 + ifname: eth8 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + linkindex: 14 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[3] + bridge: input_15 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 9 + ifname: eth9 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + linkindex: 15 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[4] + bridge: input_16 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 10 + ifname: eth10 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + linkindex: 16 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[5] + bridge: input_17 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 11 + ifname: eth11 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + linkindex: 17 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +- _linkname: vlans.red.links[6] + bridge: input_18 + gateway: + ipv4: 172.16.0.1/24 + interfaces: + - _vlan_mode: irb + ifindex: 12 + ifname: eth12 + ipv4: 172.16.0.1/24 + node: r + vlan: + access: red + - ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + linkindex: 18 + node_count: 2 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lan + vlan: + access: red +module: +- lag +- vlan +name: input +nodes: + host_w_long_n_01: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 10 + interfaces: + - bridge: input_1 + gateway: + ipv4: 172.16.1.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.1.10/24 + linkindex: 1 + name: host_w_long_n_01 -> r + neighbors: + - ifname: eth1 + ipv4: 172.16.1.1/24 + node: r + role: stub + type: lan + - bridge: input_7 + gateway: + ipv4: 172.16.7.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.7.10/24 + linkindex: 7 + mtu: 1600 + name: host_w_long_n_01 -> r + neighbors: + - ifname: eth20 + ipv4: 172.16.7.1/24 + node: r + role: stub + type: lan + - bridge: input_13 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.10/24 + linkindex: 13 + name: host_w_long_n_01 -> [r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.110 + mac: 08:4f:a9:00:00:0a + name: host_w_long_n_01 + role: host + host_w_long_n_02: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 11 + interfaces: + - bridge: input_2 + gateway: + ipv4: 172.16.2.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.2.11/24 + linkindex: 2 + name: host_w_long_n_02 -> r + neighbors: + - ifname: eth2 + ipv4: 172.16.2.1/24 + node: r + role: stub + type: lan + - bridge: input_8 + gateway: + ipv4: 172.16.8.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.8.11/24 + linkindex: 8 + mtu: 1600 + name: host_w_long_n_02 -> r + neighbors: + - ifname: eth21 + ipv4: 172.16.8.1/24 + node: r + role: stub + type: lan + - bridge: input_14 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.11/24 + linkindex: 14 + name: host_w_long_n_02 -> [host_w_long_n_01,r,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.111 + mac: 08:4f:a9:00:00:0b + name: host_w_long_n_02 + role: host + host_w_long_n_03: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 12 + interfaces: + - bridge: input_3 + gateway: + ipv4: 172.16.3.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.3.12/24 + linkindex: 3 + name: host_w_long_n_03 -> r + neighbors: + - ifname: eth3 + ipv4: 172.16.3.1/24 + node: r + role: stub + type: lan + - bridge: input_9 + gateway: + ipv4: 172.16.9.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.9.12/24 + linkindex: 9 + mtu: 1600 + name: host_w_long_n_03 -> r + neighbors: + - ifname: eth22 + ipv4: 172.16.9.1/24 + node: r + role: stub + type: lan + - bridge: input_15 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.12/24 + linkindex: 15 + name: host_w_long_n_03 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.112 + mac: 08:4f:a9:00:00:0c + name: host_w_long_n_03 + role: host + host_w_long_n_04: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 13 + interfaces: + - bridge: input_4 + gateway: + ipv4: 172.16.4.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.4.13/24 + linkindex: 4 + name: host_w_long_n_04 -> r + neighbors: + - ifname: eth4 + ipv4: 172.16.4.1/24 + node: r + role: stub + type: lan + - bridge: input_10 + gateway: + ipv4: 172.16.10.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.10.13/24 + linkindex: 10 + mtu: 1600 + name: host_w_long_n_04 -> r + neighbors: + - ifname: eth23 + ipv4: 172.16.10.1/24 + node: r + role: stub + type: lan + - bridge: input_16 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.13/24 + linkindex: 16 + name: host_w_long_n_04 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_05,host_w_long_n_06] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.113 + mac: 08:4f:a9:00:00:0d + name: host_w_long_n_04 + role: host + host_w_long_n_05: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 14 + interfaces: + - bridge: input_5 + gateway: + ipv4: 172.16.5.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.5.14/24 + linkindex: 5 + name: host_w_long_n_05 -> r + neighbors: + - ifname: eth5 + ipv4: 172.16.5.1/24 + node: r + role: stub + type: lan + - bridge: input_11 + gateway: + ipv4: 172.16.11.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.11.14/24 + linkindex: 11 + mtu: 1600 + name: host_w_long_n_05 -> r + neighbors: + - ifname: eth24 + ipv4: 172.16.11.1/24 + node: r + role: stub + type: lan + - bridge: input_17 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.14/24 + linkindex: 17 + name: host_w_long_n_05 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_06] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.114 + mac: 08:4f:a9:00:00:0e + name: host_w_long_n_05 + role: host + host_w_long_n_06: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 15 + interfaces: + - bridge: input_6 + gateway: + ipv4: 172.16.6.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.6.15/24 + linkindex: 6 + name: host_w_long_n_06 -> r + neighbors: + - ifname: eth6 + ipv4: 172.16.6.1/24 + node: r + role: stub + type: lan + - bridge: input_12 + gateway: + ipv4: 172.16.12.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.12.15/24 + linkindex: 12 + mtu: 1600 + name: host_w_long_n_06 -> r + neighbors: + - ifname: eth25 + ipv4: 172.16.12.1/24 + node: r + role: stub + type: lan + - bridge: input_18 + gateway: + ipv4: 172.16.0.1/24 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.0.15/24 + linkindex: 18 + name: host_w_long_n_06 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + role: stub + type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.115 + mac: 08:4f:a9:00:00:0f + name: host_w_long_n_06 + role: host + no_count_01: + af: {} + box: generic/ubuntu2004 + device: linux + id: 2 + interfaces: [] + mgmt: + ifname: eth0 + ipv4: 192.168.121.102 + mac: 08:4f:a9:00:00:02 + name: no_count_01 + role: host + no_count_01_04: + af: {} + box: generic/ubuntu2004 + device: linux + id: 3 + interfaces: [] + mgmt: + ifname: eth0 + ipv4: 192.168.121.103 + mac: 08:4f:a9:00:00:03 + name: no_count_01_04 + role: host + no_count_01_05: + af: {} + box: generic/ubuntu2004 + device: linux + id: 4 + interfaces: [] + mgmt: + ifname: eth0 + ipv4: 192.168.121.104 + mac: 08:4f:a9:00:00:04 + name: no_count_01_05 + role: host + r: + _set_ifindex: true + af: + ipv4: true + box: generic/ubuntu2004 + device: frr + id: 1 + interfaces: + - bridge: input_1 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.1.1/24 + linkindex: 1 + name: r -> host_w_long_n_01 + neighbors: + - ifname: eth1 + ipv4: 172.16.1.10/24 + node: host_w_long_n_01 + role: stub + type: lan + - bridge: input_2 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.2.1/24 + linkindex: 2 + name: r -> host_w_long_n_02 + neighbors: + - ifname: eth1 + ipv4: 172.16.2.11/24 + node: host_w_long_n_02 + role: stub + type: lan + - bridge: input_3 + ifindex: 3 + ifname: eth3 + ipv4: 172.16.3.1/24 + linkindex: 3 + name: r -> host_w_long_n_03 + neighbors: + - ifname: eth1 + ipv4: 172.16.3.12/24 + node: host_w_long_n_03 + role: stub + type: lan + - bridge: input_4 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.4.1/24 + linkindex: 4 + name: r -> host_w_long_n_04 + neighbors: + - ifname: eth1 + ipv4: 172.16.4.13/24 + node: host_w_long_n_04 + role: stub + type: lan + - bridge: input_5 + ifindex: 5 + ifname: eth5 + ipv4: 172.16.5.1/24 + linkindex: 5 + name: r -> host_w_long_n_05 + neighbors: + - ifname: eth1 + ipv4: 172.16.5.14/24 + node: host_w_long_n_05 + role: stub + type: lan + - bridge: input_6 + ifindex: 6 + ifname: eth6 + ipv4: 172.16.6.1/24 + linkindex: 6 + name: r -> host_w_long_n_06 + neighbors: + - ifname: eth1 + ipv4: 172.16.6.15/24 + node: host_w_long_n_06 + role: stub + type: lan + - bridge: input_13 + ifindex: 7 + ifname: eth7 + linkindex: 13 + name: '[Access VLAN red] r -> host_w_long_n_01' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_14 + ifindex: 8 + ifname: eth8 + linkindex: 14 + name: '[Access VLAN red] r -> host_w_long_n_02' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_15 + ifindex: 9 + ifname: eth9 + linkindex: 15 + name: '[Access VLAN red] r -> host_w_long_n_03' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_16 + ifindex: 10 + ifname: eth10 + linkindex: 16 + name: '[Access VLAN red] r -> host_w_long_n_04' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_17 + ifindex: 11 + ifname: eth11 + linkindex: 17 + name: '[Access VLAN red] r -> host_w_long_n_05' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + type: lan + vlan: + access: red + access_id: 1000 + - bridge: input_18 + ifindex: 12 + ifname: eth12 + linkindex: 18 + name: '[Access VLAN red] r -> host_w_long_n_06' + neighbors: + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + type: lan + vlan: + access: red + access_id: 1000 + - bridge_group: 1 + ifindex: 13 + ifname: vlan1000 + ipv4: 172.16.0.1/24 + name: VLAN red (1000) -> [host_w_long_n_01,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + role: stub + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + - ifindex: 14 + ifname: eth14 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 15 + ifname: eth15 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 16 + ifname: eth16 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 17 + ifname: eth17 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 18 + ifname: eth18 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 19 + ifname: eth19 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - bridge: input_7 + ifindex: 20 + ifname: eth20 + ipv4: 172.16.7.1/24 + linkindex: 7 + name: r -> host_w_long_n_01 + neighbors: + - ifname: eth2 + ipv4: 172.16.7.10/24 + node: host_w_long_n_01 + role: stub + type: lan + - bridge: input_8 + ifindex: 21 + ifname: eth21 + ipv4: 172.16.8.1/24 + linkindex: 8 + name: r -> host_w_long_n_02 + neighbors: + - ifname: eth2 + ipv4: 172.16.8.11/24 + node: host_w_long_n_02 + role: stub + type: lan + - bridge: input_9 + ifindex: 22 + ifname: eth22 + ipv4: 172.16.9.1/24 + linkindex: 9 + name: r -> host_w_long_n_03 + neighbors: + - ifname: eth2 + ipv4: 172.16.9.12/24 + node: host_w_long_n_03 + role: stub + type: lan + - bridge: input_10 + ifindex: 23 + ifname: eth23 + ipv4: 172.16.10.1/24 + linkindex: 10 + name: r -> host_w_long_n_04 + neighbors: + - ifname: eth2 + ipv4: 172.16.10.13/24 + node: host_w_long_n_04 + role: stub + type: lan + - bridge: input_11 + ifindex: 24 + ifname: eth24 + ipv4: 172.16.11.1/24 + linkindex: 11 + name: r -> host_w_long_n_05 + neighbors: + - ifname: eth2 + ipv4: 172.16.11.14/24 + node: host_w_long_n_05 + role: stub + type: lan + - bridge: input_12 + ifindex: 25 + ifname: eth25 + ipv4: 172.16.12.1/24 + linkindex: 12 + name: r -> host_w_long_n_06 + neighbors: + - ifname: eth2 + ipv4: 172.16.12.15/24 + node: host_w_long_n_06 + role: stub + type: lan + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + libvirt: + nic_adapter_count: 26 + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.1/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.101 + mac: 08:4f:a9:00:00:01 + module: + - lag + - vlan + name: r + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 +plugin: +- node.clone +provider: libvirt +vlans: + red: + host_count: 6 + id: 1000 + neighbors: + - ifname: eth3 + ipv4: 172.16.0.10/24 + node: host_w_long_n_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: eth3 + ipv4: 172.16.0.11/24 + node: host_w_long_n_02 + - ifname: eth3 + ipv4: 172.16.0.12/24 + node: host_w_long_n_03 + - ifname: eth3 + ipv4: 172.16.0.13/24 + node: host_w_long_n_04 + - ifname: eth3 + ipv4: 172.16.0.14/24 + node: host_w_long_n_05 + - ifname: eth3 + ipv4: 172.16.0.15/24 + node: host_w_long_n_06 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 diff --git a/tests/topology/expected/repeater-plugin.yml b/tests/topology/expected/repeater-plugin.yml deleted file mode 100644 index 62cbf1fc3..000000000 --- a/tests/topology/expected/repeater-plugin.yml +++ /dev/null @@ -1,1010 +0,0 @@ -groups: - hosts: - members: - - host_w_long_name - - host_w_long_n-02 - - host_w_long_n-03 - - host_w_long_n-04 -input: -- topology/input/repeater-plugin.yml -- package:topology-defaults.yml -lag: - lacp: fast - lacp_mode: active - mode: 802.3ad -links: -- _linkname: links[1] - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.2/30 - node: r - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.1/30 - node: host_w_long_name - linkindex: 1 - node_count: 2 - prefix: - ipv4: 10.1.0.0/30 - type: p2p -- _linkname: links[2] - interfaces: - - ifindex: 20 - ifname: eth20 - ipv4: 10.1.0.6/30 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.5/30 - mtu: 1600 - node: host_w_long_name - linkindex: 2 - node_count: 2 - prefix: - ipv4: 10.1.0.4/30 - type: p2p -- _linkname: links[3] - bridge: input_3 - interfaces: - - ifindex: 30000 - ifname: bond1 - ipv4: 10.1.0.9/30 - node: r - - ifindex: 30000 - ifname: bond1 - ipv4: 10.1.0.10/30 - node: host_w_long_name - lag: - ifindex: 1 - linkindex: 3 - node_count: 2 - prefix: - ipv4: 10.1.0.8/30 - type: lag -- _linkname: links[4] - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.13/30 - node: host_w_long_n-02 - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.14/30 - node: r - linkindex: 4 - node_count: 2 - prefix: - ipv4: 10.1.0.12/30 - type: p2p -- _linkname: links[5] - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.17/30 - node: host_w_long_n-03 - - ifindex: 3 - ifname: eth3 - ipv4: 10.1.0.18/30 - node: r - linkindex: 5 - node_count: 2 - prefix: - ipv4: 10.1.0.16/30 - type: p2p -- _linkname: links[6] - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.21/30 - node: host_w_long_n-04 - - ifindex: 4 - ifname: eth4 - ipv4: 10.1.0.22/30 - node: r - linkindex: 6 - node_count: 2 - prefix: - ipv4: 10.1.0.20/30 - type: p2p -- _linkname: links[7] - interfaces: - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.25/30 - mtu: 1600 - node: host_w_long_n-02 - - ifindex: 21 - ifname: eth21 - ipv4: 10.1.0.26/30 - node: r - linkindex: 7 - node_count: 2 - prefix: - ipv4: 10.1.0.24/30 - type: p2p -- _linkname: links[8] - interfaces: - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.29/30 - mtu: 1600 - node: host_w_long_n-03 - - ifindex: 22 - ifname: eth22 - ipv4: 10.1.0.30/30 - node: r - linkindex: 8 - node_count: 2 - prefix: - ipv4: 10.1.0.28/30 - type: p2p -- _linkname: links[9] - interfaces: - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.33/30 - mtu: 1600 - node: host_w_long_n-04 - - ifindex: 23 - ifname: eth23 - ipv4: 10.1.0.34/30 - node: r - linkindex: 9 - node_count: 2 - prefix: - ipv4: 10.1.0.32/30 - type: p2p -- _linkname: links[3].lag[1] - interfaces: - - ifindex: 5 - ifname: eth5 - node: r - - ifindex: 3 - ifname: eth3 - node: host_w_long_name - lag: - _parentindex: 3 - linkindex: 10 - node_count: 2 - prefix: false - type: p2p -- _linkname: links[3].lag[2] - interfaces: - - ifindex: 6 - ifname: eth6 - node: r - - ifindex: 4 - ifname: eth4 - node: host_w_long_name - lag: - _parentindex: 3 - linkindex: 11 - node_count: 2 - prefix: false - type: p2p -- _linkname: vlans.red.links[1] - bridge: input_12 - interfaces: - - _vlan_mode: irb - ifindex: 7 - ifname: eth7 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - - _vlan_mode: irb - ifindex: 5 - ifname: eth5 - ipv4: 172.16.0.10/24 - node: host_w_long_name - vlan: - access: red - linkindex: 12 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[2] - bridge: input_13 - interfaces: - - _vlan_mode: irb - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - vlan: - access: red - - _vlan_mode: irb - ifindex: 8 - ifname: eth8 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - linkindex: 13 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[3] - bridge: input_14 - interfaces: - - _vlan_mode: irb - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - vlan: - access: red - - _vlan_mode: irb - ifindex: 9 - ifname: eth9 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - linkindex: 14 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[4] - bridge: input_15 - interfaces: - - _vlan_mode: irb - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - vlan: - access: red - - _vlan_mode: irb - ifindex: 10 - ifname: eth10 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - linkindex: 15 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -module: -- lag -- vlan -name: input -nodes: - host_w_long_n-02: - af: - ipv4: true - box: generic/ubuntu2004 - device: frr - id: 11 - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.13/30 - linkindex: 4 - name: host_w_long_n-02 -> r - neighbors: - - ifname: eth2 - ipv4: 10.1.0.14/30 - node: r - type: p2p - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.25/30 - linkindex: 7 - mtu: 1600 - name: host_w_long_n-02 -> r - neighbors: - - ifname: eth21 - ipv4: 10.1.0.26/30 - node: r - type: p2p - - bridge: input_13 - ifindex: 3 - ifname: eth3 - linkindex: 13 - name: '[Access VLAN red] host_w_long_n-02 -> r' - neighbors: - - ifname: eth8 - ipv4: 172.16.0.1/24 - node: r - type: lan - vlan: - access: red - access_id: 1000 - - bridge_group: 1 - ifindex: 4 - ifname: vlan1000 - ipv4: 172.16.0.11/24 - name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-03,host_w_long_n-04] - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: host_w_long_name - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red - lag: - lacp: fast - lacp_mode: active - mode: 802.3ad - loopback: - ifindex: 0 - ifname: lo - ipv4: 10.0.0.11/32 - neighbors: [] - type: loopback - virtual_interface: true - mgmt: - ifname: eth0 - ipv4: 192.168.121.111 - mac: 08:4f:a9:00:00:0b - module: - - lag - - vlan - name: host_w_long_n-02 - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - host_w_long_n-03: - af: - ipv4: true - box: generic/ubuntu2004 - device: frr - id: 12 - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.17/30 - linkindex: 5 - name: host_w_long_n-03 -> r - neighbors: - - ifname: eth3 - ipv4: 10.1.0.18/30 - node: r - type: p2p - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.29/30 - linkindex: 8 - mtu: 1600 - name: host_w_long_n-03 -> r - neighbors: - - ifname: eth22 - ipv4: 10.1.0.30/30 - node: r - type: p2p - - bridge: input_14 - ifindex: 3 - ifname: eth3 - linkindex: 14 - name: '[Access VLAN red] host_w_long_n-03 -> r' - neighbors: - - ifname: eth9 - ipv4: 172.16.0.1/24 - node: r - type: lan - vlan: - access: red - access_id: 1000 - - bridge_group: 1 - ifindex: 4 - ifname: vlan1000 - ipv4: 172.16.0.12/24 - name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-02,host_w_long_n-04] - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: host_w_long_name - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red - lag: - lacp: fast - lacp_mode: active - mode: 802.3ad - loopback: - ifindex: 0 - ifname: lo - ipv4: 10.0.0.12/32 - neighbors: [] - type: loopback - virtual_interface: true - mgmt: - ifname: eth0 - ipv4: 192.168.121.112 - mac: 08:4f:a9:00:00:0c - module: - - lag - - vlan - name: host_w_long_n-03 - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - host_w_long_n-04: - af: - ipv4: true - box: generic/ubuntu2004 - device: frr - id: 13 - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.21/30 - linkindex: 6 - name: host_w_long_n-04 -> r - neighbors: - - ifname: eth4 - ipv4: 10.1.0.22/30 - node: r - type: p2p - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.33/30 - linkindex: 9 - mtu: 1600 - name: host_w_long_n-04 -> r - neighbors: - - ifname: eth23 - ipv4: 10.1.0.34/30 - node: r - type: p2p - - bridge: input_15 - ifindex: 3 - ifname: eth3 - linkindex: 15 - name: '[Access VLAN red] host_w_long_n-04 -> r' - neighbors: - - ifname: eth10 - ipv4: 172.16.0.1/24 - node: r - type: lan - vlan: - access: red - access_id: 1000 - - bridge_group: 1 - ifindex: 4 - ifname: vlan1000 - ipv4: 172.16.0.13/24 - name: VLAN red (1000) -> [host_w_long_name,r,host_w_long_n-02,host_w_long_n-03] - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: host_w_long_name - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red - lag: - lacp: fast - lacp_mode: active - mode: 802.3ad - loopback: - ifindex: 0 - ifname: lo - ipv4: 10.0.0.13/32 - neighbors: [] - type: loopback - virtual_interface: true - mgmt: - ifname: eth0 - ipv4: 192.168.121.113 - mac: 08:4f:a9:00:00:0d - module: - - lag - - vlan - name: host_w_long_n-04 - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - host_w_long_name: - af: - ipv4: true - box: generic/ubuntu2004 - device: frr - id: 10 - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.1/30 - linkindex: 1 - name: host_w_long_name -> r - neighbors: - - ifname: eth1 - ipv4: 10.1.0.2/30 - node: r - type: p2p - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.5/30 - linkindex: 2 - mtu: 1600 - name: host_w_long_name -> r - neighbors: - - ifname: eth20 - ipv4: 10.1.0.6/30 - node: r - type: p2p - - ifindex: 30000 - ifname: bond1 - ipv4: 10.1.0.10/30 - lag: - ifindex: 1 - lacp: fast - lacp_mode: active - mode: 802.3ad - linkindex: 3 - name: host_w_long_name -> r - neighbors: - - ifname: bond1 - ipv4: 10.1.0.9/30 - node: r - type: lag - virtual_interface: true - - ifindex: 3 - ifname: eth3 - lag: - _parentindex: 3 - linkindex: 10 - name: host_w_long_name -> r - neighbors: - - ifname: eth5 - node: r - type: p2p - - ifindex: 4 - ifname: eth4 - lag: - _parentindex: 3 - linkindex: 11 - name: host_w_long_name -> r - neighbors: - - ifname: eth6 - node: r - type: p2p - - bridge: input_12 - ifindex: 5 - ifname: eth5 - linkindex: 12 - name: '[Access VLAN red] host_w_long_name -> r' - neighbors: - - ifname: eth7 - ipv4: 172.16.0.1/24 - node: r - type: lan - vlan: - access: red - access_id: 1000 - - bridge_group: 1 - ifindex: 6 - ifname: vlan1000 - ipv4: 172.16.0.10/24 - name: VLAN red (1000) -> [r,host_w_long_n-02,host_w_long_n-03,host_w_long_n-04] - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red - lag: - lacp: fast - lacp_mode: active - mode: 802.3ad - loopback: - ifindex: 0 - ifname: lo - ipv4: 10.0.0.10/32 - neighbors: [] - type: loopback - virtual_interface: true - mgmt: - ifname: eth0 - ipv4: 192.168.121.110 - mac: 08:4f:a9:00:00:0a - module: - - lag - - vlan - name: host_w_long_name - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - r: - _set_ifindex: true - af: - ipv4: true - box: generic/ubuntu2004 - device: frr - id: 1 - interfaces: - - ifindex: 1 - ifname: eth1 - ipv4: 10.1.0.2/30 - linkindex: 1 - name: r -> host_w_long_name - neighbors: - - ifname: eth1 - ipv4: 10.1.0.1/30 - node: host_w_long_name - type: p2p - - ifindex: 2 - ifname: eth2 - ipv4: 10.1.0.14/30 - linkindex: 4 - name: r -> host_w_long_n-02 - neighbors: - - ifname: eth1 - ipv4: 10.1.0.13/30 - node: host_w_long_n-02 - type: p2p - - ifindex: 3 - ifname: eth3 - ipv4: 10.1.0.18/30 - linkindex: 5 - name: r -> host_w_long_n-03 - neighbors: - - ifname: eth1 - ipv4: 10.1.0.17/30 - node: host_w_long_n-03 - type: p2p - - ifindex: 4 - ifname: eth4 - ipv4: 10.1.0.22/30 - linkindex: 6 - name: r -> host_w_long_n-04 - neighbors: - - ifname: eth1 - ipv4: 10.1.0.21/30 - node: host_w_long_n-04 - type: p2p - - ifindex: 5 - ifname: eth5 - lag: - _parentindex: 3 - linkindex: 10 - name: r -> host_w_long_name - neighbors: - - ifname: eth3 - node: host_w_long_name - type: p2p - - ifindex: 6 - ifname: eth6 - lag: - _parentindex: 3 - linkindex: 11 - name: r -> host_w_long_name - neighbors: - - ifname: eth4 - node: host_w_long_name - type: p2p - - bridge: input_12 - ifindex: 7 - ifname: eth7 - linkindex: 12 - name: '[Access VLAN red] r -> host_w_long_name' - neighbors: - - ifname: eth5 - ipv4: 172.16.0.10/24 - node: host_w_long_name - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_13 - ifindex: 8 - ifname: eth8 - linkindex: 13 - name: '[Access VLAN red] r -> host_w_long_n-02' - neighbors: - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_14 - ifindex: 9 - ifname: eth9 - linkindex: 14 - name: '[Access VLAN red] r -> host_w_long_n-03' - neighbors: - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_15 - ifindex: 10 - ifname: eth10 - linkindex: 15 - name: '[Access VLAN red] r -> host_w_long_n-04' - neighbors: - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - type: lan - vlan: - access: red - access_id: 1000 - - bridge_group: 1 - ifindex: 11 - ifname: vlan1000 - ipv4: 172.16.0.1/24 - name: VLAN red (1000) -> [host_w_long_name,host_w_long_n-02,host_w_long_n-03,host_w_long_n-04] - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: host_w_long_name - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red - - ifindex: 12 - ifname: eth12 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 13 - ifname: eth13 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 14 - ifname: eth14 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 15 - ifname: eth15 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 16 - ifname: eth16 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 17 - ifname: eth17 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 18 - ifname: eth18 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 19 - ifname: eth19 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 20 - ifname: eth20 - ipv4: 10.1.0.6/30 - linkindex: 2 - name: r -> host_w_long_name - neighbors: - - ifname: eth2 - ipv4: 10.1.0.5/30 - node: host_w_long_name - type: p2p - - ifindex: 21 - ifname: eth21 - ipv4: 10.1.0.26/30 - linkindex: 7 - name: r -> host_w_long_n-02 - neighbors: - - ifname: eth2 - ipv4: 10.1.0.25/30 - node: host_w_long_n-02 - type: p2p - - ifindex: 22 - ifname: eth22 - ipv4: 10.1.0.30/30 - linkindex: 8 - name: r -> host_w_long_n-03 - neighbors: - - ifname: eth2 - ipv4: 10.1.0.29/30 - node: host_w_long_n-03 - type: p2p - - ifindex: 23 - ifname: eth23 - ipv4: 10.1.0.34/30 - linkindex: 9 - name: r -> host_w_long_n-04 - neighbors: - - ifname: eth2 - ipv4: 10.1.0.33/30 - node: host_w_long_n-04 - type: p2p - - ifindex: 30000 - ifname: bond1 - ipv4: 10.1.0.9/30 - lag: - ifindex: 1 - lacp: fast - lacp_mode: active - mode: 802.3ad - linkindex: 3 - name: r -> host_w_long_name - neighbors: - - ifname: bond1 - ipv4: 10.1.0.10/30 - node: host_w_long_name - type: lag - virtual_interface: true - lag: - lacp: fast - lacp_mode: active - mode: 802.3ad - libvirt: - nic_adapter_count: 24 - loopback: - ifindex: 0 - ifname: lo - ipv4: 10.0.0.1/32 - neighbors: [] - type: loopback - virtual_interface: true - mgmt: - ifname: eth0 - ipv4: 192.168.121.101 - mac: 08:4f:a9:00:00:01 - module: - - lag - - vlan - name: r - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 -plugin: -- repeater -provider: libvirt -vlans: - red: - host_count: 0 - id: 1000 - neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.10/24 - node: host_w_long_name - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: vlan1000 - ipv4: 172.16.0.11/24 - node: host_w_long_n-02 - - ifname: vlan1000 - ipv4: 172.16.0.12/24 - node: host_w_long_n-03 - - ifname: vlan1000 - ipv4: 172.16.0.13/24 - node: host_w_long_n-04 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/node.clone-plugin.yml b/tests/topology/input/node.clone-plugin.yml new file mode 100644 index 000000000..106e9fb6f --- /dev/null +++ b/tests/topology/input/node.clone-plugin.yml @@ -0,0 +1,35 @@ +--- +plugin: [ node.clone ] + +module: [lag,vlan] + +vlans: + red: + links: [r-host_w_long_name] # VLAN links get updated + +groups: + _auto_create: True # Test presence of bool flag + hosts: + members: [host_w_long_name] # Gets updated with cloned nodes + +nodes: + r: + device: frr + + host_w_long_name: # Test that node names get shortened to at most 16 chars + device: linux + clone.count: 4 # Create 4 hosts + id: 10 # Starting at ID 10 + + no_count: + device: linux + clone.start: 3 + +links: +- r-host_w_long_name # Plugin supports different styles of specifying links, all normalized +- r: + ifindex: 20 # Custom port on router -> gets incremented + host_w_long_name: + mtu: 1600 # Interface atts get copied too + +# - lag.members: [ r-host_w_long_name, r-host_w_long_name ] # TODO lags need special work, not supported yet \ No newline at end of file diff --git a/tests/topology/input/repeater-plugin.yml b/tests/topology/input/repeater-plugin.yml deleted file mode 100644 index d01f17155..000000000 --- a/tests/topology/input/repeater-plugin.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -plugin: [ repeater ] - -module: [lag,vlan] - -vlans: - red: - links: [r-host_w_long_name] # VLAN links get updated - -groups: - _auto_create: True # Test presence of bool flag - hosts: - members: [host_w_long_name] # Gets updated with cloned nodes - -nodes: - r: - device: frr - - host_w_long_name: # Test that node names get shortened to at most 16 chars - device: frr - repeat: 3 # Create 3 copies -> 4 hosts total - id: 10 # Starting at ID 10 - -links: -- r-host_w_long_name # Plugin supports different styles of specifying links, all normalized -- r: - ifindex: 20 # Custom port on router -> gets incremented - host_w_long_name: - mtu: 1600 # Interface atts get copied too - -- lag.members: [ r-host_w_long_name, r-host_w_long_name ] # TODO lags need special work, not supported yet -> plugin issues a warning and doesn't modify them \ No newline at end of file From 947f18e986c00af6fab03041aa2a15365691028a Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Sat, 7 Dec 2024 11:12:09 -0600 Subject: [PATCH 09/19] * Add support for VRF links Note: link groups could in theory be supported transparently if the transformation got applied before the plugin gets invoked. Similarly, it would be easier if link interfaces were normalized before plugins get invoked --- docs/plugins/node.clone.md | 5 +- netsim/extra/node.clone/plugin.py | 19 +- tests/topology/expected/node.clone-plugin.yml | 394 ++++++++++++++---- tests/topology/input/node.clone-plugin.yml | 10 +- 4 files changed, 337 insertions(+), 91 deletions(-) diff --git a/docs/plugins/node.clone.md b/docs/plugins/node.clone.md index 5311562f3..2a8c8e0e6 100644 --- a/docs/plugins/node.clone.md +++ b/docs/plugins/node.clone.md @@ -29,11 +29,10 @@ The plugin adds the following node attributes: ### Caveats -The plugin does not yet support: +The plugin does not support: * *lag* module links * link groups -* VRF links -* components +* cloning of components (nodes composed of multiple nodes) ## Examples diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index e524ba39a..f15f0b41d 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -19,8 +19,11 @@ def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[B ifs.append(l) return ifs -def update_vlan_access_links(topology: Box, nodename: str, clones: list) -> None: - for vname,vdata in topology.vlans.items(): # Iterate over global VLANs +""" +update_links - updates 'links' lists in VLAN and VRF objects +""" +def update_links(topo_items: Box, nodename: str, clones: list, topology: Box) -> None: + for vname,vdata in topo_items.items(): # Iterate over global VLANs or VRFs if not isinstance(vdata,Box): # VLAN not yet a dictionary? continue # ... no problem, skip it if not 'links' in vdata: # No VLAN links? @@ -47,6 +50,11 @@ def clone_node(node: Box, topology: Box) -> None: category=AttributeError, module='node.clone') return + if 'include' in node: # Check for components + log.error("Cannot clone component {node.name}, only elementary nodes", + category=AttributeError, module='node.clone') + return + name_format = topology.defaults.clone.node_name_pattern orig_name = node.name @@ -85,8 +93,11 @@ def clone_node(node: Box, topology: Box) -> None: gdata.members.extend( clones ) if 'vlans' in topology: - update_vlan_access_links(topology,orig_name,clones) - + update_links(topology.vlans,orig_name,clones,topology) + + if 'vrfs' in topology: + update_links(topology.vrfs,orig_name,clones,topology) + topology.nodes.pop(orig_name,None) # Finally """ diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml index 8b14ff454..82f32a400 100644 --- a/tests/topology/expected/node.clone-plugin.yml +++ b/tests/topology/expected/node.clone-plugin.yml @@ -393,9 +393,130 @@ links: type: lan vlan: access: red +- _linkname: vrfs.red.links[1] + bridge: input_19 + gateway: + ipv4: 172.16.13.1/24 + interfaces: + - ifindex: 13 + ifname: eth13 + ipv4: 172.16.13.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.13.10/24 + node: host_w_long_n_01 + linkindex: 19 + node_count: 2 + prefix: + ipv4: 172.16.13.0/24 + role: stub + type: lan + vrf: red +- _linkname: vrfs.red.links[2] + bridge: input_20 + gateway: + ipv4: 172.16.14.1/24 + interfaces: + - ifindex: 14 + ifname: eth14 + ipv4: 172.16.14.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.14.11/24 + node: host_w_long_n_02 + linkindex: 20 + node_count: 2 + prefix: + ipv4: 172.16.14.0/24 + role: stub + type: lan + vrf: red +- _linkname: vrfs.red.links[3] + bridge: input_21 + gateway: + ipv4: 172.16.15.1/24 + interfaces: + - ifindex: 15 + ifname: eth15 + ipv4: 172.16.15.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.15.12/24 + node: host_w_long_n_03 + linkindex: 21 + node_count: 2 + prefix: + ipv4: 172.16.15.0/24 + role: stub + type: lan + vrf: red +- _linkname: vrfs.red.links[4] + bridge: input_22 + gateway: + ipv4: 172.16.16.1/24 + interfaces: + - ifindex: 16 + ifname: eth16 + ipv4: 172.16.16.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.16.13/24 + node: host_w_long_n_04 + linkindex: 22 + node_count: 2 + prefix: + ipv4: 172.16.16.0/24 + role: stub + type: lan + vrf: red +- _linkname: vrfs.red.links[5] + bridge: input_23 + gateway: + ipv4: 172.16.17.1/24 + interfaces: + - ifindex: 17 + ifname: eth17 + ipv4: 172.16.17.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.17.14/24 + node: host_w_long_n_05 + linkindex: 23 + node_count: 2 + prefix: + ipv4: 172.16.17.0/24 + role: stub + type: lan + vrf: red +- _linkname: vrfs.red.links[6] + bridge: input_24 + gateway: + ipv4: 172.16.18.1/24 + interfaces: + - ifindex: 18 + ifname: eth18 + ipv4: 172.16.18.1/24 + node: r + - ifindex: 4 + ifname: eth4 + ipv4: 172.16.18.15/24 + node: host_w_long_n_06 + linkindex: 24 + node_count: 2 + prefix: + ipv4: 172.16.18.0/24 + role: stub + type: lan + vrf: red module: - lag - vlan +- vrf name: input nodes: host_w_long_n_01: @@ -463,6 +584,21 @@ nodes: node: host_w_long_n_06 role: stub type: lan + - bridge: input_19 + gateway: + ipv4: 172.16.13.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.13.10/24 + linkindex: 19 + name: host_w_long_n_01 -> r + neighbors: + - ifname: eth13 + ipv4: 172.16.13.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.110 @@ -534,6 +670,21 @@ nodes: node: host_w_long_n_06 role: stub type: lan + - bridge: input_20 + gateway: + ipv4: 172.16.14.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.14.11/24 + linkindex: 20 + name: host_w_long_n_02 -> r + neighbors: + - ifname: eth14 + ipv4: 172.16.14.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.111 @@ -605,6 +756,21 @@ nodes: node: host_w_long_n_06 role: stub type: lan + - bridge: input_21 + gateway: + ipv4: 172.16.15.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.15.12/24 + linkindex: 21 + name: host_w_long_n_03 -> r + neighbors: + - ifname: eth15 + ipv4: 172.16.15.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.112 @@ -676,6 +842,21 @@ nodes: node: host_w_long_n_06 role: stub type: lan + - bridge: input_22 + gateway: + ipv4: 172.16.16.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.16.13/24 + linkindex: 22 + name: host_w_long_n_04 -> r + neighbors: + - ifname: eth16 + ipv4: 172.16.16.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.113 @@ -747,6 +928,21 @@ nodes: node: host_w_long_n_06 role: stub type: lan + - bridge: input_23 + gateway: + ipv4: 172.16.17.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.17.14/24 + linkindex: 23 + name: host_w_long_n_05 -> r + neighbors: + - ifname: eth17 + ipv4: 172.16.17.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.114 @@ -818,52 +1014,32 @@ nodes: node: host_w_long_n_05 role: stub type: lan + - bridge: input_24 + gateway: + ipv4: 172.16.18.1/24 + ifindex: 4 + ifname: eth4 + ipv4: 172.16.18.15/24 + linkindex: 24 + name: host_w_long_n_06 -> r + neighbors: + - ifname: eth18 + ipv4: 172.16.18.1/24 + node: r + vrf: red + role: stub + type: lan mgmt: ifname: eth0 ipv4: 192.168.121.115 mac: 08:4f:a9:00:00:0f name: host_w_long_n_06 role: host - no_count_01: - af: {} - box: generic/ubuntu2004 - device: linux - id: 2 - interfaces: [] - mgmt: - ifname: eth0 - ipv4: 192.168.121.102 - mac: 08:4f:a9:00:00:02 - name: no_count_01 - role: host - no_count_01_04: - af: {} - box: generic/ubuntu2004 - device: linux - id: 3 - interfaces: [] - mgmt: - ifname: eth0 - ipv4: 192.168.121.103 - mac: 08:4f:a9:00:00:03 - name: no_count_01_04 - role: host - no_count_01_05: - af: {} - box: generic/ubuntu2004 - device: linux - id: 4 - interfaces: [] - mgmt: - ifname: eth0 - ipv4: 192.168.121.104 - mac: 08:4f:a9:00:00:04 - name: no_count_01_05 - role: host r: _set_ifindex: true af: ipv4: true + vpnv4: true box: generic/ubuntu2004 device: frr id: 1 @@ -1018,8 +1194,86 @@ nodes: vlan: access: red access_id: 1000 - - bridge_group: 1 + - bridge: input_19 ifindex: 13 + ifname: eth13 + ipv4: 172.16.13.1/24 + linkindex: 19 + name: r -> host_w_long_n_01 + neighbors: + - ifname: eth4 + ipv4: 172.16.13.10/24 + node: host_w_long_n_01 + role: stub + type: lan + vrf: red + - bridge: input_20 + ifindex: 14 + ifname: eth14 + ipv4: 172.16.14.1/24 + linkindex: 20 + name: r -> host_w_long_n_02 + neighbors: + - ifname: eth4 + ipv4: 172.16.14.11/24 + node: host_w_long_n_02 + role: stub + type: lan + vrf: red + - bridge: input_21 + ifindex: 15 + ifname: eth15 + ipv4: 172.16.15.1/24 + linkindex: 21 + name: r -> host_w_long_n_03 + neighbors: + - ifname: eth4 + ipv4: 172.16.15.12/24 + node: host_w_long_n_03 + role: stub + type: lan + vrf: red + - bridge: input_22 + ifindex: 16 + ifname: eth16 + ipv4: 172.16.16.1/24 + linkindex: 22 + name: r -> host_w_long_n_04 + neighbors: + - ifname: eth4 + ipv4: 172.16.16.13/24 + node: host_w_long_n_04 + role: stub + type: lan + vrf: red + - bridge: input_23 + ifindex: 17 + ifname: eth17 + ipv4: 172.16.17.1/24 + linkindex: 23 + name: r -> host_w_long_n_05 + neighbors: + - ifname: eth4 + ipv4: 172.16.17.14/24 + node: host_w_long_n_05 + role: stub + type: lan + vrf: red + - bridge: input_24 + ifindex: 18 + ifname: eth18 + ipv4: 172.16.18.1/24 + linkindex: 24 + name: r -> host_w_long_n_06 + neighbors: + - ifname: eth4 + ipv4: 172.16.18.15/24 + node: host_w_long_n_06 + role: stub + type: lan + vrf: red + - bridge_group: 1 + ifindex: 19 ifname: vlan1000 ipv4: 172.16.0.1/24 name: VLAN red (1000) -> [host_w_long_n_01,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] @@ -1048,48 +1302,6 @@ nodes: vlan: mode: irb name: red - - ifindex: 14 - ifname: eth14 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 15 - ifname: eth15 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 16 - ifname: eth16 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 17 - ifname: eth17 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 18 - ifname: eth18 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 19 - ifname: eth19 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - bridge: input_7 ifindex: 20 ifname: eth20 @@ -1182,6 +1394,7 @@ nodes: module: - lag - vlan + - vrf name: r vlan: max_bridge_group: 1 @@ -1193,6 +1406,19 @@ nodes: prefix: allocation: id_based ipv4: 172.16.0.0/24 + vrf: + as: 65000 + vrfs: + red: + af: + ipv4: true + export: + - '65000:1' + id: 1 + import: + - '65000:1' + rd: '65000:1' + vrfidx: 100 plugin: - node.clone provider: libvirt @@ -1225,3 +1451,13 @@ vlans: prefix: allocation: id_based ipv4: 172.16.0.0/24 +vrf: + as: 65000 +vrfs: + red: + export: + - '65000:1' + id: 1 + import: + - '65000:1' + rd: '65000:1' diff --git a/tests/topology/input/node.clone-plugin.yml b/tests/topology/input/node.clone-plugin.yml index 106e9fb6f..c1b5c1bfc 100644 --- a/tests/topology/input/node.clone-plugin.yml +++ b/tests/topology/input/node.clone-plugin.yml @@ -1,12 +1,16 @@ --- plugin: [ node.clone ] -module: [lag,vlan] +module: [lag,vlan,vrf] vlans: red: links: [r-host_w_long_name] # VLAN links get updated +vrfs: + red: + links: [r-host_w_long_name] # VRF links get updated + groups: _auto_create: True # Test presence of bool flag hosts: @@ -21,10 +25,6 @@ nodes: clone.count: 4 # Create 4 hosts id: 10 # Starting at ID 10 - no_count: - device: linux - clone.start: 3 - links: - r-host_w_long_name # Plugin supports different styles of specifying links, all normalized - r: From ae2dbdca95b0de3e36433d37cd2c3a39a420a696 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Sat, 7 Dec 2024 11:37:31 -0600 Subject: [PATCH 10/19] Wait to assign the new name, else clones may get wrong names --- netsim/extra/node.clone/plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index f15f0b41d..03c7443e1 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -58,8 +58,8 @@ def clone_node(node: Box, topology: Box) -> None: name_format = topology.defaults.clone.node_name_pattern orig_name = node.name - node.name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 - topology.nodes += { node.name: node } + new_name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 + topology.nodes += { new_name: node } clones = [ node.name ] for c in range(_p.start+1,_p.start+_p.count+2,_p.step): # Existing node is '1' @@ -98,6 +98,7 @@ def clone_node(node: Box, topology: Box) -> None: if 'vrfs' in topology: update_links(topology.vrfs,orig_name,clones,topology) + node.name = new_name topology.nodes.pop(orig_name,None) # Finally """ From 65705e20db376fcb78189f7c39bca00ea421688f Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Sat, 7 Dec 2024 11:46:44 -0600 Subject: [PATCH 11/19] Test both short and long hostnames --- netsim/extra/node.clone/plugin.py | 7 +- tests/topology/expected/node.clone-plugin.yml | 1239 +++++++---------- tests/topology/input/node.clone-plugin.yml | 12 +- 3 files changed, 491 insertions(+), 767 deletions(-) diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index 03c7443e1..4f0bb0c6e 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -58,13 +58,13 @@ def clone_node(node: Box, topology: Box) -> None: name_format = topology.defaults.clone.node_name_pattern orig_name = node.name - new_name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 - topology.nodes += { new_name: node } + node.name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 + topology.nodes += { node.name: node } clones = [ node.name ] for c in range(_p.start+1,_p.start+_p.count+2,_p.step): # Existing node is '1' clone = data.get_box(node) - clone.name = strings.eval_format(name_format, node + { 'id': c } ) + clone.name = strings.eval_format(name_format, node + { 'id': c, 'name': orig_name } ) clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: clone.id = node.id + c - 1 # Update any explicit node ID sequentially @@ -98,7 +98,6 @@ def clone_node(node: Box, topology: Box) -> None: if 'vrfs' in topology: update_links(topology.vrfs,orig_name,clones,topology) - node.name = new_name topology.nodes.pop(orig_name,None) # Finally """ diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml index 82f32a400..c7c32375a 100644 --- a/tests/topology/expected/node.clone-plugin.yml +++ b/tests/topology/expected/node.clone-plugin.yml @@ -1,12 +1,15 @@ groups: hosts: members: + - h_01 + - h_02 + - h_03 + - h_04 - host_w_long_n_01 - host_w_long_n_02 - host_w_long_n_03 - host_w_long_n_04 - host_w_long_n_05 - - host_w_long_n_06 input: - topology/input/node.clone-plugin.yml - package:topology-defaults.yml @@ -115,14 +118,15 @@ links: gateway: ipv4: 172.16.6.1/24 interfaces: - - ifindex: 6 - ifname: eth6 + - ifindex: 20 + ifname: eth20 ipv4: 172.16.6.1/24 node: r - - ifindex: 1 - ifname: eth1 - ipv4: 172.16.6.15/24 - node: host_w_long_n_06 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.6.10/24 + mtu: 1600 + node: host_w_long_n_01 linkindex: 6 node_count: 2 prefix: @@ -134,15 +138,15 @@ links: gateway: ipv4: 172.16.7.1/24 interfaces: - - ifindex: 20 - ifname: eth20 + - ifindex: 21 + ifname: eth21 ipv4: 172.16.7.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.7.10/24 + ipv4: 172.16.7.11/24 mtu: 1600 - node: host_w_long_n_01 + node: host_w_long_n_02 linkindex: 7 node_count: 2 prefix: @@ -154,15 +158,15 @@ links: gateway: ipv4: 172.16.8.1/24 interfaces: - - ifindex: 21 - ifname: eth21 + - ifindex: 22 + ifname: eth22 ipv4: 172.16.8.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.8.11/24 + ipv4: 172.16.8.12/24 mtu: 1600 - node: host_w_long_n_02 + node: host_w_long_n_03 linkindex: 8 node_count: 2 prefix: @@ -174,15 +178,15 @@ links: gateway: ipv4: 172.16.9.1/24 interfaces: - - ifindex: 22 - ifname: eth22 + - ifindex: 23 + ifname: eth23 ipv4: 172.16.9.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.9.12/24 + ipv4: 172.16.9.13/24 mtu: 1600 - node: host_w_long_n_03 + node: host_w_long_n_04 linkindex: 9 node_count: 2 prefix: @@ -194,78 +198,38 @@ links: gateway: ipv4: 172.16.10.1/24 interfaces: - - ifindex: 23 - ifname: eth23 - ipv4: 172.16.10.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.10.13/24 - mtu: 1600 - node: host_w_long_n_04 - linkindex: 10 - node_count: 2 - prefix: - ipv4: 172.16.10.0/24 - role: stub - type: lan -- _linkname: links[11] - bridge: input_11 - gateway: - ipv4: 172.16.11.1/24 - interfaces: - ifindex: 24 ifname: eth24 - ipv4: 172.16.11.1/24 + ipv4: 172.16.10.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.11.14/24 + ipv4: 172.16.10.14/24 mtu: 1600 node: host_w_long_n_05 - linkindex: 11 - node_count: 2 - prefix: - ipv4: 172.16.11.0/24 - role: stub - type: lan -- _linkname: links[12] - bridge: input_12 - gateway: - ipv4: 172.16.12.1/24 - interfaces: - - ifindex: 25 - ifname: eth25 - ipv4: 172.16.12.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.12.15/24 - mtu: 1600 - node: host_w_long_n_06 - linkindex: 12 + linkindex: 10 node_count: 2 prefix: - ipv4: 172.16.12.0/24 + ipv4: 172.16.10.0/24 role: stub type: lan - _linkname: vlans.red.links[1] - bridge: input_13 + bridge: input_11 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 7 - ifname: eth7 + ifindex: 6 + ifname: eth6 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - linkindex: 13 + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 + linkindex: 11 node_count: 2 prefix: allocation: id_based @@ -274,22 +238,22 @@ links: vlan: access: red - _linkname: vlans.red.links[2] - bridge: input_14 + bridge: input_12 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 8 - ifname: eth8 + ifindex: 7 + ifname: eth7 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - linkindex: 14 + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + linkindex: 12 node_count: 2 prefix: allocation: id_based @@ -298,22 +262,22 @@ links: vlan: access: red - _linkname: vlans.red.links[3] - bridge: input_15 + bridge: input_13 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 9 - ifname: eth9 + ifindex: 8 + ifname: eth8 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - linkindex: 15 + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 + linkindex: 13 node_count: 2 prefix: allocation: id_based @@ -322,70 +286,22 @@ links: vlan: access: red - _linkname: vlans.red.links[4] - bridge: input_16 - gateway: - ipv4: 172.16.0.1/24 - interfaces: - - _vlan_mode: irb - ifindex: 10 - ifname: eth10 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - linkindex: 16 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[5] - bridge: input_17 - gateway: - ipv4: 172.16.0.1/24 - interfaces: - - _vlan_mode: irb - ifindex: 11 - ifname: eth11 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - linkindex: 17 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[6] - bridge: input_18 + bridge: input_14 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 12 - ifname: eth12 + ifindex: 9 + ifname: eth9 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 - linkindex: 18 + - ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 + linkindex: 14 node_count: 2 prefix: allocation: id_based @@ -394,122 +310,82 @@ links: vlan: access: red - _linkname: vrfs.red.links[1] - bridge: input_19 + bridge: input_15 gateway: - ipv4: 172.16.13.1/24 + ipv4: 172.16.11.1/24 interfaces: - - ifindex: 13 - ifname: eth13 - ipv4: 172.16.13.1/24 + - ifindex: 10 + ifname: eth10 + ipv4: 172.16.11.1/24 node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.13.10/24 - node: host_w_long_n_01 - linkindex: 19 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.11.2/24 + node: h_01 + linkindex: 15 node_count: 2 prefix: - ipv4: 172.16.13.0/24 + ipv4: 172.16.11.0/24 role: stub type: lan vrf: red - _linkname: vrfs.red.links[2] - bridge: input_20 + bridge: input_16 gateway: - ipv4: 172.16.14.1/24 + ipv4: 172.16.12.1/24 interfaces: - - ifindex: 14 - ifname: eth14 - ipv4: 172.16.14.1/24 + - ifindex: 11 + ifname: eth11 + ipv4: 172.16.12.1/24 node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.14.11/24 - node: host_w_long_n_02 - linkindex: 20 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.12.3/24 + node: h_02 + linkindex: 16 node_count: 2 prefix: - ipv4: 172.16.14.0/24 + ipv4: 172.16.12.0/24 role: stub type: lan vrf: red - _linkname: vrfs.red.links[3] - bridge: input_21 + bridge: input_17 gateway: - ipv4: 172.16.15.1/24 + ipv4: 172.16.13.1/24 interfaces: - - ifindex: 15 - ifname: eth15 - ipv4: 172.16.15.1/24 + - ifindex: 12 + ifname: eth12 + ipv4: 172.16.13.1/24 node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.15.12/24 - node: host_w_long_n_03 - linkindex: 21 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.13.4/24 + node: h_03 + linkindex: 17 node_count: 2 prefix: - ipv4: 172.16.15.0/24 + ipv4: 172.16.13.0/24 role: stub type: lan vrf: red - _linkname: vrfs.red.links[4] - bridge: input_22 - gateway: - ipv4: 172.16.16.1/24 - interfaces: - - ifindex: 16 - ifname: eth16 - ipv4: 172.16.16.1/24 - node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.16.13/24 - node: host_w_long_n_04 - linkindex: 22 - node_count: 2 - prefix: - ipv4: 172.16.16.0/24 - role: stub - type: lan - vrf: red -- _linkname: vrfs.red.links[5] - bridge: input_23 - gateway: - ipv4: 172.16.17.1/24 - interfaces: - - ifindex: 17 - ifname: eth17 - ipv4: 172.16.17.1/24 - node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.17.14/24 - node: host_w_long_n_05 - linkindex: 23 - node_count: 2 - prefix: - ipv4: 172.16.17.0/24 - role: stub - type: lan - vrf: red -- _linkname: vrfs.red.links[6] - bridge: input_24 + bridge: input_18 gateway: - ipv4: 172.16.18.1/24 + ipv4: 172.16.14.1/24 interfaces: - - ifindex: 18 - ifname: eth18 - ipv4: 172.16.18.1/24 + - ifindex: 13 + ifname: eth13 + ipv4: 172.16.14.1/24 node: r - - ifindex: 4 - ifname: eth4 - ipv4: 172.16.18.15/24 - node: host_w_long_n_06 - linkindex: 24 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.14.5/24 + node: h_04 + linkindex: 18 node_count: 2 prefix: - ipv4: 172.16.18.0/24 + ipv4: 172.16.14.0/24 role: stub type: lan vrf: red @@ -519,167 +395,199 @@ module: - vrf name: input nodes: - host_w_long_n_01: + h_01: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 10 + id: 2 interfaces: - - bridge: input_1 + - bridge: input_11 gateway: - ipv4: 172.16.1.1/24 + ipv4: 172.16.0.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.1.10/24 - linkindex: 1 - name: host_w_long_n_01 -> r + ipv4: 172.16.0.2/24 + linkindex: 11 + name: h_01 -> [r,h_02,h_03,h_04] neighbors: - - ifname: eth1 - ipv4: 172.16.1.1/24 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 node: r + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 role: stub type: lan - - bridge: input_7 + - bridge: input_15 gateway: - ipv4: 172.16.7.1/24 + ipv4: 172.16.11.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.7.10/24 - linkindex: 7 - mtu: 1600 - name: host_w_long_n_01 -> r + ipv4: 172.16.11.2/24 + linkindex: 15 + name: h_01 -> r neighbors: - - ifname: eth20 - ipv4: 172.16.7.1/24 + - ifname: eth10 + ipv4: 172.16.11.1/24 node: r + vrf: red role: stub type: lan - - bridge: input_13 + mgmt: + ifname: eth0 + ipv4: 192.168.121.102 + mac: 08:4f:a9:00:00:02 + name: h_01 + role: host + h_02: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 3 + interfaces: + - bridge: input_12 gateway: ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.10/24 - linkindex: 13 - name: host_w_long_n_01 -> [r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.3/24 + linkindex: 12 + name: h_02 -> [h_01,r,h_03,h_04] neighbors: + - ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 role: stub type: lan - - bridge: input_19 + - bridge: input_16 gateway: - ipv4: 172.16.13.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.13.10/24 - linkindex: 19 - name: host_w_long_n_01 -> r + ipv4: 172.16.12.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.12.3/24 + linkindex: 16 + name: h_02 -> r neighbors: - - ifname: eth13 - ipv4: 172.16.13.1/24 + - ifname: eth11 + ipv4: 172.16.12.1/24 node: r vrf: red role: stub type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.110 - mac: 08:4f:a9:00:00:0a - name: host_w_long_n_01 + ipv4: 192.168.121.103 + mac: 08:4f:a9:00:00:03 + name: h_02 role: host - host_w_long_n_02: + h_03: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 11 + id: 4 interfaces: - - bridge: input_2 + - bridge: input_13 gateway: - ipv4: 172.16.2.1/24 + ipv4: 172.16.0.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.2.11/24 - linkindex: 2 - name: host_w_long_n_02 -> r + ipv4: 172.16.0.4/24 + linkindex: 13 + name: h_03 -> [h_01,r,h_02,h_04] neighbors: - - ifname: eth2 - ipv4: 172.16.2.1/24 + - ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 node: r + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 role: stub type: lan - - bridge: input_8 + - bridge: input_17 gateway: - ipv4: 172.16.8.1/24 + ipv4: 172.16.13.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.8.11/24 - linkindex: 8 - mtu: 1600 - name: host_w_long_n_02 -> r + ipv4: 172.16.13.4/24 + linkindex: 17 + name: h_03 -> r neighbors: - - ifname: eth21 - ipv4: 172.16.8.1/24 + - ifname: eth12 + ipv4: 172.16.13.1/24 node: r + vrf: red role: stub type: lan + mgmt: + ifname: eth0 + ipv4: 192.168.121.104 + mac: 08:4f:a9:00:00:04 + name: h_03 + role: host + h_04: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 5 + interfaces: - bridge: input_14 gateway: ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.11/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.0.5/24 linkindex: 14 - name: host_w_long_n_02 -> [host_w_long_n_01,r,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + name: h_04 -> [h_01,r,h_02,h_03] neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 + - ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 role: stub type: lan - - bridge: input_20 + - bridge: input_18 gateway: ipv4: 172.16.14.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.14.11/24 - linkindex: 20 - name: host_w_long_n_02 -> r + ifindex: 2 + ifname: eth2 + ipv4: 172.16.14.5/24 + linkindex: 18 + name: h_04 -> r neighbors: - - ifname: eth14 + - ifname: eth13 ipv4: 172.16.14.1/24 node: r vrf: red @@ -687,353 +595,219 @@ nodes: type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.111 - mac: 08:4f:a9:00:00:0b - name: host_w_long_n_02 + ipv4: 192.168.121.105 + mac: 08:4f:a9:00:00:05 + name: h_04 role: host - host_w_long_n_03: + host_w_long_n_01: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 12 + id: 10 interfaces: - - bridge: input_3 + - bridge: input_1 gateway: - ipv4: 172.16.3.1/24 + ipv4: 172.16.1.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.3.12/24 - linkindex: 3 - name: host_w_long_n_03 -> r + ipv4: 172.16.1.10/24 + linkindex: 1 + name: host_w_long_n_01 -> r neighbors: - - ifname: eth3 - ipv4: 172.16.3.1/24 + - ifname: eth1 + ipv4: 172.16.1.1/24 node: r role: stub type: lan - - bridge: input_9 + - bridge: input_6 gateway: - ipv4: 172.16.9.1/24 + ipv4: 172.16.6.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.9.12/24 - linkindex: 9 + ipv4: 172.16.6.10/24 + linkindex: 6 mtu: 1600 - name: host_w_long_n_03 -> r - neighbors: - - ifname: eth22 - ipv4: 172.16.9.1/24 - node: r - role: stub - type: lan - - bridge: input_15 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.12/24 - linkindex: 15 - name: host_w_long_n_03 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] - neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 - role: stub - type: lan - - bridge: input_21 - gateway: - ipv4: 172.16.15.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.15.12/24 - linkindex: 21 - name: host_w_long_n_03 -> r + name: host_w_long_n_01 -> r neighbors: - - ifname: eth15 - ipv4: 172.16.15.1/24 + - ifname: eth20 + ipv4: 172.16.6.1/24 node: r - vrf: red role: stub type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.112 - mac: 08:4f:a9:00:00:0c - name: host_w_long_n_03 + ipv4: 192.168.121.110 + mac: 08:4f:a9:00:00:0a + name: host_w_long_n_01 role: host - host_w_long_n_04: + host_w_long_n_02: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 13 + id: 11 interfaces: - - bridge: input_4 + - bridge: input_2 gateway: - ipv4: 172.16.4.1/24 + ipv4: 172.16.2.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.4.13/24 - linkindex: 4 - name: host_w_long_n_04 -> r + ipv4: 172.16.2.11/24 + linkindex: 2 + name: host_w_long_n_02 -> r neighbors: - - ifname: eth4 - ipv4: 172.16.4.1/24 + - ifname: eth2 + ipv4: 172.16.2.1/24 node: r role: stub type: lan - - bridge: input_10 + - bridge: input_7 gateway: - ipv4: 172.16.10.1/24 + ipv4: 172.16.7.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.10.13/24 - linkindex: 10 + ipv4: 172.16.7.11/24 + linkindex: 7 mtu: 1600 - name: host_w_long_n_04 -> r - neighbors: - - ifname: eth23 - ipv4: 172.16.10.1/24 - node: r - role: stub - type: lan - - bridge: input_16 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.13/24 - linkindex: 16 - name: host_w_long_n_04 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_05,host_w_long_n_06] - neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 - role: stub - type: lan - - bridge: input_22 - gateway: - ipv4: 172.16.16.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.16.13/24 - linkindex: 22 - name: host_w_long_n_04 -> r + name: host_w_long_n_02 -> r neighbors: - - ifname: eth16 - ipv4: 172.16.16.1/24 + - ifname: eth21 + ipv4: 172.16.7.1/24 node: r - vrf: red role: stub type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.113 - mac: 08:4f:a9:00:00:0d - name: host_w_long_n_04 + ipv4: 192.168.121.111 + mac: 08:4f:a9:00:00:0b + name: host_w_long_n_02 role: host - host_w_long_n_05: + host_w_long_n_03: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 14 + id: 12 interfaces: - - bridge: input_5 + - bridge: input_3 gateway: - ipv4: 172.16.5.1/24 + ipv4: 172.16.3.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.5.14/24 - linkindex: 5 - name: host_w_long_n_05 -> r + ipv4: 172.16.3.12/24 + linkindex: 3 + name: host_w_long_n_03 -> r neighbors: - - ifname: eth5 - ipv4: 172.16.5.1/24 + - ifname: eth3 + ipv4: 172.16.3.1/24 node: r role: stub type: lan - - bridge: input_11 + - bridge: input_8 gateway: - ipv4: 172.16.11.1/24 + ipv4: 172.16.8.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.11.14/24 - linkindex: 11 + ipv4: 172.16.8.12/24 + linkindex: 8 mtu: 1600 - name: host_w_long_n_05 -> r - neighbors: - - ifname: eth24 - ipv4: 172.16.11.1/24 - node: r - role: stub - type: lan - - bridge: input_17 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.14/24 - linkindex: 17 - name: host_w_long_n_05 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_06] - neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 - role: stub - type: lan - - bridge: input_23 - gateway: - ipv4: 172.16.17.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.17.14/24 - linkindex: 23 - name: host_w_long_n_05 -> r + name: host_w_long_n_03 -> r neighbors: - - ifname: eth17 - ipv4: 172.16.17.1/24 + - ifname: eth22 + ipv4: 172.16.8.1/24 node: r - vrf: red role: stub type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.114 - mac: 08:4f:a9:00:00:0e - name: host_w_long_n_05 + ipv4: 192.168.121.112 + mac: 08:4f:a9:00:00:0c + name: host_w_long_n_03 role: host - host_w_long_n_06: + host_w_long_n_04: af: ipv4: true box: generic/ubuntu2004 device: linux - id: 15 + id: 13 interfaces: - - bridge: input_6 + - bridge: input_4 gateway: - ipv4: 172.16.6.1/24 + ipv4: 172.16.4.1/24 ifindex: 1 ifname: eth1 - ipv4: 172.16.6.15/24 - linkindex: 6 - name: host_w_long_n_06 -> r + ipv4: 172.16.4.13/24 + linkindex: 4 + name: host_w_long_n_04 -> r neighbors: - - ifname: eth6 - ipv4: 172.16.6.1/24 + - ifname: eth4 + ipv4: 172.16.4.1/24 node: r role: stub type: lan - - bridge: input_12 + - bridge: input_9 gateway: - ipv4: 172.16.12.1/24 + ipv4: 172.16.9.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.12.15/24 - linkindex: 12 + ipv4: 172.16.9.13/24 + linkindex: 9 mtu: 1600 - name: host_w_long_n_06 -> r + name: host_w_long_n_04 -> r neighbors: - - ifname: eth25 - ipv4: 172.16.12.1/24 + - ifname: eth23 + ipv4: 172.16.9.1/24 node: r role: stub type: lan - - bridge: input_18 + mgmt: + ifname: eth0 + ipv4: 192.168.121.113 + mac: 08:4f:a9:00:00:0d + name: host_w_long_n_04 + role: host + host_w_long_n_05: + af: + ipv4: true + box: generic/ubuntu2004 + device: linux + id: 14 + interfaces: + - bridge: input_5 gateway: - ipv4: 172.16.0.1/24 - ifindex: 3 - ifname: eth3 - ipv4: 172.16.0.15/24 - linkindex: 18 - name: host_w_long_n_06 -> [host_w_long_n_01,r,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05] + ipv4: 172.16.5.1/24 + ifindex: 1 + ifname: eth1 + ipv4: 172.16.5.14/24 + linkindex: 5 + name: host_w_long_n_05 -> r neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 + - ifname: eth5 + ipv4: 172.16.5.1/24 node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 role: stub type: lan - - bridge: input_24 + - bridge: input_10 gateway: - ipv4: 172.16.18.1/24 - ifindex: 4 - ifname: eth4 - ipv4: 172.16.18.15/24 - linkindex: 24 - name: host_w_long_n_06 -> r + ipv4: 172.16.10.1/24 + ifindex: 2 + ifname: eth2 + ipv4: 172.16.10.14/24 + linkindex: 10 + mtu: 1600 + name: host_w_long_n_05 -> r neighbors: - - ifname: eth18 - ipv4: 172.16.18.1/24 + - ifname: eth24 + ipv4: 172.16.10.1/24 node: r - vrf: red role: stub type: lan mgmt: ifname: eth0 - ipv4: 192.168.121.115 - mac: 08:4f:a9:00:00:0f - name: host_w_long_n_06 + ipv4: 192.168.121.114 + mac: 08:4f:a9:00:00:0e + name: host_w_long_n_05 role: host r: _set_ifindex: true @@ -1104,282 +878,235 @@ nodes: node: host_w_long_n_05 role: stub type: lan - - bridge: input_6 + - bridge: input_11 ifindex: 6 ifname: eth6 - ipv4: 172.16.6.1/24 - linkindex: 6 - name: r -> host_w_long_n_06 + linkindex: 11 + name: '[Access VLAN red] r -> h_01' neighbors: - ifname: eth1 - ipv4: 172.16.6.15/24 - node: host_w_long_n_06 - role: stub + ipv4: 172.16.0.2/24 + node: h_01 type: lan - - bridge: input_13 + vlan: + access: red + access_id: 1000 + - bridge: input_12 ifindex: 7 ifname: eth7 - linkindex: 13 - name: '[Access VLAN red] r -> host_w_long_n_01' + linkindex: 12 + name: '[Access VLAN red] r -> h_02' neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 type: lan vlan: access: red access_id: 1000 - - bridge: input_14 + - bridge: input_13 ifindex: 8 ifname: eth8 - linkindex: 14 - name: '[Access VLAN red] r -> host_w_long_n_02' + linkindex: 13 + name: '[Access VLAN red] r -> h_03' neighbors: - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 type: lan vlan: access: red access_id: 1000 - - bridge: input_15 + - bridge: input_14 ifindex: 9 ifname: eth9 - linkindex: 15 - name: '[Access VLAN red] r -> host_w_long_n_03' + linkindex: 14 + name: '[Access VLAN red] r -> h_04' neighbors: - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 type: lan vlan: access: red access_id: 1000 - - bridge: input_16 + - bridge: input_15 ifindex: 10 ifname: eth10 - linkindex: 16 - name: '[Access VLAN red] r -> host_w_long_n_04' + ipv4: 172.16.11.1/24 + linkindex: 15 + name: r -> h_01 neighbors: - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 + - ifname: eth2 + ipv4: 172.16.11.2/24 + node: h_01 + role: stub type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_17 + vrf: red + - bridge: input_16 ifindex: 11 ifname: eth11 - linkindex: 17 - name: '[Access VLAN red] r -> host_w_long_n_05' + ipv4: 172.16.12.1/24 + linkindex: 16 + name: r -> h_02 neighbors: - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 + - ifname: eth2 + ipv4: 172.16.12.3/24 + node: h_02 + role: stub type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_18 + vrf: red + - bridge: input_17 ifindex: 12 ifname: eth12 - linkindex: 18 - name: '[Access VLAN red] r -> host_w_long_n_06' - neighbors: - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_19 - ifindex: 13 - ifname: eth13 ipv4: 172.16.13.1/24 - linkindex: 19 - name: r -> host_w_long_n_01 + linkindex: 17 + name: r -> h_03 neighbors: - - ifname: eth4 - ipv4: 172.16.13.10/24 - node: host_w_long_n_01 + - ifname: eth2 + ipv4: 172.16.13.4/24 + node: h_03 role: stub type: lan vrf: red - - bridge: input_20 - ifindex: 14 - ifname: eth14 + - bridge: input_18 + ifindex: 13 + ifname: eth13 ipv4: 172.16.14.1/24 - linkindex: 20 - name: r -> host_w_long_n_02 - neighbors: - - ifname: eth4 - ipv4: 172.16.14.11/24 - node: host_w_long_n_02 - role: stub - type: lan - vrf: red - - bridge: input_21 - ifindex: 15 - ifname: eth15 - ipv4: 172.16.15.1/24 - linkindex: 21 - name: r -> host_w_long_n_03 - neighbors: - - ifname: eth4 - ipv4: 172.16.15.12/24 - node: host_w_long_n_03 - role: stub - type: lan - vrf: red - - bridge: input_22 - ifindex: 16 - ifname: eth16 - ipv4: 172.16.16.1/24 - linkindex: 22 - name: r -> host_w_long_n_04 - neighbors: - - ifname: eth4 - ipv4: 172.16.16.13/24 - node: host_w_long_n_04 - role: stub - type: lan - vrf: red - - bridge: input_23 - ifindex: 17 - ifname: eth17 - ipv4: 172.16.17.1/24 - linkindex: 23 - name: r -> host_w_long_n_05 - neighbors: - - ifname: eth4 - ipv4: 172.16.17.14/24 - node: host_w_long_n_05 - role: stub - type: lan - vrf: red - - bridge: input_24 - ifindex: 18 - ifname: eth18 - ipv4: 172.16.18.1/24 - linkindex: 24 - name: r -> host_w_long_n_06 + linkindex: 18 + name: r -> h_04 neighbors: - - ifname: eth4 - ipv4: 172.16.18.15/24 - node: host_w_long_n_06 + - ifname: eth2 + ipv4: 172.16.14.5/24 + node: h_04 role: stub type: lan vrf: red - bridge_group: 1 - ifindex: 19 + ifindex: 14 ifname: vlan1000 ipv4: 172.16.0.1/24 - name: VLAN red (1000) -> [host_w_long_n_01,host_w_long_n_02,host_w_long_n_03,host_w_long_n_04,host_w_long_n_05,host_w_long_n_06] + name: VLAN red (1000) -> [h_01,h_02,h_03,h_04] neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 + - ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 role: stub type: svi virtual_interface: true vlan: mode: irb name: red - - bridge: input_7 + - ifindex: 15 + ifname: eth15 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 16 + ifname: eth16 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 17 + ifname: eth17 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 18 + ifname: eth18 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 19 + ifname: eth19 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - bridge: input_6 ifindex: 20 ifname: eth20 - ipv4: 172.16.7.1/24 - linkindex: 7 + ipv4: 172.16.6.1/24 + linkindex: 6 name: r -> host_w_long_n_01 neighbors: - ifname: eth2 - ipv4: 172.16.7.10/24 + ipv4: 172.16.6.10/24 node: host_w_long_n_01 role: stub type: lan - - bridge: input_8 + - bridge: input_7 ifindex: 21 ifname: eth21 - ipv4: 172.16.8.1/24 - linkindex: 8 + ipv4: 172.16.7.1/24 + linkindex: 7 name: r -> host_w_long_n_02 neighbors: - ifname: eth2 - ipv4: 172.16.8.11/24 + ipv4: 172.16.7.11/24 node: host_w_long_n_02 role: stub type: lan - - bridge: input_9 + - bridge: input_8 ifindex: 22 ifname: eth22 - ipv4: 172.16.9.1/24 - linkindex: 9 + ipv4: 172.16.8.1/24 + linkindex: 8 name: r -> host_w_long_n_03 neighbors: - ifname: eth2 - ipv4: 172.16.9.12/24 + ipv4: 172.16.8.12/24 node: host_w_long_n_03 role: stub type: lan - - bridge: input_10 + - bridge: input_9 ifindex: 23 ifname: eth23 - ipv4: 172.16.10.1/24 - linkindex: 10 + ipv4: 172.16.9.1/24 + linkindex: 9 name: r -> host_w_long_n_04 neighbors: - ifname: eth2 - ipv4: 172.16.10.13/24 + ipv4: 172.16.9.13/24 node: host_w_long_n_04 role: stub type: lan - - bridge: input_11 + - bridge: input_10 ifindex: 24 ifname: eth24 - ipv4: 172.16.11.1/24 - linkindex: 11 + ipv4: 172.16.10.1/24 + linkindex: 10 name: r -> host_w_long_n_05 neighbors: - ifname: eth2 - ipv4: 172.16.11.14/24 + ipv4: 172.16.10.14/24 node: host_w_long_n_05 role: stub type: lan - - bridge: input_12 - ifindex: 25 - ifname: eth25 - ipv4: 172.16.12.1/24 - linkindex: 12 - name: r -> host_w_long_n_06 - neighbors: - - ifname: eth2 - ipv4: 172.16.12.15/24 - node: host_w_long_n_06 - role: stub - type: lan lag: lacp: fast lacp_mode: active mode: 802.3ad libvirt: - nic_adapter_count: 26 + nic_adapter_count: 25 loopback: ifindex: 0 ifname: lo @@ -1424,30 +1151,24 @@ plugin: provider: libvirt vlans: red: - host_count: 6 + host_count: 4 id: 1000 neighbors: - - ifname: eth3 - ipv4: 172.16.0.10/24 - node: host_w_long_n_01 + - ifname: eth1 + ipv4: 172.16.0.2/24 + node: h_01 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: eth3 - ipv4: 172.16.0.11/24 - node: host_w_long_n_02 - - ifname: eth3 - ipv4: 172.16.0.12/24 - node: host_w_long_n_03 - - ifname: eth3 - ipv4: 172.16.0.13/24 - node: host_w_long_n_04 - - ifname: eth3 - ipv4: 172.16.0.14/24 - node: host_w_long_n_05 - - ifname: eth3 - ipv4: 172.16.0.15/24 - node: host_w_long_n_06 + - ifname: eth1 + ipv4: 172.16.0.3/24 + node: h_02 + - ifname: eth1 + ipv4: 172.16.0.4/24 + node: h_03 + - ifname: eth1 + ipv4: 172.16.0.5/24 + node: h_04 prefix: allocation: id_based ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/node.clone-plugin.yml b/tests/topology/input/node.clone-plugin.yml index c1b5c1bfc..e9dc088d7 100644 --- a/tests/topology/input/node.clone-plugin.yml +++ b/tests/topology/input/node.clone-plugin.yml @@ -5,24 +5,28 @@ module: [lag,vlan,vrf] vlans: red: - links: [r-host_w_long_name] # VLAN links get updated + links: [r-h] # VLAN links get updated vrfs: red: - links: [r-host_w_long_name] # VRF links get updated + links: [r-h] # VRF links get updated groups: _auto_create: True # Test presence of bool flag hosts: - members: [host_w_long_name] # Gets updated with cloned nodes + members: [h,host_w_long_name] # Gets updated with cloned nodes nodes: r: device: frr + h: # Short name, regular test + device: linux + clone.count: 2 + host_w_long_name: # Test that node names get shortened to at most 16 chars device: linux - clone.count: 4 # Create 4 hosts + clone.count: 3 # Create 3 hosts id: 10 # Starting at ID 10 links: From b5e20b10052d00946b5c290aa3d656d9d574498e Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Sat, 7 Dec 2024 17:31:03 -0600 Subject: [PATCH 12/19] * Use start and step parameters, test them * Use '-' in node name template --- netsim/extra/node.clone/defaults.yml | 2 +- netsim/extra/node.clone/plugin.py | 4 +- tests/topology/expected/node.clone-plugin.yml | 852 +++++------------- tests/topology/input/node.clone-plugin.yml | 5 +- 4 files changed, 214 insertions(+), 649 deletions(-) diff --git a/netsim/extra/node.clone/defaults.yml b/netsim/extra/node.clone/defaults.yml index 1dd08f5be..60b97921f 100644 --- a/netsim/extra/node.clone/defaults.yml +++ b/netsim/extra/node.clone/defaults.yml @@ -2,7 +2,7 @@ # --- clone: - node_name_pattern: "{name[:13]}_{id:02d}" # Result should be a valid identifier, can use '-' in node names if needed + node_name_pattern: "{name[:13]}-{id:02d}" # Result should be a valid identifier, can use '-' in node names attributes: node: diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index 4f0bb0c6e..c43471138 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -58,11 +58,11 @@ def clone_node(node: Box, topology: Box) -> None: name_format = topology.defaults.clone.node_name_pattern orig_name = node.name - node.name = strings.eval_format(name_format, node + { 'id': 1 } ) # Rename first node as clone_01 + node.name = strings.eval_format(name_format, node + { 'id': _p.start } ) # Rename first node as clone_01 topology.nodes += { node.name: node } clones = [ node.name ] - for c in range(_p.start+1,_p.start+_p.count+2,_p.step): # Existing node is '1' + for c in range(_p.start+_p.step,_p.start+_p.count*_p.step,_p.step): # Existing node is '1' clone = data.get_box(node) clone.name = strings.eval_format(name_format, node + { 'id': c, 'name': orig_name } ) clone.interfaces = [] # Start clean, remove reference to original node diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml index c7c32375a..47c97cee4 100644 --- a/tests/topology/expected/node.clone-plugin.yml +++ b/tests/topology/expected/node.clone-plugin.yml @@ -1,15 +1,11 @@ groups: hosts: members: - - h_01 - - h_02 - - h_03 - - h_04 - - host_w_long_n_01 - - host_w_long_n_02 - - host_w_long_n_03 - - host_w_long_n_04 - - host_w_long_n_05 + - h-03 + - h-07 + - host_w_long_n-01 + - host_w_long_n-02 + - host_w_long_n-03 input: - topology/input/node.clone-plugin.yml - package:topology-defaults.yml @@ -30,7 +26,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 172.16.1.10/24 - node: host_w_long_n_01 + node: host_w_long_n-01 linkindex: 1 node_count: 2 prefix: @@ -49,7 +45,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 172.16.2.11/24 - node: host_w_long_n_02 + node: host_w_long_n-02 linkindex: 2 node_count: 2 prefix: @@ -68,7 +64,7 @@ links: - ifindex: 1 ifname: eth1 ipv4: 172.16.3.12/24 - node: host_w_long_n_03 + node: host_w_long_n-03 linkindex: 3 node_count: 2 prefix: @@ -80,14 +76,15 @@ links: gateway: ipv4: 172.16.4.1/24 interfaces: - - ifindex: 4 - ifname: eth4 + - ifindex: 20 + ifname: eth20 ipv4: 172.16.4.1/24 node: r - - ifindex: 1 - ifname: eth1 - ipv4: 172.16.4.13/24 - node: host_w_long_n_04 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.4.10/24 + mtu: 1600 + node: host_w_long_n-01 linkindex: 4 node_count: 2 prefix: @@ -99,14 +96,15 @@ links: gateway: ipv4: 172.16.5.1/24 interfaces: - - ifindex: 5 - ifname: eth5 + - ifindex: 21 + ifname: eth21 ipv4: 172.16.5.1/24 node: r - - ifindex: 1 - ifname: eth1 - ipv4: 172.16.5.14/24 - node: host_w_long_n_05 + - ifindex: 2 + ifname: eth2 + ipv4: 172.16.5.11/24 + mtu: 1600 + node: host_w_long_n-02 linkindex: 5 node_count: 2 prefix: @@ -118,109 +116,29 @@ links: gateway: ipv4: 172.16.6.1/24 interfaces: - - ifindex: 20 - ifname: eth20 + - ifindex: 22 + ifname: eth22 ipv4: 172.16.6.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.6.10/24 + ipv4: 172.16.6.12/24 mtu: 1600 - node: host_w_long_n_01 + node: host_w_long_n-03 linkindex: 6 node_count: 2 prefix: ipv4: 172.16.6.0/24 role: stub type: lan -- _linkname: links[7] - bridge: input_7 - gateway: - ipv4: 172.16.7.1/24 - interfaces: - - ifindex: 21 - ifname: eth21 - ipv4: 172.16.7.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.7.11/24 - mtu: 1600 - node: host_w_long_n_02 - linkindex: 7 - node_count: 2 - prefix: - ipv4: 172.16.7.0/24 - role: stub - type: lan -- _linkname: links[8] - bridge: input_8 - gateway: - ipv4: 172.16.8.1/24 - interfaces: - - ifindex: 22 - ifname: eth22 - ipv4: 172.16.8.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.8.12/24 - mtu: 1600 - node: host_w_long_n_03 - linkindex: 8 - node_count: 2 - prefix: - ipv4: 172.16.8.0/24 - role: stub - type: lan -- _linkname: links[9] - bridge: input_9 - gateway: - ipv4: 172.16.9.1/24 - interfaces: - - ifindex: 23 - ifname: eth23 - ipv4: 172.16.9.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.9.13/24 - mtu: 1600 - node: host_w_long_n_04 - linkindex: 9 - node_count: 2 - prefix: - ipv4: 172.16.9.0/24 - role: stub - type: lan -- _linkname: links[10] - bridge: input_10 - gateway: - ipv4: 172.16.10.1/24 - interfaces: - - ifindex: 24 - ifname: eth24 - ipv4: 172.16.10.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.10.14/24 - mtu: 1600 - node: host_w_long_n_05 - linkindex: 10 - node_count: 2 - prefix: - ipv4: 172.16.10.0/24 - role: stub - type: lan - _linkname: vlans.red.links[1] - bridge: input_11 + bridge: input_7 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 6 - ifname: eth6 + ifindex: 4 + ifname: eth4 ipv4: 172.16.0.1/24 node: r vlan: @@ -228,8 +146,8 @@ links: - ifindex: 1 ifname: eth1 ipv4: 172.16.0.2/24 - node: h_01 - linkindex: 11 + node: h-03 + linkindex: 7 node_count: 2 prefix: allocation: id_based @@ -238,13 +156,13 @@ links: vlan: access: red - _linkname: vlans.red.links[2] - bridge: input_12 + bridge: input_8 gateway: ipv4: 172.16.0.1/24 interfaces: - _vlan_mode: irb - ifindex: 7 - ifname: eth7 + ifindex: 5 + ifname: eth5 ipv4: 172.16.0.1/24 node: r vlan: @@ -252,56 +170,8 @@ links: - ifindex: 1 ifname: eth1 ipv4: 172.16.0.3/24 - node: h_02 - linkindex: 12 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[3] - bridge: input_13 - gateway: - ipv4: 172.16.0.1/24 - interfaces: - - _vlan_mode: irb - ifindex: 8 - ifname: eth8 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - - ifindex: 1 - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - linkindex: 13 - node_count: 2 - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 - type: lan - vlan: - access: red -- _linkname: vlans.red.links[4] - bridge: input_14 - gateway: - ipv4: 172.16.0.1/24 - interfaces: - - _vlan_mode: irb - ifindex: 9 - ifname: eth9 - ipv4: 172.16.0.1/24 - node: r - vlan: - access: red - - ifindex: 1 - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 - linkindex: 14 + node: h-07 + linkindex: 8 node_count: 2 prefix: allocation: id_based @@ -310,82 +180,42 @@ links: vlan: access: red - _linkname: vrfs.red.links[1] - bridge: input_15 + bridge: input_9 gateway: - ipv4: 172.16.11.1/24 + ipv4: 172.16.7.1/24 interfaces: - - ifindex: 10 - ifname: eth10 - ipv4: 172.16.11.1/24 + - ifindex: 6 + ifname: eth6 + ipv4: 172.16.7.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.11.2/24 - node: h_01 - linkindex: 15 + ipv4: 172.16.7.2/24 + node: h-03 + linkindex: 9 node_count: 2 prefix: - ipv4: 172.16.11.0/24 + ipv4: 172.16.7.0/24 role: stub type: lan vrf: red - _linkname: vrfs.red.links[2] - bridge: input_16 - gateway: - ipv4: 172.16.12.1/24 - interfaces: - - ifindex: 11 - ifname: eth11 - ipv4: 172.16.12.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.12.3/24 - node: h_02 - linkindex: 16 - node_count: 2 - prefix: - ipv4: 172.16.12.0/24 - role: stub - type: lan - vrf: red -- _linkname: vrfs.red.links[3] - bridge: input_17 - gateway: - ipv4: 172.16.13.1/24 - interfaces: - - ifindex: 12 - ifname: eth12 - ipv4: 172.16.13.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.13.4/24 - node: h_03 - linkindex: 17 - node_count: 2 - prefix: - ipv4: 172.16.13.0/24 - role: stub - type: lan - vrf: red -- _linkname: vrfs.red.links[4] - bridge: input_18 + bridge: input_10 gateway: - ipv4: 172.16.14.1/24 + ipv4: 172.16.8.1/24 interfaces: - - ifindex: 13 - ifname: eth13 - ipv4: 172.16.14.1/24 + - ifindex: 7 + ifname: eth7 + ipv4: 172.16.8.1/24 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.14.5/24 - node: h_04 - linkindex: 18 + ipv4: 172.16.8.3/24 + node: h-07 + linkindex: 10 node_count: 2 prefix: - ipv4: 172.16.14.0/24 + ipv4: 172.16.8.0/24 role: stub type: lan vrf: red @@ -395,47 +225,41 @@ module: - vrf name: input nodes: - h_01: + h-03: af: ipv4: true box: generic/ubuntu2004 device: linux id: 2 interfaces: - - bridge: input_11 + - bridge: input_7 gateway: ipv4: 172.16.0.1/24 ifindex: 1 ifname: eth1 ipv4: 172.16.0.2/24 - linkindex: 11 - name: h_01 -> [r,h_02,h_03,h_04] + linkindex: 7 + name: h-03 -> [r,h-07] neighbors: - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: eth1 ipv4: 172.16.0.3/24 - node: h_02 - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 + node: h-07 role: stub type: lan - - bridge: input_15 + - bridge: input_9 gateway: - ipv4: 172.16.11.1/24 + ipv4: 172.16.7.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.11.2/24 - linkindex: 15 - name: h_01 -> r + ipv4: 172.16.7.2/24 + linkindex: 9 + name: h-03 -> r neighbors: - - ifname: eth10 - ipv4: 172.16.11.1/24 + - ifname: eth6 + ipv4: 172.16.7.1/24 node: r vrf: red role: stub @@ -444,49 +268,43 @@ nodes: ifname: eth0 ipv4: 192.168.121.102 mac: 08:4f:a9:00:00:02 - name: h_01 + name: h-03 role: host - h_02: + h-07: af: ipv4: true box: generic/ubuntu2004 device: linux id: 3 interfaces: - - bridge: input_12 + - bridge: input_8 gateway: ipv4: 172.16.0.1/24 ifindex: 1 ifname: eth1 ipv4: 172.16.0.3/24 - linkindex: 12 - name: h_02 -> [h_01,r,h_03,h_04] + linkindex: 8 + name: h-07 -> [h-03,r] neighbors: - ifname: eth1 ipv4: 172.16.0.2/24 - node: h_01 + node: h-03 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 role: stub type: lan - - bridge: input_16 + - bridge: input_10 gateway: - ipv4: 172.16.12.1/24 + ipv4: 172.16.8.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.12.3/24 - linkindex: 16 - name: h_02 -> r + ipv4: 172.16.8.3/24 + linkindex: 10 + name: h-07 -> r neighbors: - - ifname: eth11 - ipv4: 172.16.12.1/24 + - ifname: eth7 + ipv4: 172.16.8.1/24 node: r vrf: red role: stub @@ -495,111 +313,9 @@ nodes: ifname: eth0 ipv4: 192.168.121.103 mac: 08:4f:a9:00:00:03 - name: h_02 - role: host - h_03: - af: - ipv4: true - box: generic/ubuntu2004 - device: linux - id: 4 - interfaces: - - bridge: input_13 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 1 - ifname: eth1 - ipv4: 172.16.0.4/24 - linkindex: 13 - name: h_03 -> [h_01,r,h_02,h_04] - neighbors: - - ifname: eth1 - ipv4: 172.16.0.2/24 - node: h_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: eth1 - ipv4: 172.16.0.3/24 - node: h_02 - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 - role: stub - type: lan - - bridge: input_17 - gateway: - ipv4: 172.16.13.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.13.4/24 - linkindex: 17 - name: h_03 -> r - neighbors: - - ifname: eth12 - ipv4: 172.16.13.1/24 - node: r - vrf: red - role: stub - type: lan - mgmt: - ifname: eth0 - ipv4: 192.168.121.104 - mac: 08:4f:a9:00:00:04 - name: h_03 - role: host - h_04: - af: - ipv4: true - box: generic/ubuntu2004 - device: linux - id: 5 - interfaces: - - bridge: input_14 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 1 - ifname: eth1 - ipv4: 172.16.0.5/24 - linkindex: 14 - name: h_04 -> [h_01,r,h_02,h_03] - neighbors: - - ifname: eth1 - ipv4: 172.16.0.2/24 - node: h_01 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 - node: r - - ifname: eth1 - ipv4: 172.16.0.3/24 - node: h_02 - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - role: stub - type: lan - - bridge: input_18 - gateway: - ipv4: 172.16.14.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.14.5/24 - linkindex: 18 - name: h_04 -> r - neighbors: - - ifname: eth13 - ipv4: 172.16.14.1/24 - node: r - vrf: red - role: stub - type: lan - mgmt: - ifname: eth0 - ipv4: 192.168.121.105 - mac: 08:4f:a9:00:00:05 - name: h_04 + name: h-07 role: host - host_w_long_n_01: + host_w_long_n-01: af: ipv4: true box: generic/ubuntu2004 @@ -613,25 +329,25 @@ nodes: ifname: eth1 ipv4: 172.16.1.10/24 linkindex: 1 - name: host_w_long_n_01 -> r + name: host_w_long_n-01 -> r neighbors: - ifname: eth1 ipv4: 172.16.1.1/24 node: r role: stub type: lan - - bridge: input_6 + - bridge: input_4 gateway: - ipv4: 172.16.6.1/24 + ipv4: 172.16.4.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.6.10/24 - linkindex: 6 + ipv4: 172.16.4.10/24 + linkindex: 4 mtu: 1600 - name: host_w_long_n_01 -> r + name: host_w_long_n-01 -> r neighbors: - ifname: eth20 - ipv4: 172.16.6.1/24 + ipv4: 172.16.4.1/24 node: r role: stub type: lan @@ -639,9 +355,9 @@ nodes: ifname: eth0 ipv4: 192.168.121.110 mac: 08:4f:a9:00:00:0a - name: host_w_long_n_01 + name: host_w_long_n-01 role: host - host_w_long_n_02: + host_w_long_n-02: af: ipv4: true box: generic/ubuntu2004 @@ -655,25 +371,25 @@ nodes: ifname: eth1 ipv4: 172.16.2.11/24 linkindex: 2 - name: host_w_long_n_02 -> r + name: host_w_long_n-02 -> r neighbors: - ifname: eth2 ipv4: 172.16.2.1/24 node: r role: stub type: lan - - bridge: input_7 + - bridge: input_5 gateway: - ipv4: 172.16.7.1/24 + ipv4: 172.16.5.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.7.11/24 - linkindex: 7 + ipv4: 172.16.5.11/24 + linkindex: 5 mtu: 1600 - name: host_w_long_n_02 -> r + name: host_w_long_n-02 -> r neighbors: - ifname: eth21 - ipv4: 172.16.7.1/24 + ipv4: 172.16.5.1/24 node: r role: stub type: lan @@ -681,9 +397,9 @@ nodes: ifname: eth0 ipv4: 192.168.121.111 mac: 08:4f:a9:00:00:0b - name: host_w_long_n_02 + name: host_w_long_n-02 role: host - host_w_long_n_03: + host_w_long_n-03: af: ipv4: true box: generic/ubuntu2004 @@ -697,25 +413,25 @@ nodes: ifname: eth1 ipv4: 172.16.3.12/24 linkindex: 3 - name: host_w_long_n_03 -> r + name: host_w_long_n-03 -> r neighbors: - ifname: eth3 ipv4: 172.16.3.1/24 node: r role: stub type: lan - - bridge: input_8 + - bridge: input_6 gateway: - ipv4: 172.16.8.1/24 + ipv4: 172.16.6.1/24 ifindex: 2 ifname: eth2 - ipv4: 172.16.8.12/24 - linkindex: 8 + ipv4: 172.16.6.12/24 + linkindex: 6 mtu: 1600 - name: host_w_long_n_03 -> r + name: host_w_long_n-03 -> r neighbors: - ifname: eth22 - ipv4: 172.16.8.1/24 + ipv4: 172.16.6.1/24 node: r role: stub type: lan @@ -723,91 +439,7 @@ nodes: ifname: eth0 ipv4: 192.168.121.112 mac: 08:4f:a9:00:00:0c - name: host_w_long_n_03 - role: host - host_w_long_n_04: - af: - ipv4: true - box: generic/ubuntu2004 - device: linux - id: 13 - interfaces: - - bridge: input_4 - gateway: - ipv4: 172.16.4.1/24 - ifindex: 1 - ifname: eth1 - ipv4: 172.16.4.13/24 - linkindex: 4 - name: host_w_long_n_04 -> r - neighbors: - - ifname: eth4 - ipv4: 172.16.4.1/24 - node: r - role: stub - type: lan - - bridge: input_9 - gateway: - ipv4: 172.16.9.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.9.13/24 - linkindex: 9 - mtu: 1600 - name: host_w_long_n_04 -> r - neighbors: - - ifname: eth23 - ipv4: 172.16.9.1/24 - node: r - role: stub - type: lan - mgmt: - ifname: eth0 - ipv4: 192.168.121.113 - mac: 08:4f:a9:00:00:0d - name: host_w_long_n_04 - role: host - host_w_long_n_05: - af: - ipv4: true - box: generic/ubuntu2004 - device: linux - id: 14 - interfaces: - - bridge: input_5 - gateway: - ipv4: 172.16.5.1/24 - ifindex: 1 - ifname: eth1 - ipv4: 172.16.5.14/24 - linkindex: 5 - name: host_w_long_n_05 -> r - neighbors: - - ifname: eth5 - ipv4: 172.16.5.1/24 - node: r - role: stub - type: lan - - bridge: input_10 - gateway: - ipv4: 172.16.10.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.10.14/24 - linkindex: 10 - mtu: 1600 - name: host_w_long_n_05 -> r - neighbors: - - ifname: eth24 - ipv4: 172.16.10.1/24 - node: r - role: stub - type: lan - mgmt: - ifname: eth0 - ipv4: 192.168.121.114 - mac: 08:4f:a9:00:00:0e - name: host_w_long_n_05 + name: host_w_long_n-03 role: host r: _set_ifindex: true @@ -823,11 +455,11 @@ nodes: ifname: eth1 ipv4: 172.16.1.1/24 linkindex: 1 - name: r -> host_w_long_n_01 + name: r -> host_w_long_n-01 neighbors: - ifname: eth1 ipv4: 172.16.1.10/24 - node: host_w_long_n_01 + node: host_w_long_n-01 role: stub type: lan - bridge: input_2 @@ -835,11 +467,11 @@ nodes: ifname: eth2 ipv4: 172.16.2.1/24 linkindex: 2 - name: r -> host_w_long_n_02 + name: r -> host_w_long_n-02 neighbors: - ifname: eth1 ipv4: 172.16.2.11/24 - node: host_w_long_n_02 + node: host_w_long_n-02 role: stub type: lan - bridge: input_3 @@ -847,165 +479,125 @@ nodes: ifname: eth3 ipv4: 172.16.3.1/24 linkindex: 3 - name: r -> host_w_long_n_03 + name: r -> host_w_long_n-03 neighbors: - ifname: eth1 ipv4: 172.16.3.12/24 - node: host_w_long_n_03 + node: host_w_long_n-03 role: stub type: lan - - bridge: input_4 + - bridge: input_7 ifindex: 4 ifname: eth4 - ipv4: 172.16.4.1/24 - linkindex: 4 - name: r -> host_w_long_n_04 - neighbors: - - ifname: eth1 - ipv4: 172.16.4.13/24 - node: host_w_long_n_04 - role: stub - type: lan - - bridge: input_5 - ifindex: 5 - ifname: eth5 - ipv4: 172.16.5.1/24 - linkindex: 5 - name: r -> host_w_long_n_05 - neighbors: - - ifname: eth1 - ipv4: 172.16.5.14/24 - node: host_w_long_n_05 - role: stub - type: lan - - bridge: input_11 - ifindex: 6 - ifname: eth6 - linkindex: 11 - name: '[Access VLAN red] r -> h_01' + linkindex: 7 + name: '[Access VLAN red] r -> h-03' neighbors: - ifname: eth1 ipv4: 172.16.0.2/24 - node: h_01 + node: h-03 type: lan vlan: access: red access_id: 1000 - - bridge: input_12 - ifindex: 7 - ifname: eth7 - linkindex: 12 - name: '[Access VLAN red] r -> h_02' + - bridge: input_8 + ifindex: 5 + ifname: eth5 + linkindex: 8 + name: '[Access VLAN red] r -> h-07' neighbors: - ifname: eth1 ipv4: 172.16.0.3/24 - node: h_02 - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_13 - ifindex: 8 - ifname: eth8 - linkindex: 13 - name: '[Access VLAN red] r -> h_03' - neighbors: - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - type: lan - vlan: - access: red - access_id: 1000 - - bridge: input_14 - ifindex: 9 - ifname: eth9 - linkindex: 14 - name: '[Access VLAN red] r -> h_04' - neighbors: - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 + node: h-07 type: lan vlan: access: red access_id: 1000 - - bridge: input_15 - ifindex: 10 - ifname: eth10 - ipv4: 172.16.11.1/24 - linkindex: 15 - name: r -> h_01 - neighbors: - - ifname: eth2 - ipv4: 172.16.11.2/24 - node: h_01 - role: stub - type: lan - vrf: red - - bridge: input_16 - ifindex: 11 - ifname: eth11 - ipv4: 172.16.12.1/24 - linkindex: 16 - name: r -> h_02 - neighbors: - - ifname: eth2 - ipv4: 172.16.12.3/24 - node: h_02 - role: stub - type: lan - vrf: red - - bridge: input_17 - ifindex: 12 - ifname: eth12 - ipv4: 172.16.13.1/24 - linkindex: 17 - name: r -> h_03 + - bridge: input_9 + ifindex: 6 + ifname: eth6 + ipv4: 172.16.7.1/24 + linkindex: 9 + name: r -> h-03 neighbors: - ifname: eth2 - ipv4: 172.16.13.4/24 - node: h_03 + ipv4: 172.16.7.2/24 + node: h-03 role: stub type: lan vrf: red - - bridge: input_18 - ifindex: 13 - ifname: eth13 - ipv4: 172.16.14.1/24 - linkindex: 18 - name: r -> h_04 + - bridge: input_10 + ifindex: 7 + ifname: eth7 + ipv4: 172.16.8.1/24 + linkindex: 10 + name: r -> h-07 neighbors: - ifname: eth2 - ipv4: 172.16.14.5/24 - node: h_04 + ipv4: 172.16.8.3/24 + node: h-07 role: stub type: lan vrf: red - bridge_group: 1 - ifindex: 14 + ifindex: 8 ifname: vlan1000 ipv4: 172.16.0.1/24 - name: VLAN red (1000) -> [h_01,h_02,h_03,h_04] + name: VLAN red (1000) -> [h-03,h-07] neighbors: - ifname: eth1 ipv4: 172.16.0.2/24 - node: h_01 + node: h-03 - ifname: eth1 ipv4: 172.16.0.3/24 - node: h_02 - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 + node: h-07 role: stub type: svi virtual_interface: true vlan: mode: irb name: red + - ifindex: 9 + ifname: eth9 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 10 + ifname: eth10 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 11 + ifname: eth11 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 12 + ifname: eth12 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 13 + ifname: eth13 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p + - ifindex: 14 + ifname: eth14 + linkindex: 0 + neighbors: [] + remote_id: 1 + remote_ifindex: 666 + type: p2p - ifindex: 15 ifname: eth15 linkindex: 0 @@ -1041,64 +633,40 @@ nodes: remote_id: 1 remote_ifindex: 666 type: p2p - - bridge: input_6 + - bridge: input_4 ifindex: 20 ifname: eth20 - ipv4: 172.16.6.1/24 - linkindex: 6 - name: r -> host_w_long_n_01 + ipv4: 172.16.4.1/24 + linkindex: 4 + name: r -> host_w_long_n-01 neighbors: - ifname: eth2 - ipv4: 172.16.6.10/24 - node: host_w_long_n_01 + ipv4: 172.16.4.10/24 + node: host_w_long_n-01 role: stub type: lan - - bridge: input_7 + - bridge: input_5 ifindex: 21 ifname: eth21 - ipv4: 172.16.7.1/24 - linkindex: 7 - name: r -> host_w_long_n_02 + ipv4: 172.16.5.1/24 + linkindex: 5 + name: r -> host_w_long_n-02 neighbors: - ifname: eth2 - ipv4: 172.16.7.11/24 - node: host_w_long_n_02 + ipv4: 172.16.5.11/24 + node: host_w_long_n-02 role: stub type: lan - - bridge: input_8 + - bridge: input_6 ifindex: 22 ifname: eth22 - ipv4: 172.16.8.1/24 - linkindex: 8 - name: r -> host_w_long_n_03 - neighbors: - - ifname: eth2 - ipv4: 172.16.8.12/24 - node: host_w_long_n_03 - role: stub - type: lan - - bridge: input_9 - ifindex: 23 - ifname: eth23 - ipv4: 172.16.9.1/24 - linkindex: 9 - name: r -> host_w_long_n_04 - neighbors: - - ifname: eth2 - ipv4: 172.16.9.13/24 - node: host_w_long_n_04 - role: stub - type: lan - - bridge: input_10 - ifindex: 24 - ifname: eth24 - ipv4: 172.16.10.1/24 - linkindex: 10 - name: r -> host_w_long_n_05 + ipv4: 172.16.6.1/24 + linkindex: 6 + name: r -> host_w_long_n-03 neighbors: - ifname: eth2 - ipv4: 172.16.10.14/24 - node: host_w_long_n_05 + ipv4: 172.16.6.12/24 + node: host_w_long_n-03 role: stub type: lan lag: @@ -1106,7 +674,7 @@ nodes: lacp_mode: active mode: 802.3ad libvirt: - nic_adapter_count: 25 + nic_adapter_count: 23 loopback: ifindex: 0 ifname: lo @@ -1151,24 +719,18 @@ plugin: provider: libvirt vlans: red: - host_count: 4 + host_count: 2 id: 1000 neighbors: - ifname: eth1 ipv4: 172.16.0.2/24 - node: h_01 + node: h-03 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - ifname: eth1 ipv4: 172.16.0.3/24 - node: h_02 - - ifname: eth1 - ipv4: 172.16.0.4/24 - node: h_03 - - ifname: eth1 - ipv4: 172.16.0.5/24 - node: h_04 + node: h-07 prefix: allocation: id_based ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/node.clone-plugin.yml b/tests/topology/input/node.clone-plugin.yml index e9dc088d7..5edd3774c 100644 --- a/tests/topology/input/node.clone-plugin.yml +++ b/tests/topology/input/node.clone-plugin.yml @@ -22,7 +22,10 @@ nodes: h: # Short name, regular test device: linux - clone.count: 2 + clone: + count: 2 + start: 3 # Create h-03 and h-07 + step: 4 host_w_long_name: # Test that node names get shortened to at most 16 chars device: linux From a32130ac02df7bf926cd8c06edd71b25687dc55c Mon Sep 17 00:00:00 2001 From: J vanBemmel Date: Mon, 9 Dec 2024 11:34:02 -0600 Subject: [PATCH 13/19] Resolve feedback * implement separate 'process_links' * don't treat clone 1 different * use proper name prefix for cloned links * rename 'clone_interfaces' --- netsim/extra/node.clone/plugin.py | 88 ++++++++++++++----------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index c43471138..21266a67a 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -3,8 +3,8 @@ from netsim.utils import log,strings from netsim.augment import links -def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: - ifs = [] +def clone_link(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: + cloned_links = [] if nodename in [ i.node for i in link_data.get('interfaces',[]) ]: for c,clone in enumerate(clones): l = data.get_box(link_data) @@ -16,29 +16,38 @@ def clone_interfaces(link_data: Box, nodename: str, clones: list[str]) -> list[B elif 'ifindex' in intf: intf_clone.ifindex = intf.ifindex + c l.interfaces.append(intf_clone) - ifs.append(l) - return ifs + cloned_links.append(l) + return cloned_links """ -update_links - updates 'links' lists in VLAN and VRF objects +process_links - iterate over the 'links' attribute for the given item and clone any instances that involve node + can be the global topology or a VLAN or VRF object with 'links' """ -def update_links(topo_items: Box, nodename: str, clones: list, topology: Box) -> None: - for vname,vdata in topo_items.items(): # Iterate over global VLANs or VRFs - if not isinstance(vdata,Box): # VLAN not yet a dictionary? - continue # ... no problem, skip it - if not 'links' in vdata: # No VLAN links? - continue # ... no problem, move on +def process_links(item: Box, linkprefix: str, nodename: str, clones: list, topology: Box) -> None: + for cnt,l in enumerate(list(item.links)): + link_data = links.adjust_link_object( # Create link data from link definition + l=l, + linkname=f'{linkprefix}.links[{cnt+1}]', + nodes=topology.nodes) + if link_data is None: + continue + elif 'lag' in link_data: + log.error(f"LAG links not yet supported by node.clone plugin, not cloning any members containing {nodename}", + category=Warning, module='node.clone') + continue + + cloned_links = clone_link(link_data,nodename,clones) + if cloned_links: + item.links.remove(l) + item.links += cloned_links - for cnt,l in enumerate(list(vdata.links)): # So far so good, now iterate over the links - link_data = links.adjust_link_object( # Create link data from link definition - l=l, - linkname=f'vlans.{vname}.links[{cnt+1}]', - nodes=topology.nodes) - if link_data is not None: - ifs = clone_interfaces(link_data,nodename,clones) - if ifs: - vdata.links.remove(l) - vdata.links += ifs +""" +update_links - updates 'links' lists in VLAN and VRF objects +""" +def update_links(topo_items: str, nodename: str, clones: list, topology: Box) -> None: + for vname,vdata in topology[topo_items].items(): # Iterate over global VLANs or VRFs + if isinstance(vdata,Box) and 'links' in vdata: + process_links(vdata,f'{topo_items}.{vname}',nodename,clones,topology) """ clone_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes @@ -56,49 +65,34 @@ def clone_node(node: Box, topology: Box) -> None: return name_format = topology.defaults.clone.node_name_pattern - - orig_name = node.name - node.name = strings.eval_format(name_format, node + { 'id': _p.start } ) # Rename first node as clone_01 - topology.nodes += { node.name: node } - - clones = [ node.name ] - for c in range(_p.start+_p.step,_p.start+_p.count*_p.step,_p.step): # Existing node is '1' + clones = [] + for c in range(_p.start,_p.start+_p.count*_p.step,_p.step): clone = data.get_box(node) - clone.name = strings.eval_format(name_format, node + { 'id': c, 'name': orig_name } ) + clone.name = strings.eval_format(name_format, node + { 'id': c } ) clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: clone.id = node.id + c - 1 # Update any explicit node ID sequentially - topology.nodes += { clone.name: clone } + topology.nodes[ clone.name ] = clone clones.append( clone.name ) - for link in list(topology.get('links',[])): # Make a copy of links list - link_data = links.adjust_link_object(link,f'clone[{orig_name}]',topology.nodes) - if link_data is None: - continue - if 'lag' in link_data: - log.error("LAG links not yet supported by node.clone plugin", - category=AttributeError, module='node.clone') - continue - ifs = clone_interfaces(link_data,orig_name,clones) - if ifs: - topology.links.remove(link) # Remove the original link - topology.links += ifs + if 'links' in topology: + process_links(topology,'links',node.name,clones,topology) if 'groups' in topology: for groupname,gdata in topology.groups.items(): if groupname[0]=='_': # Skip flags and other special items continue - if orig_name in gdata.get('members',[]): - gdata.members.remove( orig_name ) + if node.name in gdata.get('members',[]): + gdata.members.remove( node.name ) gdata.members.extend( clones ) if 'vlans' in topology: - update_links(topology.vlans,orig_name,clones,topology) + update_links('vlans',node.name,clones,topology) if 'vrfs' in topology: - update_links(topology.vrfs,orig_name,clones,topology) + update_links('vrfs',node.name,clones,topology) - topology.nodes.pop(orig_name,None) # Finally + topology.nodes.pop(node.name,None) # Finally """ topology_expand - Main plugin function, expands the topology with cloned nodes and interfaces From 3860f75fab63613e6cead804b64103bc961db8d3 Mon Sep 17 00:00:00 2001 From: J vanBemmel Date: Mon, 9 Dec 2024 11:41:38 -0600 Subject: [PATCH 14/19] Fix prefix string, whitespace --- netsim/extra/node.clone/plugin.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index 21266a67a..cf80cc0f7 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -25,9 +25,9 @@ def clone_link(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: """ def process_links(item: Box, linkprefix: str, nodename: str, clones: list, topology: Box) -> None: for cnt,l in enumerate(list(item.links)): - link_data = links.adjust_link_object( # Create link data from link definition + link_data = links.adjust_link_object( # Create link data from link definition l=l, - linkname=f'{linkprefix}.links[{cnt+1}]', + linkname=f'{linkprefix}links[{cnt+1}]', nodes=topology.nodes) if link_data is None: continue @@ -47,7 +47,7 @@ def process_links(item: Box, linkprefix: str, nodename: str, clones: list, topol def update_links(topo_items: str, nodename: str, clones: list, topology: Box) -> None: for vname,vdata in topology[topo_items].items(): # Iterate over global VLANs or VRFs if isinstance(vdata,Box) and 'links' in vdata: - process_links(vdata,f'{topo_items}.{vname}',nodename,clones,topology) + process_links(vdata,f'{topo_items}.{vname}.',nodename,clones,topology) """ clone_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes @@ -69,18 +69,18 @@ def clone_node(node: Box, topology: Box) -> None: for c in range(_p.start,_p.start+_p.count*_p.step,_p.step): clone = data.get_box(node) clone.name = strings.eval_format(name_format, node + { 'id': c } ) - clone.interfaces = [] # Start clean, remove reference to original node + clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: - clone.id = node.id + c - 1 # Update any explicit node ID sequentially + clone.id = node.id + c - 1 # Update any explicit node ID sequentially topology.nodes[ clone.name ] = clone clones.append( clone.name ) if 'links' in topology: - process_links(topology,'links',node.name,clones,topology) + process_links(topology,"",node.name,clones,topology) if 'groups' in topology: for groupname,gdata in topology.groups.items(): - if groupname[0]=='_': # Skip flags and other special items + if groupname[0]=='_': # Skip flags and other special items continue if node.name in gdata.get('members',[]): gdata.members.remove( node.name ) @@ -92,7 +92,7 @@ def clone_node(node: Box, topology: Box) -> None: if 'vrfs' in topology: update_links('vrfs',node.name,clones,topology) - topology.nodes.pop(node.name,None) # Finally + topology.nodes.pop(node.name,None) # Finally """ topology_expand - Main plugin function, expands the topology with cloned nodes and interfaces From 01e30ddcfe1142991d73e432ef12ba014d429d95 Mon Sep 17 00:00:00 2001 From: J vanBemmel Date: Mon, 9 Dec 2024 12:34:56 -0600 Subject: [PATCH 15/19] Update FRR box value --- tests/topology/expected/node.clone-plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml index 47c97cee4..17e22245f 100644 --- a/tests/topology/expected/node.clone-plugin.yml +++ b/tests/topology/expected/node.clone-plugin.yml @@ -446,7 +446,7 @@ nodes: af: ipv4: true vpnv4: true - box: generic/ubuntu2004 + box: debian/bookworm64 device: frr id: 1 interfaces: From 8218aade2d6ef4eaa2eb9c18a1a776111f6cb60e Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Mon, 9 Dec 2024 22:32:59 -0600 Subject: [PATCH 16/19] * Add lag support --- docs/plugins/node.clone.md | 5 +- netsim/extra/node.clone/plugin.py | 54 +- .../expected/node.clone-plugin-lag.yml | 886 ++++++++++++++ tests/topology/expected/node.clone-plugin.yml | 1058 ++++++++++++----- tests/topology/input/lag-mlag.yml | 4 +- .../topology/input/node.clone-plugin-lag.yml | 43 + tests/topology/input/node.clone-plugin.yml | 18 +- 7 files changed, 1744 insertions(+), 324 deletions(-) create mode 100644 tests/topology/expected/node.clone-plugin-lag.yml create mode 100644 tests/topology/input/node.clone-plugin-lag.yml diff --git a/docs/plugins/node.clone.md b/docs/plugins/node.clone.md index 2a8c8e0e6..82e70c055 100644 --- a/docs/plugins/node.clone.md +++ b/docs/plugins/node.clone.md @@ -19,8 +19,8 @@ The plugin is invoked early in the _netlab_ topology transformation process and ### Supported attributes -The naming of cloned nodes can be controlled through global **clone.node_name_pattern**, default "{name[:13]}_{id:02d}". -It is recommended to ensure this generates valid identifiers (of max length 16) +The naming of cloned nodes can be controlled through global **clone.node_name_pattern**, default "{name[:13]}-{id:02d}". +When customizing, it is recommended to ensure this generates valid DNS hostnames (of max length 16) The plugin adds the following node attributes: * **clone.count** is a required int (>0) that defines the number of clones to create @@ -30,7 +30,6 @@ The plugin adds the following node attributes: ### Caveats The plugin does not support: -* *lag* module links * link groups * cloning of components (nodes composed of multiple nodes) diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index cf80cc0f7..95b0c0312 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -3,6 +3,9 @@ from netsim.utils import log,strings from netsim.augment import links +""" +clone_link - makes a copy of the given link for each clone, updating its node +""" def clone_link(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: cloned_links = [] if nodename in [ i.node for i in link_data.get('interfaces',[]) ]: @@ -13,33 +16,60 @@ def clone_link(link_data: Box, nodename: str, clones: list[str]) -> list[Box]: intf_clone = data.get_box(intf) if intf.node == nodename: intf_clone.node = clone - elif 'ifindex' in intf: + elif 'ifindex' in intf: # Update port on the peer side, if any intf_clone.ifindex = intf.ifindex + c l.interfaces.append(intf_clone) cloned_links.append(l) return cloned_links +""" +clone_lag - special routine to handle cloning of lag links +""" +def clone_lag(cnt: int, link_data: Box, nodename: str, clones: list[str], topology: Box) -> list[Box]: + lag_members = link_data.get('lag.members') + cloned_members = process_links(lag_members,f"lag[{cnt+1}].m",nodename,clones,topology) + if not cloned_members: # If no lag members involve + return [] # .. exit + + cloned_lag_links = [] + for c,clone in enumerate(clones): + l = data.get_box(link_data) # Clone the lag link + if l.get('lag.ifindex',0): + l.lag.ifindex = l.lag.ifindex + c # Update its ifindex, if any + l.lag.members = [] + for clonelist in cloned_members: + for intf in clonelist[c].interfaces: # Update ifindex on interfaces + if 'ifindex' in intf: + intf.ifindex += c + l.lag.members.append( clonelist[c] ) + cloned_lag_links.append(l) + return cloned_lag_links + """ process_links - iterate over the 'links' attribute for the given item and clone any instances that involve node can be the global topology or a VLAN or VRF object with 'links' + + Returns a list of a list of cloned links """ -def process_links(item: Box, linkprefix: str, nodename: str, clones: list, topology: Box) -> None: - for cnt,l in enumerate(list(item.links)): +def process_links(linkitems: list, linkprefix: str, nodename: str, clones: list, topology: Box) -> list[list[Box]]: + result: list[list[Box]] = [] + for cnt,l in enumerate(list(linkitems)): link_data = links.adjust_link_object( # Create link data from link definition l=l, linkname=f'{linkprefix}links[{cnt+1}]', nodes=topology.nodes) if link_data is None: continue - elif 'lag' in link_data: - log.error(f"LAG links not yet supported by node.clone plugin, not cloning any members containing {nodename}", - category=Warning, module='node.clone') - continue + elif link_data.get('lag.members',None): + cloned_links = clone_lag(cnt,link_data,nodename,clones,topology) + else: + cloned_links = clone_link(link_data,nodename,clones) - cloned_links = clone_link(link_data,nodename,clones) if cloned_links: - item.links.remove(l) - item.links += cloned_links + linkitems.remove(l) + linkitems += cloned_links + result.append(cloned_links) + return result """ update_links - updates 'links' lists in VLAN and VRF objects @@ -47,7 +77,7 @@ def process_links(item: Box, linkprefix: str, nodename: str, clones: list, topol def update_links(topo_items: str, nodename: str, clones: list, topology: Box) -> None: for vname,vdata in topology[topo_items].items(): # Iterate over global VLANs or VRFs if isinstance(vdata,Box) and 'links' in vdata: - process_links(vdata,f'{topo_items}.{vname}.',nodename,clones,topology) + process_links(vdata.links,f'{topo_items}.{vname}.',nodename,clones,topology) """ clone_node - Clones a given node N times, creating additional links and/or interfaces for the new nodes @@ -76,7 +106,7 @@ def clone_node(node: Box, topology: Box) -> None: clones.append( clone.name ) if 'links' in topology: - process_links(topology,"",node.name,clones,topology) + process_links(topology.links,"",node.name,clones,topology) if 'groups' in topology: for groupname,gdata in topology.groups.items(): diff --git a/tests/topology/expected/node.clone-plugin-lag.yml b/tests/topology/expected/node.clone-plugin-lag.yml new file mode 100644 index 000000000..51f4f4fef --- /dev/null +++ b/tests/topology/expected/node.clone-plugin-lag.yml @@ -0,0 +1,886 @@ +groups: + routers: + device: eos + members: + - r1 + - r2 + module: + - vlan + - lag +input: +- topology/input/node.clone-plugin-lag.yml +- package:topology-defaults.yml +lag: + lacp: fast + lacp_mode: active + mode: 802.3ad +links: +- _linkname: links[1].peerlink[1] + interfaces: + - ifindex: 1 + ifname: Ethernet1 + node: r1 + - ifindex: 1 + ifname: Ethernet1 + node: r2 + lag: + mlag: + peergroup: 1 + linkindex: 1 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[2] + bridge: input_2 + interfaces: + - ifindex: 30000 + ifname: port-channel5 + node: r1 + - ifindex: 30000 + ifname: bond5 + node: h-01 + lag: + ifindex: 5 + linkindex: 2 + node_count: 2 + pool: l2only + type: lag +- _linkname: links[3] + bridge: input_3 + interfaces: + - ifindex: 30001 + ifname: port-channel6 + node: r1 + - ifindex: 30000 + ifname: bond6 + node: h-02 + lag: + ifindex: 6 + linkindex: 3 + node_count: 2 + pool: l2only + type: lag +- _linkname: links[4] + bridge: input_4 + interfaces: + - _vlan_mode: irb + ifindex: 30001 + ifname: bond1 + ipv4: 172.16.0.3/24 + lag: + ifindex: 1 + node: h-01 + vlan: + access: red + - _vlan_mode: irb + ifindex: 30002 + ifname: port-channel1 + ipv4: 172.16.0.1/24 + lag: + _mlag: true + node: r1 + vlan: + access: red + - _vlan_mode: irb + ifindex: 30000 + ifname: port-channel1 + ipv4: 172.16.0.2/24 + lag: + _mlag: true + node: r2 + vlan: + access: red + lag: + ifindex: 1 + linkindex: 4 + node_count: 3 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lag + vlan: + access: red +- _linkname: links[5] + bridge: input_5 + interfaces: + - _vlan_mode: irb + ifindex: 30001 + ifname: bond1 + ipv4: 172.16.0.4/24 + lag: + ifindex: 1 + node: h-02 + vlan: + access: red + - _vlan_mode: irb + ifindex: 30003 + ifname: port-channel2 + ipv4: 172.16.0.1/24 + lag: + _mlag: true + node: r1 + vlan: + access: red + - _vlan_mode: irb + ifindex: 30001 + ifname: port-channel2 + ipv4: 172.16.0.2/24 + lag: + _mlag: true + node: r2 + vlan: + access: red + lag: + ifindex: 2 + linkindex: 5 + node_count: 3 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + type: lag + vlan: + access: red +- _linkname: links[2].lag[1] + interfaces: + - ifindex: 2 + ifname: Ethernet2 + node: r1 + - ifindex: 1 + ifname: eth1 + node: h-01 + lag: + _parentindex: 2 + linkindex: 6 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[2].lag[2] + interfaces: + - ifindex: 3 + ifname: Ethernet3 + node: r1 + - ifindex: 2 + ifname: eth2 + node: h-01 + lag: + _parentindex: 2 + linkindex: 7 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[3].lag[1] + interfaces: + - ifindex: 4 + ifname: Ethernet4 + node: r1 + - ifindex: 1 + ifname: eth1 + node: h-02 + lag: + _parentindex: 3 + linkindex: 8 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[3].lag[2] + interfaces: + - ifindex: 5 + ifname: Ethernet5 + node: r1 + - ifindex: 2 + ifname: eth2 + node: h-02 + lag: + _parentindex: 3 + linkindex: 9 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[4].lag[1] + interfaces: + - ifindex: 3 + ifname: eth3 + node: h-01 + - ifindex: 6 + ifname: Ethernet6 + node: r1 + lag: + _parentindex: 4 + linkindex: 10 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[4].lag[2] + interfaces: + - ifindex: 4 + ifname: eth4 + node: h-01 + - ifindex: 2 + ifname: Ethernet2 + node: r2 + lag: + _parentindex: 4 + linkindex: 11 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[5].lag[1] + interfaces: + - ifindex: 3 + ifname: eth3 + node: h-02 + - ifindex: 7 + ifname: Ethernet7 + node: r1 + lag: + _parentindex: 5 + linkindex: 12 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[5].lag[2] + interfaces: + - ifindex: 4 + ifname: eth4 + node: h-02 + - ifindex: 3 + ifname: Ethernet3 + node: r2 + lag: + _parentindex: 5 + linkindex: 13 + node_count: 2 + prefix: false + type: p2p +module: +- lag +- vlan +name: input +nodes: + h-01: + af: + ipv4: true + box: debian/bookworm64 + device: frr + id: 3 + interfaces: + - ifindex: 30000 + ifname: bond5 + lag: + ifindex: 5 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 2 + name: h-01 -> r1 + neighbors: + - ifname: port-channel5 + node: r1 + pool: l2only + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: bond1 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 4 + name: '[Access VLAN red] h-01 -> [r1,r2]' + neighbors: + - ifname: port-channel1 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: port-channel1 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 1 + ifname: eth1 + lag: + _parentindex: 2 + linkindex: 6 + name: h-01 -> r1 + neighbors: + - ifname: Ethernet2 + node: r1 + type: p2p + - ifindex: 2 + ifname: eth2 + lag: + _parentindex: 2 + linkindex: 7 + name: h-01 -> r1 + neighbors: + - ifname: Ethernet3 + node: r1 + type: p2p + - ifindex: 3 + ifname: eth3 + lag: + _parentindex: 4 + linkindex: 10 + name: h-01 -> r1 + neighbors: + - ifname: Ethernet6 + node: r1 + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 4 + linkindex: 11 + name: h-01 -> r2 + neighbors: + - ifname: Ethernet2 + node: r2 + type: p2p + - bridge_group: 1 + ifindex: 5 + ifname: vlan1000 + ipv4: 172.16.0.3/24 + name: VLAN red (1000) -> [r2,r1,h-02] + neighbors: + - ifname: Vlan1000 + ipv4: 172.16.0.2/24 + node: r2 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-02 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.3/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.103 + mac: 08:4f:a9:00:00:03 + module: + - lag + - vlan + name: h-01 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + h-02: + af: + ipv4: true + box: debian/bookworm64 + device: frr + id: 4 + interfaces: + - ifindex: 30000 + ifname: bond6 + lag: + ifindex: 6 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: h-02 -> r1 + neighbors: + - ifname: port-channel6 + node: r1 + pool: l2only + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: bond1 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 5 + name: '[Access VLAN red] h-02 -> [r1,r2]' + neighbors: + - ifname: port-channel2 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: port-channel2 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 1 + ifname: eth1 + lag: + _parentindex: 3 + linkindex: 8 + name: h-02 -> r1 + neighbors: + - ifname: Ethernet4 + node: r1 + type: p2p + - ifindex: 2 + ifname: eth2 + lag: + _parentindex: 3 + linkindex: 9 + name: h-02 -> r1 + neighbors: + - ifname: Ethernet5 + node: r1 + type: p2p + - ifindex: 3 + ifname: eth3 + lag: + _parentindex: 5 + linkindex: 12 + name: h-02 -> r1 + neighbors: + - ifname: Ethernet7 + node: r1 + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 5 + linkindex: 13 + name: h-02 -> r2 + neighbors: + - ifname: Ethernet3 + node: r2 + type: p2p + - bridge_group: 1 + ifindex: 5 + ifname: vlan1000 + ipv4: 172.16.0.4/24 + name: VLAN red (1000) -> [h-01,r2,r1] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: Vlan1000 + ipv4: 172.16.0.2/24 + node: r2 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.4/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.104 + mac: 08:4f:a9:00:00:04 + module: + - lag + - vlan + name: h-02 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + r1: + af: + ipv4: true + box: arista/veos + device: eos + id: 1 + interfaces: + - ifindex: 1 + ifname: Ethernet1 + lag: + mlag: + ifindex: 4094 + peer: 169.254.127.0 + peergroup: 1 + self: 169.254.127.1/31 + vlan: 4094 + linkindex: 1 + name: r1 -> r2 + neighbors: + - ifname: Ethernet1 + node: r2 + type: p2p + - ifindex: 30000 + ifname: port-channel5 + lag: + ifindex: 5 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 2 + name: r1 -> h-01 + neighbors: + - ifname: bond5 + node: h-01 + pool: l2only + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: port-channel6 + lag: + ifindex: 6 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: r1 -> h-02 + neighbors: + - ifname: bond6 + node: h-02 + pool: l2only + type: lag + virtual_interface: true + - ifindex: 30002 + ifname: port-channel1 + lag: + _mlag: true + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 4 + name: '[Access VLAN red] r1 -> [h-01,r2]' + neighbors: + - ifname: bond1 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: port-channel1 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 30003 + ifname: port-channel2 + lag: + _mlag: true + ifindex: 2 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 5 + name: '[Access VLAN red] r1 -> [h-02,r2]' + neighbors: + - ifname: bond1 + ipv4: 172.16.0.4/24 + node: h-02 + - ifname: port-channel2 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 2 + ifname: Ethernet2 + lag: + _parentindex: 2 + linkindex: 6 + name: r1 -> h-01 + neighbors: + - ifname: eth1 + node: h-01 + type: p2p + - ifindex: 3 + ifname: Ethernet3 + lag: + _parentindex: 2 + linkindex: 7 + name: r1 -> h-01 + neighbors: + - ifname: eth2 + node: h-01 + type: p2p + - ifindex: 4 + ifname: Ethernet4 + lag: + _parentindex: 3 + linkindex: 8 + name: r1 -> h-02 + neighbors: + - ifname: eth1 + node: h-02 + type: p2p + - ifindex: 5 + ifname: Ethernet5 + lag: + _parentindex: 3 + linkindex: 9 + name: r1 -> h-02 + neighbors: + - ifname: eth2 + node: h-02 + type: p2p + - ifindex: 6 + ifname: Ethernet6 + lag: + _parentindex: 4 + linkindex: 10 + name: r1 -> h-01 + neighbors: + - ifname: eth3 + node: h-01 + type: p2p + - ifindex: 7 + ifname: Ethernet7 + lag: + _parentindex: 5 + linkindex: 12 + name: r1 -> h-02 + neighbors: + - ifname: eth3 + node: h-02 + type: p2p + - bridge_group: 1 + ifindex: 8 + ifname: Vlan1000 + ipv4: 172.16.0.1/24 + name: VLAN red (1000) -> [h-01,r2,h-02] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: Vlan1000 + ipv4: 172.16.0.2/24 + node: r2 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-02 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: Loopback0 + ipv4: 10.0.0.1/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: Management1 + ipv4: 192.168.121.101 + mac: 08:4f:a9:00:00:01 + module: + - lag + - vlan + name: r1 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + r2: + af: + ipv4: true + box: arista/veos + device: eos + id: 2 + interfaces: + - ifindex: 1 + ifname: Ethernet1 + lag: + mlag: + ifindex: 4094 + peer: 169.254.127.1 + peergroup: 1 + self: 169.254.127.0/31 + vlan: 4094 + linkindex: 1 + name: r2 -> r1 + neighbors: + - ifname: Ethernet1 + node: r1 + type: p2p + - ifindex: 30000 + ifname: port-channel1 + lag: + _mlag: true + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 4 + name: '[Access VLAN red] r2 -> [h-01,r1]' + neighbors: + - ifname: bond1 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: port-channel1 + ipv4: 172.16.0.1/24 + node: r1 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 30001 + ifname: port-channel2 + lag: + _mlag: true + ifindex: 2 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 5 + name: '[Access VLAN red] r2 -> [h-02,r1]' + neighbors: + - ifname: bond1 + ipv4: 172.16.0.4/24 + node: h-02 + - ifname: port-channel2 + ipv4: 172.16.0.1/24 + node: r1 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 2 + ifname: Ethernet2 + lag: + _parentindex: 4 + linkindex: 11 + name: r2 -> h-01 + neighbors: + - ifname: eth4 + node: h-01 + type: p2p + - ifindex: 3 + ifname: Ethernet3 + lag: + _parentindex: 5 + linkindex: 13 + name: r2 -> h-02 + neighbors: + - ifname: eth4 + node: h-02 + type: p2p + - bridge_group: 1 + ifindex: 4 + ifname: Vlan1000 + ipv4: 172.16.0.2/24 + name: VLAN red (1000) -> [h-01,r1,h-02] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-02 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: Loopback0 + ipv4: 10.0.0.2/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: Management1 + ipv4: 192.168.121.102 + mac: 08:4f:a9:00:00:02 + module: + - lag + - vlan + name: r2 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 +plugin: +- node.clone +provider: libvirt +vlans: + red: + host_count: 0 + id: 1000 + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-01 + - ifname: Vlan1000 + ipv4: 172.16.0.2/24 + node: r2 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: vlan1000 + ipv4: 172.16.0.4/24 + node: h-02 + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 diff --git a/tests/topology/expected/node.clone-plugin.yml b/tests/topology/expected/node.clone-plugin.yml index 17e22245f..0b356a9f1 100644 --- a/tests/topology/expected/node.clone-plugin.yml +++ b/tests/topology/expected/node.clone-plugin.yml @@ -15,7 +15,111 @@ lag: mode: 802.3ad links: - _linkname: links[1] - bridge: input_1 + interfaces: + - ifindex: 16 + ifname: eth16 + ipv4: 10.1.0.2/30 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.1/30 + mtu: 1600 + node: h-03 + linkindex: 1 + node_count: 2 + prefix: + ipv4: 10.1.0.0/30 + type: p2p +- _linkname: links[2] + interfaces: + - ifindex: 17 + ifname: eth17 + ipv4: 10.1.0.6/30 + node: r + - ifindex: 1 + ifname: eth1 + ipv4: 10.1.0.5/30 + mtu: 1600 + node: h-07 + linkindex: 2 + node_count: 2 + prefix: + ipv4: 10.1.0.4/30 + type: p2p +- _linkname: links[3] + bridge: input_3 + interfaces: + - ifindex: 30000 + ifname: bond5 + ipv4: 10.1.0.9/30 + node: r + - ifindex: 30000 + ifname: bond5 + ipv4: 10.1.0.10/30 + node: h-03 + lag: + ifindex: 5 + linkindex: 3 + node_count: 2 + prefix: + ipv4: 10.1.0.8/30 + type: lag +- _linkname: links[4] + bridge: input_4 + interfaces: + - ifindex: 30001 + ifname: bond6 + ipv4: 10.1.0.13/30 + node: r + - ifindex: 30000 + ifname: bond6 + ipv4: 10.1.0.14/30 + node: h-07 + lag: + ifindex: 6 + linkindex: 4 + node_count: 2 + prefix: + ipv4: 10.1.0.12/30 + type: lag +- _linkname: links[5] + bridge: input_5 + interfaces: + - ifindex: 30002 + ifname: bond1 + ipv4: 10.1.0.17/30 + node: r + - ifindex: 30001 + ifname: bond1 + ipv4: 10.1.0.18/30 + node: h-03 + lag: + ifindex: 1 + linkindex: 5 + node_count: 2 + prefix: + ipv4: 10.1.0.16/30 + type: lag +- _linkname: links[6] + bridge: input_6 + interfaces: + - ifindex: 30003 + ifname: bond2 + ipv4: 10.1.0.21/30 + node: r + - ifindex: 30001 + ifname: bond2 + ipv4: 10.1.0.22/30 + node: h-07 + lag: + ifindex: 2 + linkindex: 6 + node_count: 2 + prefix: + ipv4: 10.1.0.20/30 + type: lag +- _linkname: links[7] + bridge: input_7 gateway: ipv4: 172.16.1.1/24 interfaces: @@ -27,14 +131,14 @@ links: ifname: eth1 ipv4: 172.16.1.10/24 node: host_w_long_n-01 - linkindex: 1 + linkindex: 7 node_count: 2 prefix: ipv4: 172.16.1.0/24 role: stub type: lan -- _linkname: links[2] - bridge: input_2 +- _linkname: links[8] + bridge: input_8 gateway: ipv4: 172.16.2.1/24 interfaces: @@ -46,14 +150,14 @@ links: ifname: eth1 ipv4: 172.16.2.11/24 node: host_w_long_n-02 - linkindex: 2 + linkindex: 8 node_count: 2 prefix: ipv4: 172.16.2.0/24 role: stub type: lan -- _linkname: links[3] - bridge: input_3 +- _linkname: links[9] + bridge: input_9 gateway: ipv4: 172.16.3.1/24 interfaces: @@ -65,89 +169,142 @@ links: ifname: eth1 ipv4: 172.16.3.12/24 node: host_w_long_n-03 - linkindex: 3 + linkindex: 9 node_count: 2 prefix: ipv4: 172.16.3.0/24 role: stub type: lan -- _linkname: links[4] - bridge: input_4 - gateway: - ipv4: 172.16.4.1/24 +- _linkname: links[3].lag[1] interfaces: - - ifindex: 20 - ifname: eth20 - ipv4: 172.16.4.1/24 + - ifindex: 4 + ifname: eth4 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.4.10/24 - mtu: 1600 - node: host_w_long_n-01 - linkindex: 4 + node: h-03 + lag: + _parentindex: 3 + linkindex: 10 node_count: 2 - prefix: - ipv4: 172.16.4.0/24 - role: stub - type: lan -- _linkname: links[5] - bridge: input_5 - gateway: - ipv4: 172.16.5.1/24 + prefix: false + type: p2p +- _linkname: links[3].lag[2] interfaces: - - ifindex: 21 - ifname: eth21 - ipv4: 172.16.5.1/24 + - ifindex: 5 + ifname: eth5 + node: r + - ifindex: 3 + ifname: eth3 + node: h-03 + lag: + _parentindex: 3 + linkindex: 11 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[4].lag[1] + interfaces: + - ifindex: 6 + ifname: eth6 node: r - ifindex: 2 ifname: eth2 - ipv4: 172.16.5.11/24 - mtu: 1600 - node: host_w_long_n-02 - linkindex: 5 + node: h-07 + lag: + _parentindex: 4 + linkindex: 12 node_count: 2 - prefix: - ipv4: 172.16.5.0/24 - role: stub - type: lan -- _linkname: links[6] - bridge: input_6 - gateway: - ipv4: 172.16.6.1/24 + prefix: false + type: p2p +- _linkname: links[4].lag[2] + interfaces: + - ifindex: 7 + ifname: eth7 + node: r + - ifindex: 3 + ifname: eth3 + node: h-07 + lag: + _parentindex: 4 + linkindex: 13 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[5].lag[1] + interfaces: + - ifindex: 20 + ifname: eth20 + node: r + - ifindex: 4 + ifname: eth4 + node: h-03 + lag: + _parentindex: 5 + linkindex: 14 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[5].lag[2] + interfaces: + - ifindex: 21 + ifname: eth21 + node: r + - ifindex: 5 + ifname: eth5 + node: h-03 + lag: + _parentindex: 5 + linkindex: 15 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[6].lag[1] interfaces: - ifindex: 22 ifname: eth22 - ipv4: 172.16.6.1/24 node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.6.12/24 - mtu: 1600 - node: host_w_long_n-03 - linkindex: 6 + - ifindex: 4 + ifname: eth4 + node: h-07 + lag: + _parentindex: 6 + linkindex: 16 node_count: 2 - prefix: - ipv4: 172.16.6.0/24 - role: stub - type: lan + prefix: false + type: p2p +- _linkname: links[6].lag[2] + interfaces: + - ifindex: 23 + ifname: eth23 + node: r + - ifindex: 5 + ifname: eth5 + node: h-07 + lag: + _parentindex: 6 + linkindex: 17 + node_count: 2 + prefix: false + type: p2p - _linkname: vlans.red.links[1] - bridge: input_7 - gateway: - ipv4: 172.16.0.1/24 + bridge: input_18 interfaces: - _vlan_mode: irb - ifindex: 4 - ifname: eth4 + ifindex: 8 + ifname: eth8 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 1 - ifname: eth1 + - _vlan_mode: irb + ifindex: 6 + ifname: eth6 ipv4: 172.16.0.2/24 node: h-03 - linkindex: 7 + vlan: + access: red + linkindex: 18 node_count: 2 prefix: allocation: id_based @@ -156,22 +313,23 @@ links: vlan: access: red - _linkname: vlans.red.links[2] - bridge: input_8 - gateway: - ipv4: 172.16.0.1/24 + bridge: input_19 interfaces: - _vlan_mode: irb - ifindex: 5 - ifname: eth5 + ifindex: 9 + ifname: eth9 ipv4: 172.16.0.1/24 node: r vlan: access: red - - ifindex: 1 - ifname: eth1 + - _vlan_mode: irb + ifindex: 6 + ifname: eth6 ipv4: 172.16.0.3/24 node: h-07 - linkindex: 8 + vlan: + access: red + linkindex: 19 node_count: 2 prefix: allocation: id_based @@ -180,44 +338,36 @@ links: vlan: access: red - _linkname: vrfs.red.links[1] - bridge: input_9 - gateway: - ipv4: 172.16.7.1/24 interfaces: - - ifindex: 6 - ifname: eth6 - ipv4: 172.16.7.1/24 + - ifindex: 10 + ifname: eth10 + ipv4: 10.1.0.26/30 node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.7.2/24 + - ifindex: 7 + ifname: eth7 + ipv4: 10.1.0.25/30 node: h-03 - linkindex: 9 + linkindex: 20 node_count: 2 prefix: - ipv4: 172.16.7.0/24 - role: stub - type: lan + ipv4: 10.1.0.24/30 + type: p2p vrf: red - _linkname: vrfs.red.links[2] - bridge: input_10 - gateway: - ipv4: 172.16.8.1/24 interfaces: + - ifindex: 11 + ifname: eth11 + ipv4: 10.1.0.30/30 + node: r - ifindex: 7 ifname: eth7 - ipv4: 172.16.8.1/24 - node: r - - ifindex: 2 - ifname: eth2 - ipv4: 172.16.8.3/24 + ipv4: 10.1.0.29/30 node: h-07 - linkindex: 10 + linkindex: 21 node_count: 2 prefix: - ipv4: 172.16.8.0/24 - role: stub - type: lan + ipv4: 10.1.0.28/30 + type: p2p vrf: red module: - lag @@ -228,93 +378,355 @@ nodes: h-03: af: ipv4: true - box: generic/ubuntu2004 - device: linux + vpnv4: true + box: debian/bookworm64 + device: frr id: 2 interfaces: - - bridge: input_7 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 1 + - ifindex: 1 ifname: eth1 - ipv4: 172.16.0.2/24 - linkindex: 7 - name: h-03 -> [r,h-07] + ipv4: 10.1.0.1/30 + linkindex: 1 + mtu: 1600 + name: h-03 -> r neighbors: - - ifname: vlan1000 + - ifname: eth16 + ipv4: 10.1.0.2/30 + node: r + type: p2p + - ifindex: 30000 + ifname: bond5 + ipv4: 10.1.0.10/30 + lag: + ifindex: 5 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: h-03 -> r + neighbors: + - ifname: bond5 + ipv4: 10.1.0.9/30 + node: r + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: bond1 + ipv4: 10.1.0.18/30 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 5 + name: h-03 -> r + neighbors: + - ifname: bond1 + ipv4: 10.1.0.17/30 + node: r + type: lag + virtual_interface: true + - ifindex: 2 + ifname: eth2 + lag: + _parentindex: 3 + linkindex: 10 + name: h-03 -> r + neighbors: + - ifname: eth4 + node: r + type: p2p + - ifindex: 3 + ifname: eth3 + lag: + _parentindex: 3 + linkindex: 11 + name: h-03 -> r + neighbors: + - ifname: eth5 + node: r + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 5 + linkindex: 14 + name: h-03 -> r + neighbors: + - ifname: eth20 + node: r + type: p2p + - ifindex: 5 + ifname: eth5 + lag: + _parentindex: 5 + linkindex: 15 + name: h-03 -> r + neighbors: + - ifname: eth21 + node: r + type: p2p + - bridge: input_18 + ifindex: 6 + ifname: eth6 + linkindex: 18 + name: '[Access VLAN red] h-03 -> r' + neighbors: + - ifname: eth8 ipv4: 172.16.0.1/24 node: r - - ifname: eth1 - ipv4: 172.16.0.3/24 - node: h-07 - role: stub type: lan - - bridge: input_9 - gateway: - ipv4: 172.16.7.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.7.2/24 - linkindex: 9 + vlan: + access: red + access_id: 1000 + - ifindex: 7 + ifname: eth7 + ipv4: 10.1.0.25/30 + linkindex: 20 name: h-03 -> r neighbors: - - ifname: eth6 - ipv4: 172.16.7.1/24 + - ifname: eth10 + ipv4: 10.1.0.26/30 node: r vrf: red - role: stub - type: lan + type: p2p + vrf: red + - bridge_group: 1 + ifindex: 8 + ifname: vlan1000 + ipv4: 172.16.0.2/24 + name: VLAN red (1000) -> [r,h-07] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + - ifname: vlan1000 + ipv4: 172.16.0.3/24 + node: h-07 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.2/32 + neighbors: [] + type: loopback + virtual_interface: true mgmt: ifname: eth0 ipv4: 192.168.121.102 mac: 08:4f:a9:00:00:02 + module: + - lag + - vlan + - vrf name: h-03 - role: host + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + vrf: + as: 65000 + vrfs: + red: + af: + ipv4: true + export: + - '65000:1' + id: 1 + import: + - '65000:1' + rd: '65000:1' + vrfidx: 100 h-07: af: ipv4: true - box: generic/ubuntu2004 - device: linux + vpnv4: true + box: debian/bookworm64 + device: frr id: 3 interfaces: - - bridge: input_8 - gateway: - ipv4: 172.16.0.1/24 - ifindex: 1 + - ifindex: 1 ifname: eth1 - ipv4: 172.16.0.3/24 - linkindex: 8 - name: h-07 -> [h-03,r] + ipv4: 10.1.0.5/30 + linkindex: 2 + mtu: 1600 + name: h-07 -> r neighbors: - - ifname: eth1 - ipv4: 172.16.0.2/24 - node: h-03 - - ifname: vlan1000 - ipv4: 172.16.0.1/24 + - ifname: eth17 + ipv4: 10.1.0.6/30 node: r - role: stub - type: lan - - bridge: input_10 - gateway: - ipv4: 172.16.8.1/24 - ifindex: 2 + type: p2p + - ifindex: 30000 + ifname: bond6 + ipv4: 10.1.0.14/30 + lag: + ifindex: 6 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 4 + name: h-07 -> r + neighbors: + - ifname: bond6 + ipv4: 10.1.0.13/30 + node: r + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: bond2 + ipv4: 10.1.0.22/30 + lag: + ifindex: 2 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 6 + name: h-07 -> r + neighbors: + - ifname: bond2 + ipv4: 10.1.0.21/30 + node: r + type: lag + virtual_interface: true + - ifindex: 2 ifname: eth2 - ipv4: 172.16.8.3/24 - linkindex: 10 + lag: + _parentindex: 4 + linkindex: 12 + name: h-07 -> r + neighbors: + - ifname: eth6 + node: r + type: p2p + - ifindex: 3 + ifname: eth3 + lag: + _parentindex: 4 + linkindex: 13 name: h-07 -> r neighbors: - ifname: eth7 - ipv4: 172.16.8.1/24 node: r - vrf: red - role: stub - type: lan + type: p2p + - ifindex: 4 + ifname: eth4 + lag: + _parentindex: 6 + linkindex: 16 + name: h-07 -> r + neighbors: + - ifname: eth22 + node: r + type: p2p + - ifindex: 5 + ifname: eth5 + lag: + _parentindex: 6 + linkindex: 17 + name: h-07 -> r + neighbors: + - ifname: eth23 + node: r + type: p2p + - bridge: input_19 + ifindex: 6 + ifname: eth6 + linkindex: 19 + name: '[Access VLAN red] h-07 -> r' + neighbors: + - ifname: eth9 + ipv4: 172.16.0.1/24 + node: r + type: lan + vlan: + access: red + access_id: 1000 + - ifindex: 7 + ifname: eth7 + ipv4: 10.1.0.29/30 + linkindex: 21 + name: h-07 -> r + neighbors: + - ifname: eth11 + ipv4: 10.1.0.30/30 + node: r + vrf: red + type: p2p + vrf: red + - bridge_group: 1 + ifindex: 8 + ifname: vlan1000 + ipv4: 172.16.0.3/24 + name: VLAN red (1000) -> [h-03,r] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.2/24 + node: h-03 + - ifname: vlan1000 + ipv4: 172.16.0.1/24 + node: r + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.3/32 + neighbors: [] + type: loopback + virtual_interface: true mgmt: ifname: eth0 ipv4: 192.168.121.103 mac: 08:4f:a9:00:00:03 + module: + - lag + - vlan + - vrf name: h-07 - role: host + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + vrf: + as: 65000 + vrfs: + red: + af: + ipv4: true + export: + - '65000:1' + id: 1 + import: + - '65000:1' + rd: '65000:1' + vrfidx: 100 host_w_long_n-01: af: ipv4: true @@ -322,13 +734,13 @@ nodes: device: linux id: 10 interfaces: - - bridge: input_1 + - bridge: input_7 gateway: ipv4: 172.16.1.1/24 ifindex: 1 ifname: eth1 ipv4: 172.16.1.10/24 - linkindex: 1 + linkindex: 7 name: host_w_long_n-01 -> r neighbors: - ifname: eth1 @@ -336,21 +748,6 @@ nodes: node: r role: stub type: lan - - bridge: input_4 - gateway: - ipv4: 172.16.4.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.4.10/24 - linkindex: 4 - mtu: 1600 - name: host_w_long_n-01 -> r - neighbors: - - ifname: eth20 - ipv4: 172.16.4.1/24 - node: r - role: stub - type: lan mgmt: ifname: eth0 ipv4: 192.168.121.110 @@ -364,13 +761,13 @@ nodes: device: linux id: 11 interfaces: - - bridge: input_2 + - bridge: input_8 gateway: ipv4: 172.16.2.1/24 ifindex: 1 ifname: eth1 ipv4: 172.16.2.11/24 - linkindex: 2 + linkindex: 8 name: host_w_long_n-02 -> r neighbors: - ifname: eth2 @@ -378,21 +775,6 @@ nodes: node: r role: stub type: lan - - bridge: input_5 - gateway: - ipv4: 172.16.5.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.5.11/24 - linkindex: 5 - mtu: 1600 - name: host_w_long_n-02 -> r - neighbors: - - ifname: eth21 - ipv4: 172.16.5.1/24 - node: r - role: stub - type: lan mgmt: ifname: eth0 ipv4: 192.168.121.111 @@ -406,13 +788,13 @@ nodes: device: linux id: 12 interfaces: - - bridge: input_3 + - bridge: input_9 gateway: ipv4: 172.16.3.1/24 ifindex: 1 ifname: eth1 ipv4: 172.16.3.12/24 - linkindex: 3 + linkindex: 9 name: host_w_long_n-03 -> r neighbors: - ifname: eth3 @@ -420,21 +802,6 @@ nodes: node: r role: stub type: lan - - bridge: input_6 - gateway: - ipv4: 172.16.6.1/24 - ifindex: 2 - ifname: eth2 - ipv4: 172.16.6.12/24 - linkindex: 6 - mtu: 1600 - name: host_w_long_n-03 -> r - neighbors: - - ifname: eth22 - ipv4: 172.16.6.1/24 - node: r - role: stub - type: lan mgmt: ifname: eth0 ipv4: 192.168.121.112 @@ -450,11 +817,11 @@ nodes: device: frr id: 1 interfaces: - - bridge: input_1 + - bridge: input_7 ifindex: 1 ifname: eth1 ipv4: 172.16.1.1/24 - linkindex: 1 + linkindex: 7 name: r -> host_w_long_n-01 neighbors: - ifname: eth1 @@ -462,11 +829,11 @@ nodes: node: host_w_long_n-01 role: stub type: lan - - bridge: input_2 + - bridge: input_8 ifindex: 2 ifname: eth2 ipv4: 172.16.2.1/24 - linkindex: 2 + linkindex: 8 name: r -> host_w_long_n-02 neighbors: - ifname: eth1 @@ -474,11 +841,11 @@ nodes: node: host_w_long_n-02 role: stub type: lan - - bridge: input_3 + - bridge: input_9 ifindex: 3 ifname: eth3 ipv4: 172.16.3.1/24 - linkindex: 3 + linkindex: 9 name: r -> host_w_long_n-03 neighbors: - ifname: eth1 @@ -486,104 +853,113 @@ nodes: node: host_w_long_n-03 role: stub type: lan - - bridge: input_7 - ifindex: 4 + - ifindex: 4 ifname: eth4 - linkindex: 7 + lag: + _parentindex: 3 + linkindex: 10 + name: r -> h-03 + neighbors: + - ifname: eth2 + node: h-03 + type: p2p + - ifindex: 5 + ifname: eth5 + lag: + _parentindex: 3 + linkindex: 11 + name: r -> h-03 + neighbors: + - ifname: eth3 + node: h-03 + type: p2p + - ifindex: 6 + ifname: eth6 + lag: + _parentindex: 4 + linkindex: 12 + name: r -> h-07 + neighbors: + - ifname: eth2 + node: h-07 + type: p2p + - ifindex: 7 + ifname: eth7 + lag: + _parentindex: 4 + linkindex: 13 + name: r -> h-07 + neighbors: + - ifname: eth3 + node: h-07 + type: p2p + - bridge: input_18 + ifindex: 8 + ifname: eth8 + linkindex: 18 name: '[Access VLAN red] r -> h-03' neighbors: - - ifname: eth1 + - ifname: eth6 ipv4: 172.16.0.2/24 node: h-03 type: lan vlan: access: red access_id: 1000 - - bridge: input_8 - ifindex: 5 - ifname: eth5 - linkindex: 8 + - bridge: input_19 + ifindex: 9 + ifname: eth9 + linkindex: 19 name: '[Access VLAN red] r -> h-07' neighbors: - - ifname: eth1 + - ifname: eth6 ipv4: 172.16.0.3/24 node: h-07 type: lan vlan: access: red access_id: 1000 - - bridge: input_9 - ifindex: 6 - ifname: eth6 - ipv4: 172.16.7.1/24 - linkindex: 9 + - ifindex: 10 + ifname: eth10 + ipv4: 10.1.0.26/30 + linkindex: 20 name: r -> h-03 neighbors: - - ifname: eth2 - ipv4: 172.16.7.2/24 + - ifname: eth7 + ipv4: 10.1.0.25/30 node: h-03 - role: stub - type: lan + vrf: red + type: p2p vrf: red - - bridge: input_10 - ifindex: 7 - ifname: eth7 - ipv4: 172.16.8.1/24 - linkindex: 10 + - ifindex: 11 + ifname: eth11 + ipv4: 10.1.0.30/30 + linkindex: 21 name: r -> h-07 neighbors: - - ifname: eth2 - ipv4: 172.16.8.3/24 + - ifname: eth7 + ipv4: 10.1.0.29/30 node: h-07 - role: stub - type: lan + vrf: red + type: p2p vrf: red - bridge_group: 1 - ifindex: 8 + ifindex: 12 ifname: vlan1000 ipv4: 172.16.0.1/24 name: VLAN red (1000) -> [h-03,h-07] neighbors: - - ifname: eth1 + - ifname: vlan1000 ipv4: 172.16.0.2/24 node: h-03 - - ifname: eth1 + - ifname: vlan1000 ipv4: 172.16.0.3/24 node: h-07 - role: stub type: svi virtual_interface: true vlan: mode: irb name: red - - ifindex: 9 - ifname: eth9 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 10 - ifname: eth10 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 11 - ifname: eth11 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - - ifindex: 12 - ifname: eth12 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 - type: p2p - ifindex: 13 ifname: eth13 linkindex: 0 @@ -607,17 +983,23 @@ nodes: type: p2p - ifindex: 16 ifname: eth16 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 + ipv4: 10.1.0.2/30 + linkindex: 1 + name: r -> h-03 + neighbors: + - ifname: eth1 + ipv4: 10.1.0.1/30 + node: h-03 type: p2p - ifindex: 17 ifname: eth17 - linkindex: 0 - neighbors: [] - remote_id: 1 - remote_ifindex: 666 + ipv4: 10.1.0.6/30 + linkindex: 2 + name: r -> h-07 + neighbors: + - ifname: eth1 + ipv4: 10.1.0.5/30 + node: h-07 type: p2p - ifindex: 18 ifname: eth18 @@ -633,48 +1015,116 @@ nodes: remote_id: 1 remote_ifindex: 666 type: p2p - - bridge: input_4 - ifindex: 20 + - ifindex: 20 ifname: eth20 - ipv4: 172.16.4.1/24 - linkindex: 4 - name: r -> host_w_long_n-01 + lag: + _parentindex: 5 + linkindex: 14 + name: r -> h-03 neighbors: - - ifname: eth2 - ipv4: 172.16.4.10/24 - node: host_w_long_n-01 - role: stub - type: lan - - bridge: input_5 - ifindex: 21 + - ifname: eth4 + node: h-03 + type: p2p + - ifindex: 21 ifname: eth21 - ipv4: 172.16.5.1/24 - linkindex: 5 - name: r -> host_w_long_n-02 + lag: + _parentindex: 5 + linkindex: 15 + name: r -> h-03 neighbors: - - ifname: eth2 - ipv4: 172.16.5.11/24 - node: host_w_long_n-02 - role: stub - type: lan - - bridge: input_6 - ifindex: 22 + - ifname: eth5 + node: h-03 + type: p2p + - ifindex: 22 ifname: eth22 - ipv4: 172.16.6.1/24 + lag: + _parentindex: 6 + linkindex: 16 + name: r -> h-07 + neighbors: + - ifname: eth4 + node: h-07 + type: p2p + - ifindex: 23 + ifname: eth23 + lag: + _parentindex: 6 + linkindex: 17 + name: r -> h-07 + neighbors: + - ifname: eth5 + node: h-07 + type: p2p + - ifindex: 30000 + ifname: bond5 + ipv4: 10.1.0.9/30 + lag: + ifindex: 5 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 3 + name: r -> h-03 + neighbors: + - ifname: bond5 + ipv4: 10.1.0.10/30 + node: h-03 + type: lag + virtual_interface: true + - ifindex: 30001 + ifname: bond6 + ipv4: 10.1.0.13/30 + lag: + ifindex: 6 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 4 + name: r -> h-07 + neighbors: + - ifname: bond6 + ipv4: 10.1.0.14/30 + node: h-07 + type: lag + virtual_interface: true + - ifindex: 30002 + ifname: bond1 + ipv4: 10.1.0.17/30 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 5 + name: r -> h-03 + neighbors: + - ifname: bond1 + ipv4: 10.1.0.18/30 + node: h-03 + type: lag + virtual_interface: true + - ifindex: 30003 + ifname: bond2 + ipv4: 10.1.0.21/30 + lag: + ifindex: 2 + lacp: fast + lacp_mode: active + mode: 802.3ad linkindex: 6 - name: r -> host_w_long_n-03 + name: r -> h-07 neighbors: - - ifname: eth2 - ipv4: 172.16.6.12/24 - node: host_w_long_n-03 - role: stub - type: lan + - ifname: bond2 + ipv4: 10.1.0.22/30 + node: h-07 + type: lag + virtual_interface: true lag: lacp: fast lacp_mode: active mode: 802.3ad libvirt: - nic_adapter_count: 23 + nic_adapter_count: 24 loopback: ifindex: 0 ifname: lo @@ -719,16 +1169,16 @@ plugin: provider: libvirt vlans: red: - host_count: 2 + host_count: 0 id: 1000 neighbors: - - ifname: eth1 + - ifname: vlan1000 ipv4: 172.16.0.2/24 node: h-03 - ifname: vlan1000 ipv4: 172.16.0.1/24 node: r - - ifname: eth1 + - ifname: vlan1000 ipv4: 172.16.0.3/24 node: h-07 prefix: diff --git a/tests/topology/input/lag-mlag.yml b/tests/topology/input/lag-mlag.yml index ed76dd944..9d67240fd 100644 --- a/tests/topology/input/lag-mlag.yml +++ b/tests/topology/input/lag-mlag.yml @@ -22,6 +22,8 @@ links: - lag: # MLAG peer link between S1 and S2, redundant members: [s1-s2,s2-s1] mlag.peergroup: True +- lag: + members: [h2-s2,h2-s2] # Regression: Basic lag assigned ifindex=1, followed by mlag - lag: members: [ h1-s1,h1-s1,h1-s2,h1-s2 ] # Test multiple links between same pair of nodes vlan.access: red @@ -30,4 +32,4 @@ links: vlan.access: red - lag: members: [ h2-s1,h2-s2 ] # A second lag should get a unique ifindex, not overlapping with the first one - vlan.access: red \ No newline at end of file + vlan.access: red diff --git a/tests/topology/input/node.clone-plugin-lag.yml b/tests/topology/input/node.clone-plugin-lag.yml new file mode 100644 index 000000000..3ef7419f5 --- /dev/null +++ b/tests/topology/input/node.clone-plugin-lag.yml @@ -0,0 +1,43 @@ +# +# Tests various lag related cases +# +--- +plugin: [ node.clone ] + +module: [lag,vlan] + +vlans: + red: + +groups: + _auto_create: True + routers: + members: [r1,r2] # Devices that supports (m)lag + device: eos + module: [vlan,lag] + +nodes: + h: # Short name, regular test + device: frr + clone.count: 2 + +links: +- lag: + members: [r1-r2] + mlag.peergroup: True +- lag: + members: [ r1-h, r1-h ] + ifindex: 8 # Custom lag.ifindex, gets incremented for each clone + pool: l2only +- lag: + members: + - r2: + ifindex: 6 # Custom ifindex on interface, gets incremented for each clone + h: + - r2: + ifindex: 7 + h: + pool: l2only +- lag: + members: [ h-r1, h-r2 ] # mlag + vlan.access: red \ No newline at end of file diff --git a/tests/topology/input/node.clone-plugin.yml b/tests/topology/input/node.clone-plugin.yml index 5edd3774c..03d93f9c7 100644 --- a/tests/topology/input/node.clone-plugin.yml +++ b/tests/topology/input/node.clone-plugin.yml @@ -21,7 +21,7 @@ nodes: device: frr h: # Short name, regular test - device: linux + device: frr clone: count: 2 start: 3 # Create h-03 and h-07 @@ -35,8 +35,18 @@ nodes: links: - r-host_w_long_name # Plugin supports different styles of specifying links, all normalized - r: - ifindex: 20 # Custom port on router -> gets incremented - host_w_long_name: + ifindex: 16 # Custom port on router -> gets incremented + h: mtu: 1600 # Interface atts get copied too -# - lag.members: [ r-host_w_long_name, r-host_w_long_name ] # TODO lags need special work, not supported yet \ No newline at end of file +- lag: + members: [ r-h, r-h ] + ifindex: 5 # Custom lag.ifindex, gets incremented for each clone +- lag: + members: + - r: + ifindex: 20 # Custom ifindex on interface, gets incremented for each clone + h: + - r: + ifindex: 21 + h: \ No newline at end of file From c966424ab715ce6906336aeb7f198d359c81ba97 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Mon, 9 Dec 2024 23:04:00 -0600 Subject: [PATCH 17/19] Avoid triggering lag.ifindex overlap issue --- .../expected/node.clone-plugin-lag.yml | 708 ++++++++++++------ .../topology/input/node.clone-plugin-lag.yml | 6 +- 2 files changed, 503 insertions(+), 211 deletions(-) diff --git a/tests/topology/expected/node.clone-plugin-lag.yml b/tests/topology/expected/node.clone-plugin-lag.yml index 51f4f4fef..bfc0d9d12 100644 --- a/tests/topology/expected/node.clone-plugin-lag.yml +++ b/tests/topology/expected/node.clone-plugin-lag.yml @@ -34,13 +34,13 @@ links: bridge: input_2 interfaces: - ifindex: 30000 - ifname: port-channel5 + ifname: port-channel8 node: r1 - ifindex: 30000 - ifname: bond5 + ifname: bond8 node: h-01 lag: - ifindex: 5 + ifindex: 8 linkindex: 2 node_count: 2 pool: l2only @@ -49,13 +49,13 @@ links: bridge: input_3 interfaces: - ifindex: 30001 - ifname: port-channel6 + ifname: port-channel9 node: r1 - ifindex: 30000 - ifname: bond6 + ifname: bond9 node: h-02 lag: - ifindex: 6 + ifindex: 9 linkindex: 3 node_count: 2 pool: l2only @@ -63,18 +63,48 @@ links: - _linkname: links[4] bridge: input_4 interfaces: + - ifindex: 30000 + ifname: port-channel1 + node: r2 + - ifindex: 30001 + ifname: bond1 + node: h-01 + lag: + ifindex: 1 + linkindex: 4 + node_count: 2 + pool: l2only + type: lag +- _linkname: links[5] + bridge: input_5 + interfaces: + - ifindex: 30001 + ifname: port-channel2 + node: r2 + - ifindex: 30001 + ifname: bond2 + node: h-02 + lag: + ifindex: 2 + linkindex: 5 + node_count: 2 + pool: l2only + type: lag +- _linkname: links[6] + bridge: input_6 + interfaces: - _vlan_mode: irb - ifindex: 30001 + ifindex: 30000 ifname: bond1 - ipv4: 172.16.0.3/24 + ipv4: 172.16.0.5/24 lag: ifindex: 1 - node: h-01 + node: h2-01 vlan: access: red - _vlan_mode: irb ifindex: 30002 - ifname: port-channel1 + ifname: port-channel3 ipv4: 172.16.0.1/24 lag: _mlag: true @@ -82,8 +112,8 @@ links: vlan: access: red - _vlan_mode: irb - ifindex: 30000 - ifname: port-channel1 + ifindex: 30002 + ifname: port-channel3 ipv4: 172.16.0.2/24 lag: _mlag: true @@ -91,8 +121,8 @@ links: vlan: access: red lag: - ifindex: 1 - linkindex: 4 + ifindex: 3 + linkindex: 6 node_count: 3 prefix: allocation: id_based @@ -100,21 +130,21 @@ links: type: lag vlan: access: red -- _linkname: links[5] - bridge: input_5 +- _linkname: links[7] + bridge: input_7 interfaces: - _vlan_mode: irb - ifindex: 30001 + ifindex: 30000 ifname: bond1 - ipv4: 172.16.0.4/24 + ipv4: 172.16.0.6/24 lag: ifindex: 1 - node: h-02 + node: h2-02 vlan: access: red - _vlan_mode: irb ifindex: 30003 - ifname: port-channel2 + ifname: port-channel4 ipv4: 172.16.0.1/24 lag: _mlag: true @@ -122,8 +152,8 @@ links: vlan: access: red - _vlan_mode: irb - ifindex: 30001 - ifname: port-channel2 + ifindex: 30003 + ifname: port-channel4 ipv4: 172.16.0.2/24 lag: _mlag: true @@ -131,8 +161,8 @@ links: vlan: access: red lag: - ifindex: 2 - linkindex: 5 + ifindex: 4 + linkindex: 7 node_count: 3 prefix: allocation: id_based @@ -150,7 +180,7 @@ links: node: h-01 lag: _parentindex: 2 - linkindex: 6 + linkindex: 8 node_count: 2 prefix: false type: p2p @@ -164,7 +194,7 @@ links: node: h-01 lag: _parentindex: 2 - linkindex: 7 + linkindex: 9 node_count: 2 prefix: false type: p2p @@ -178,7 +208,7 @@ links: node: h-02 lag: _parentindex: 3 - linkindex: 8 + linkindex: 10 node_count: 2 prefix: false type: p2p @@ -192,63 +222,119 @@ links: node: h-02 lag: _parentindex: 3 - linkindex: 9 + linkindex: 11 node_count: 2 prefix: false type: p2p - _linkname: links[4].lag[1] interfaces: + - ifindex: 6 + ifname: Ethernet6 + node: r2 - ifindex: 3 ifname: eth3 node: h-01 - - ifindex: 6 - ifname: Ethernet6 - node: r1 lag: _parentindex: 4 - linkindex: 10 + linkindex: 12 node_count: 2 prefix: false type: p2p - _linkname: links[4].lag[2] interfaces: + - ifindex: 7 + ifname: Ethernet7 + node: r2 - ifindex: 4 ifname: eth4 node: h-01 - - ifindex: 2 - ifname: Ethernet2 - node: r2 lag: _parentindex: 4 - linkindex: 11 + linkindex: 13 node_count: 2 prefix: false type: p2p - _linkname: links[5].lag[1] interfaces: + - ifindex: 8 + ifname: Ethernet8 + node: r2 - ifindex: 3 ifname: eth3 node: h-02 - - ifindex: 7 - ifname: Ethernet7 - node: r1 lag: _parentindex: 5 - linkindex: 12 + linkindex: 14 node_count: 2 prefix: false type: p2p - _linkname: links[5].lag[2] interfaces: + - ifindex: 9 + ifname: Ethernet9 + node: r2 - ifindex: 4 ifname: eth4 node: h-02 + lag: + _parentindex: 5 + linkindex: 15 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[6].lag[1] + interfaces: + - ifindex: 1 + ifname: eth1 + node: h2-01 + - ifindex: 6 + ifname: Ethernet6 + node: r1 + lag: + _parentindex: 6 + linkindex: 16 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[6].lag[2] + interfaces: + - ifindex: 2 + ifname: eth2 + node: h2-01 + - ifindex: 2 + ifname: Ethernet2 + node: r2 + lag: + _parentindex: 6 + linkindex: 17 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[7].lag[1] + interfaces: + - ifindex: 1 + ifname: eth1 + node: h2-02 + - ifindex: 7 + ifname: Ethernet7 + node: r1 + lag: + _parentindex: 7 + linkindex: 18 + node_count: 2 + prefix: false + type: p2p +- _linkname: links[7].lag[2] + interfaces: + - ifindex: 2 + ifname: eth2 + node: h2-02 - ifindex: 3 ifname: Ethernet3 node: r2 lag: - _parentindex: 5 - linkindex: 13 + _parentindex: 7 + linkindex: 19 node_count: 2 prefix: false type: p2p @@ -265,16 +351,16 @@ nodes: id: 3 interfaces: - ifindex: 30000 - ifname: bond5 + ifname: bond8 lag: - ifindex: 5 + ifindex: 8 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 2 name: h-01 -> r1 neighbors: - - ifname: port-channel5 + - ifname: port-channel8 node: r1 pool: l2only type: lag @@ -287,24 +373,18 @@ nodes: lacp_mode: active mode: 802.3ad linkindex: 4 - name: '[Access VLAN red] h-01 -> [r1,r2]' + name: h-01 -> r2 neighbors: - ifname: port-channel1 - ipv4: 172.16.0.1/24 - node: r1 - - ifname: port-channel1 - ipv4: 172.16.0.2/24 node: r2 + pool: l2only type: lag virtual_interface: true - vlan: - access: red - access_id: 1000 - ifindex: 1 ifname: eth1 lag: _parentindex: 2 - linkindex: 6 + linkindex: 8 name: h-01 -> r1 neighbors: - ifname: Ethernet2 @@ -314,7 +394,7 @@ nodes: ifname: eth2 lag: _parentindex: 2 - linkindex: 7 + linkindex: 9 name: h-01 -> r1 neighbors: - ifname: Ethernet3 @@ -324,42 +404,22 @@ nodes: ifname: eth3 lag: _parentindex: 4 - linkindex: 10 - name: h-01 -> r1 + linkindex: 12 + name: h-01 -> r2 neighbors: - ifname: Ethernet6 - node: r1 + node: r2 type: p2p - ifindex: 4 ifname: eth4 lag: _parentindex: 4 - linkindex: 11 + linkindex: 13 name: h-01 -> r2 neighbors: - - ifname: Ethernet2 + - ifname: Ethernet7 node: r2 type: p2p - - bridge_group: 1 - ifindex: 5 - ifname: vlan1000 - ipv4: 172.16.0.3/24 - name: VLAN red (1000) -> [r2,r1,h-02] - neighbors: - - ifname: Vlan1000 - ipv4: 172.16.0.2/24 - node: r2 - - ifname: Vlan1000 - ipv4: 172.16.0.1/24 - node: r1 - - ifname: vlan1000 - ipv4: 172.16.0.4/24 - node: h-02 - type: svi - virtual_interface: true - vlan: - mode: irb - name: red lag: lacp: fast lacp_mode: active @@ -379,16 +439,6 @@ nodes: - lag - vlan name: h-01 - vlan: - max_bridge_group: 1 - vlans: - red: - bridge_group: 1 - id: 1000 - mode: irb - prefix: - allocation: id_based - ipv4: 172.16.0.0/24 h-02: af: ipv4: true @@ -397,46 +447,40 @@ nodes: id: 4 interfaces: - ifindex: 30000 - ifname: bond6 + ifname: bond9 lag: - ifindex: 6 + ifindex: 9 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 3 name: h-02 -> r1 neighbors: - - ifname: port-channel6 + - ifname: port-channel9 node: r1 pool: l2only type: lag virtual_interface: true - ifindex: 30001 - ifname: bond1 + ifname: bond2 lag: - ifindex: 1 + ifindex: 2 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 5 - name: '[Access VLAN red] h-02 -> [r1,r2]' + name: h-02 -> r2 neighbors: - ifname: port-channel2 - ipv4: 172.16.0.1/24 - node: r1 - - ifname: port-channel2 - ipv4: 172.16.0.2/24 node: r2 + pool: l2only type: lag virtual_interface: true - vlan: - access: red - access_id: 1000 - ifindex: 1 ifname: eth1 lag: _parentindex: 3 - linkindex: 8 + linkindex: 10 name: h-02 -> r1 neighbors: - ifname: Ethernet4 @@ -446,7 +490,7 @@ nodes: ifname: eth2 lag: _parentindex: 3 - linkindex: 9 + linkindex: 11 name: h-02 -> r1 neighbors: - ifname: Ethernet5 @@ -456,31 +500,195 @@ nodes: ifname: eth3 lag: _parentindex: 5 - linkindex: 12 - name: h-02 -> r1 + linkindex: 14 + name: h-02 -> r2 neighbors: - - ifname: Ethernet7 - node: r1 + - ifname: Ethernet8 + node: r2 type: p2p - ifindex: 4 ifname: eth4 lag: _parentindex: 5 - linkindex: 13 + linkindex: 15 name: h-02 -> r2 neighbors: + - ifname: Ethernet9 + node: r2 + type: p2p + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.4/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.104 + mac: 08:4f:a9:00:00:04 + module: + - lag + - vlan + name: h-02 + h2-01: + af: + ipv4: true + box: debian/bookworm64 + device: frr + id: 5 + interfaces: + - ifindex: 30000 + ifname: bond1 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 6 + name: '[Access VLAN red] h2-01 -> [r1,r2]' + neighbors: + - ifname: port-channel3 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: port-channel3 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 1 + ifname: eth1 + lag: + _parentindex: 6 + linkindex: 16 + name: h2-01 -> r1 + neighbors: + - ifname: Ethernet6 + node: r1 + type: p2p + - ifindex: 2 + ifname: eth2 + lag: + _parentindex: 6 + linkindex: 17 + name: h2-01 -> r2 + neighbors: + - ifname: Ethernet2 + node: r2 + type: p2p + - bridge_group: 1 + ifindex: 3 + ifname: vlan1000 + ipv4: 172.16.0.5/24 + name: VLAN red (1000) -> [r2,r1,h2-02] + neighbors: + - ifname: Vlan1000 + ipv4: 172.16.0.2/24 + node: r2 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: vlan1000 + ipv4: 172.16.0.6/24 + node: h2-02 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + lag: + lacp: fast + lacp_mode: active + mode: 802.3ad + loopback: + ifindex: 0 + ifname: lo + ipv4: 10.0.0.5/32 + neighbors: [] + type: loopback + virtual_interface: true + mgmt: + ifname: eth0 + ipv4: 192.168.121.105 + mac: 08:4f:a9:00:00:05 + module: + - lag + - vlan + name: h2-01 + vlan: + max_bridge_group: 1 + vlans: + red: + bridge_group: 1 + id: 1000 + mode: irb + prefix: + allocation: id_based + ipv4: 172.16.0.0/24 + h2-02: + af: + ipv4: true + box: debian/bookworm64 + device: frr + id: 6 + interfaces: + - ifindex: 30000 + ifname: bond1 + lag: + ifindex: 1 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 7 + name: '[Access VLAN red] h2-02 -> [r1,r2]' + neighbors: + - ifname: port-channel4 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: port-channel4 + ipv4: 172.16.0.2/24 + node: r2 + type: lag + virtual_interface: true + vlan: + access: red + access_id: 1000 + - ifindex: 1 + ifname: eth1 + lag: + _parentindex: 7 + linkindex: 18 + name: h2-02 -> r1 + neighbors: + - ifname: Ethernet7 + node: r1 + type: p2p + - ifindex: 2 + ifname: eth2 + lag: + _parentindex: 7 + linkindex: 19 + name: h2-02 -> r2 + neighbors: - ifname: Ethernet3 node: r2 type: p2p - bridge_group: 1 - ifindex: 5 + ifindex: 3 ifname: vlan1000 - ipv4: 172.16.0.4/24 - name: VLAN red (1000) -> [h-01,r2,r1] + ipv4: 172.16.0.6/24 + name: VLAN red (1000) -> [h2-01,r2,r1] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.3/24 - node: h-01 + ipv4: 172.16.0.5/24 + node: h2-01 - ifname: Vlan1000 ipv4: 172.16.0.2/24 node: r2 @@ -499,18 +707,18 @@ nodes: loopback: ifindex: 0 ifname: lo - ipv4: 10.0.0.4/32 + ipv4: 10.0.0.6/32 neighbors: [] type: loopback virtual_interface: true mgmt: ifname: eth0 - ipv4: 192.168.121.104 - mac: 08:4f:a9:00:00:04 + ipv4: 192.168.121.106 + mac: 08:4f:a9:00:00:06 module: - lag - vlan - name: h-02 + name: h2-02 vlan: max_bridge_group: 1 vlans: @@ -544,50 +752,50 @@ nodes: node: r2 type: p2p - ifindex: 30000 - ifname: port-channel5 + ifname: port-channel8 lag: - ifindex: 5 + ifindex: 8 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 2 name: r1 -> h-01 neighbors: - - ifname: bond5 + - ifname: bond8 node: h-01 pool: l2only type: lag virtual_interface: true - ifindex: 30001 - ifname: port-channel6 + ifname: port-channel9 lag: - ifindex: 6 + ifindex: 9 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 3 name: r1 -> h-02 neighbors: - - ifname: bond6 + - ifname: bond9 node: h-02 pool: l2only type: lag virtual_interface: true - ifindex: 30002 - ifname: port-channel1 + ifname: port-channel3 lag: _mlag: true - ifindex: 1 + ifindex: 3 lacp: fast lacp_mode: active mode: 802.3ad - linkindex: 4 - name: '[Access VLAN red] r1 -> [h-01,r2]' + linkindex: 6 + name: '[Access VLAN red] r1 -> [h2-01,r2]' neighbors: - ifname: bond1 - ipv4: 172.16.0.3/24 - node: h-01 - - ifname: port-channel1 + ipv4: 172.16.0.5/24 + node: h2-01 + - ifname: port-channel3 ipv4: 172.16.0.2/24 node: r2 type: lag @@ -596,20 +804,20 @@ nodes: access: red access_id: 1000 - ifindex: 30003 - ifname: port-channel2 + ifname: port-channel4 lag: _mlag: true - ifindex: 2 + ifindex: 4 lacp: fast lacp_mode: active mode: 802.3ad - linkindex: 5 - name: '[Access VLAN red] r1 -> [h-02,r2]' + linkindex: 7 + name: '[Access VLAN red] r1 -> [h2-02,r2]' neighbors: - ifname: bond1 - ipv4: 172.16.0.4/24 - node: h-02 - - ifname: port-channel2 + ipv4: 172.16.0.6/24 + node: h2-02 + - ifname: port-channel4 ipv4: 172.16.0.2/24 node: r2 type: lag @@ -621,7 +829,7 @@ nodes: ifname: Ethernet2 lag: _parentindex: 2 - linkindex: 6 + linkindex: 8 name: r1 -> h-01 neighbors: - ifname: eth1 @@ -631,7 +839,7 @@ nodes: ifname: Ethernet3 lag: _parentindex: 2 - linkindex: 7 + linkindex: 9 name: r1 -> h-01 neighbors: - ifname: eth2 @@ -641,7 +849,7 @@ nodes: ifname: Ethernet4 lag: _parentindex: 3 - linkindex: 8 + linkindex: 10 name: r1 -> h-02 neighbors: - ifname: eth1 @@ -651,7 +859,7 @@ nodes: ifname: Ethernet5 lag: _parentindex: 3 - linkindex: 9 + linkindex: 11 name: r1 -> h-02 neighbors: - ifname: eth2 @@ -660,38 +868,38 @@ nodes: - ifindex: 6 ifname: Ethernet6 lag: - _parentindex: 4 - linkindex: 10 - name: r1 -> h-01 + _parentindex: 6 + linkindex: 16 + name: r1 -> h2-01 neighbors: - - ifname: eth3 - node: h-01 + - ifname: eth1 + node: h2-01 type: p2p - ifindex: 7 ifname: Ethernet7 lag: - _parentindex: 5 - linkindex: 12 - name: r1 -> h-02 + _parentindex: 7 + linkindex: 18 + name: r1 -> h2-02 neighbors: - - ifname: eth3 - node: h-02 + - ifname: eth1 + node: h2-02 type: p2p - bridge_group: 1 ifindex: 8 ifname: Vlan1000 ipv4: 172.16.0.1/24 - name: VLAN red (1000) -> [h-01,r2,h-02] + name: VLAN red (1000) -> [h2-01,r2,h2-02] neighbors: - ifname: vlan1000 - ipv4: 172.16.0.3/24 - node: h-01 + ipv4: 172.16.0.5/24 + node: h2-01 - ifname: Vlan1000 ipv4: 172.16.0.2/24 node: r2 - ifname: vlan1000 - ipv4: 172.16.0.4/24 - node: h-02 + ipv4: 172.16.0.6/24 + node: h2-02 type: svi virtual_interface: true vlan: @@ -727,6 +935,7 @@ nodes: allocation: id_based ipv4: 172.16.0.0/24 r2: + _set_ifindex: true af: ipv4: true box: arista/veos @@ -748,43 +957,138 @@ nodes: - ifname: Ethernet1 node: r1 type: p2p + - ifindex: 2 + ifname: Ethernet2 + lag: + _parentindex: 6 + linkindex: 17 + name: r2 -> h2-01 + neighbors: + - ifname: eth2 + node: h2-01 + type: p2p + - ifindex: 3 + ifname: Ethernet3 + lag: + _parentindex: 7 + linkindex: 19 + name: r2 -> h2-02 + neighbors: + - ifname: eth2 + node: h2-02 + type: p2p + - bridge_group: 1 + ifindex: 4 + ifname: Vlan1000 + ipv4: 172.16.0.2/24 + name: VLAN red (1000) -> [h2-01,r1,h2-02] + neighbors: + - ifname: vlan1000 + ipv4: 172.16.0.5/24 + node: h2-01 + - ifname: Vlan1000 + ipv4: 172.16.0.1/24 + node: r1 + - ifname: vlan1000 + ipv4: 172.16.0.6/24 + node: h2-02 + type: svi + virtual_interface: true + vlan: + mode: irb + name: red + - ifindex: 5 + ifname: Ethernet5 + linkindex: 0 + neighbors: [] + remote_id: 2 + remote_ifindex: 666 + type: p2p + - ifindex: 6 + ifname: Ethernet6 + lag: + _parentindex: 4 + linkindex: 12 + name: r2 -> h-01 + neighbors: + - ifname: eth3 + node: h-01 + type: p2p + - ifindex: 7 + ifname: Ethernet7 + lag: + _parentindex: 4 + linkindex: 13 + name: r2 -> h-01 + neighbors: + - ifname: eth4 + node: h-01 + type: p2p + - ifindex: 8 + ifname: Ethernet8 + lag: + _parentindex: 5 + linkindex: 14 + name: r2 -> h-02 + neighbors: + - ifname: eth3 + node: h-02 + type: p2p + - ifindex: 9 + ifname: Ethernet9 + lag: + _parentindex: 5 + linkindex: 15 + name: r2 -> h-02 + neighbors: + - ifname: eth4 + node: h-02 + type: p2p - ifindex: 30000 ifname: port-channel1 lag: - _mlag: true ifindex: 1 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 4 - name: '[Access VLAN red] r2 -> [h-01,r1]' + name: r2 -> h-01 neighbors: - ifname: bond1 - ipv4: 172.16.0.3/24 node: h-01 - - ifname: port-channel1 - ipv4: 172.16.0.1/24 - node: r1 + pool: l2only type: lag virtual_interface: true - vlan: - access: red - access_id: 1000 - ifindex: 30001 ifname: port-channel2 lag: - _mlag: true ifindex: 2 lacp: fast lacp_mode: active mode: 802.3ad linkindex: 5 - name: '[Access VLAN red] r2 -> [h-02,r1]' + name: r2 -> h-02 neighbors: - - ifname: bond1 - ipv4: 172.16.0.4/24 + - ifname: bond2 node: h-02 - - ifname: port-channel2 + pool: l2only + type: lag + virtual_interface: true + - ifindex: 30002 + ifname: port-channel3 + lag: + _mlag: true + ifindex: 3 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 6 + name: '[Access VLAN red] r2 -> [h2-01,r1]' + neighbors: + - ifname: bond1 + ipv4: 172.16.0.5/24 + node: h2-01 + - ifname: port-channel3 ipv4: 172.16.0.1/24 node: r1 type: lag @@ -792,50 +1096,34 @@ nodes: vlan: access: red access_id: 1000 - - ifindex: 2 - ifname: Ethernet2 - lag: - _parentindex: 4 - linkindex: 11 - name: r2 -> h-01 - neighbors: - - ifname: eth4 - node: h-01 - type: p2p - - ifindex: 3 - ifname: Ethernet3 + - ifindex: 30003 + ifname: port-channel4 lag: - _parentindex: 5 - linkindex: 13 - name: r2 -> h-02 - neighbors: - - ifname: eth4 - node: h-02 - type: p2p - - bridge_group: 1 - ifindex: 4 - ifname: Vlan1000 - ipv4: 172.16.0.2/24 - name: VLAN red (1000) -> [h-01,r1,h-02] + _mlag: true + ifindex: 4 + lacp: fast + lacp_mode: active + mode: 802.3ad + linkindex: 7 + name: '[Access VLAN red] r2 -> [h2-02,r1]' neighbors: - - ifname: vlan1000 - ipv4: 172.16.0.3/24 - node: h-01 - - ifname: Vlan1000 + - ifname: bond1 + ipv4: 172.16.0.6/24 + node: h2-02 + - ifname: port-channel4 ipv4: 172.16.0.1/24 node: r1 - - ifname: vlan1000 - ipv4: 172.16.0.4/24 - node: h-02 - type: svi + type: lag virtual_interface: true vlan: - mode: irb - name: red + access: red + access_id: 1000 lag: lacp: fast lacp_mode: active mode: 802.3ad + libvirt: + nic_adapter_count: 10 loopback: ifindex: 0 ifname: Loopback0 @@ -870,8 +1158,8 @@ vlans: id: 1000 neighbors: - ifname: vlan1000 - ipv4: 172.16.0.3/24 - node: h-01 + ipv4: 172.16.0.5/24 + node: h2-01 - ifname: Vlan1000 ipv4: 172.16.0.2/24 node: r2 @@ -879,8 +1167,8 @@ vlans: ipv4: 172.16.0.1/24 node: r1 - ifname: vlan1000 - ipv4: 172.16.0.4/24 - node: h-02 + ipv4: 172.16.0.6/24 + node: h2-02 prefix: allocation: id_based ipv4: 172.16.0.0/24 diff --git a/tests/topology/input/node.clone-plugin-lag.yml b/tests/topology/input/node.clone-plugin-lag.yml index 3ef7419f5..5637eedcb 100644 --- a/tests/topology/input/node.clone-plugin-lag.yml +++ b/tests/topology/input/node.clone-plugin-lag.yml @@ -21,6 +21,10 @@ nodes: device: frr clone.count: 2 + h2: + device: frr + clone.count: 2 + links: - lag: members: [r1-r2] @@ -39,5 +43,5 @@ links: h: pool: l2only - lag: - members: [ h-r1, h-r2 ] # mlag + members: [ h2-r1, h2-r2 ] # mlag, avoid issue with overlapping lag.ifindex vlan.access: red \ No newline at end of file From 0bc81e1e66e51effea18407a01f238f85dd4cbb5 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Mon, 9 Dec 2024 23:19:57 -0600 Subject: [PATCH 18/19] Remove lag regression test, included in lag PR --- tests/topology/input/lag-mlag.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/topology/input/lag-mlag.yml b/tests/topology/input/lag-mlag.yml index 9d67240fd..a8628b6e8 100644 --- a/tests/topology/input/lag-mlag.yml +++ b/tests/topology/input/lag-mlag.yml @@ -22,8 +22,6 @@ links: - lag: # MLAG peer link between S1 and S2, redundant members: [s1-s2,s2-s1] mlag.peergroup: True -- lag: - members: [h2-s2,h2-s2] # Regression: Basic lag assigned ifindex=1, followed by mlag - lag: members: [ h1-s1,h1-s1,h1-s2,h1-s2 ] # Test multiple links between same pair of nodes vlan.access: red From bd9f378ca57f3dca5efc7ad1161b770d6b6fe8b1 Mon Sep 17 00:00:00 2001 From: Jeroen van Bemmel Date: Mon, 9 Dec 2024 23:38:33 -0600 Subject: [PATCH 19/19] * Add caveats * Check for overlapping clone name --- docs/plugins/node.clone.md | 4 ++++ netsim/extra/node.clone/plugin.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/plugins/node.clone.md b/docs/plugins/node.clone.md index 82e70c055..9e928ea6d 100644 --- a/docs/plugins/node.clone.md +++ b/docs/plugins/node.clone.md @@ -33,6 +33,10 @@ The plugin does not support: * link groups * cloning of components (nodes composed of multiple nodes) +When custom **ifindex** or **lag.ifindex** values are specified, the plugin automatically increments the value for each clone. This may generate overlapping/conflicting values, which will typically show up as duplicate interface names. It is the user's responsibility to ensure that custom values don't overlap. + +Avoid the use of static IPv4/v6 attributes for clones, they are not checked nor automatically updated, and will likely lead to duplicate IP addresses. + ## Examples (host-cluster)= diff --git a/netsim/extra/node.clone/plugin.py b/netsim/extra/node.clone/plugin.py index 95b0c0312..d76d8c4f0 100644 --- a/netsim/extra/node.clone/plugin.py +++ b/netsim/extra/node.clone/plugin.py @@ -40,7 +40,7 @@ def clone_lag(cnt: int, link_data: Box, nodename: str, clones: list[str], topolo for clonelist in cloned_members: for intf in clonelist[c].interfaces: # Update ifindex on interfaces if 'ifindex' in intf: - intf.ifindex += c + intf.ifindex += c # May generate overlapping values l.lag.members.append( clonelist[c] ) cloned_lag_links.append(l) return cloned_lag_links @@ -99,6 +99,12 @@ def clone_node(node: Box, topology: Box) -> None: for c in range(_p.start,_p.start+_p.count*_p.step,_p.step): clone = data.get_box(node) clone.name = strings.eval_format(name_format, node + { 'id': c } ) + + if clone.name in topology.nodes: # Check for overlapping names + log.error("Generated clone name '{clone.name}' conflicts with an existing node", + category=AttributeError, module='node.clone') + return + clone.interfaces = [] # Start clean, remove reference to original node if 'id' in node: clone.id = node.id + c - 1 # Update any explicit node ID sequentially