From e7e3958ceba2c1a78df0ac2fe8a9cf79b466cc79 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 15 Mar 2022 22:32:55 +0000 Subject: [PATCH] Assert source/target L2XC are the same MTU --- unittest/error-l2xc7.yaml | 36 ++++++++++++++++++++++++++++++++++++ validator/interface.py | 8 ++++++++ 2 files changed, 44 insertions(+) create mode 100644 unittest/error-l2xc7.yaml diff --git a/unittest/error-l2xc7.yaml b/unittest/error-l2xc7.yaml new file mode 100644 index 0000000..8cc595d --- /dev/null +++ b/unittest/error-l2xc7.yaml @@ -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 diff --git a/validator/interface.py b/validator/interface.py index e196c67..454b8f6 100644 --- a/validator/interface.py +++ b/validator/interface.py @@ -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