Assert that an interface cannot l2 cross connect to itself
This commit is contained in:
16
unittest/error-l2xc8.yaml
Normal file
16
unittest/error-l2xc8.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
test:
|
||||||
|
description: "L2 cross connect source and target cannot be the same"
|
||||||
|
errors:
|
||||||
|
expected:
|
||||||
|
- "interface .* l2xc target cannot be itself"
|
||||||
|
- "sub-interface .* l2xc target cannot be itself"
|
||||||
|
count: 2
|
||||||
|
---
|
||||||
|
interfaces:
|
||||||
|
GigabitEthernet1/0/0:
|
||||||
|
l2xc: GigabitEthernet1/0/0
|
||||||
|
|
||||||
|
GigabitEthernet2/0/0:
|
||||||
|
sub-interfaces:
|
||||||
|
100:
|
||||||
|
l2xc: GigabitEthernet2/0/0.100
|
@ -393,6 +393,9 @@ def validate_interfaces(yaml):
|
|||||||
if not get_by_name(yaml, iface['l2xc']):
|
if not get_by_name(yaml, iface['l2xc']):
|
||||||
msgs.append("interface %s l2xc target %s does not exist" % (ifname, iface['l2xc']))
|
msgs.append("interface %s l2xc target %s does not exist" % (ifname, iface['l2xc']))
|
||||||
result = False
|
result = False
|
||||||
|
if iface['l2xc'] == ifname:
|
||||||
|
msgs.append("interface %s l2xc target cannot be itself" % (ifname))
|
||||||
|
result = False
|
||||||
target_mtu = get_mtu(yaml, iface['l2xc'])
|
target_mtu = get_mtu(yaml, iface['l2xc'])
|
||||||
if target_mtu != iface_mtu:
|
if target_mtu != iface_mtu:
|
||||||
msgs.append("interface %s l2xc target MTU %d does not match source MTU %d" % (ifname, target_mtu, iface_mtu))
|
msgs.append("interface %s l2xc target MTU %d does not match source MTU %d" % (ifname, target_mtu, iface_mtu))
|
||||||
@ -459,6 +462,9 @@ def validate_interfaces(yaml):
|
|||||||
if not get_by_name(yaml, sub_iface['l2xc']):
|
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']))
|
msgs.append("sub-interface %s l2xc target %s does not exist" % (sub_ifname, sub_iface['l2xc']))
|
||||||
result = False
|
result = False
|
||||||
|
if sub_iface['l2xc'] == sub_ifname:
|
||||||
|
msgs.append("sub-interface %s l2xc target cannot be itself" % (sub_ifname))
|
||||||
|
result = False
|
||||||
target_mtu = get_mtu(yaml, sub_iface['l2xc'])
|
target_mtu = get_mtu(yaml, sub_iface['l2xc'])
|
||||||
if target_mtu != sub_mtu:
|
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))
|
msgs.append("sub-interface %s l2xc target MTU %d does not match source MTU %d" % (ifname, target_mtu, sub_mtu))
|
||||||
|
Reference in New Issue
Block a user