Assert source/target L2XC are the same MTU

This commit is contained in:
Pim van Pelt
2022-03-15 22:32:55 +00:00
parent 686cd45158
commit e7e3958ceb
2 changed files with 44 additions and 0 deletions

36
unittest/error-l2xc7.yaml Normal file
View File

@ -0,0 +1,36 @@
test:
description: "L2 cross connect source and target must have the same MTU"
errors:
expected:
- "interface .* l2xc target MTU .* does not match source MTU .*"
- "sub-interface .* l2xc target MTU .* does not match source MTU .*"
count: 6
---
interfaces:
GigabitEthernet1/0/0:
mtu: 9216
l2xc: GigabitEthernet1/0/1
GigabitEthernet1/0/1:
mtu: 9215
l2xc: GigabitEthernet1/0/0
GigabitEthernet2/0/0:
mtu: 9216
sub-interfaces:
100:
mtu: 1500
l2xc: GigabitEthernet2/0/0.200
200:
mtu: 1501
l2xc: GigabitEthernet2/0/0.100
GigabitEthernet3/0/0:
mtu: 9000
l2xc: GigabitEthernet3/0/1.100
GigabitEthernet3/0/1:
mtu: 3000
sub-interfaces:
100:
mtu: 2000
l2xc: GigabitEthernet3/0/0

View File

@ -393,6 +393,10 @@ def validate_interfaces(yaml):
if not get_by_name(yaml, iface['l2xc']):
msgs.append("interface %s l2xc target %s does not exist" % (ifname, iface['l2xc']))
result = False
target_mtu = get_mtu(yaml, iface['l2xc'])
if target_mtu != iface_mtu:
msgs.append("interface %s l2xc target MTU %d does not match source MTU %d" % (ifname, target_mtu, iface_mtu))
result = False
if not is_l2xc_target_interface_unique(yaml, iface['l2xc']):
msgs.append("interface %s l2xc target %s is not unique" % (ifname, iface['l2xc']))
result = False
@ -455,6 +459,10 @@ def validate_interfaces(yaml):
if not get_by_name(yaml, sub_iface['l2xc']):
msgs.append("sub-interface %s l2xc target %s does not exist" % (sub_ifname, sub_iface['l2xc']))
result = False
target_mtu = get_mtu(yaml, sub_iface['l2xc'])
if target_mtu != sub_mtu:
msgs.append("sub-interface %s l2xc target MTU %d does not match source MTU %d" % (ifname, target_mtu, sub_mtu))
result = False
if not is_l2xc_target_interface_unique(yaml, sub_iface['l2xc']):
msgs.append("sub-interface %s l2xc target %s is not unique" % (sub_ifname, sub_iface['l2xc']))
result = False