Assert BondEthernet devices also exist as interfaces. Assert MTU of members is equal to that of the BondEthernet interface
This commit is contained in:
@ -63,10 +63,19 @@ def validate_bondethernets(yaml):
|
||||
|
||||
for ifname, iface in yaml['bondethernets'].items():
|
||||
logger.debug("bondethernet %s: %s" % (ifname, iface))
|
||||
bond_ifname, bond_iface = interface.get_by_name(yaml, ifname)
|
||||
bond_mtu = 1500
|
||||
if not bond_iface:
|
||||
msgs.append("bondethernet %s does not exist in interfaces" % (ifname))
|
||||
result = False
|
||||
else:
|
||||
bond_mtu = interface.get_mtu(yaml, bond_ifname)
|
||||
|
||||
for member in iface['interfaces']:
|
||||
if (None, None) == interface.get_by_name(yaml, member):
|
||||
msgs.append("bondethernet %s member %s does not exist" % (ifname, member))
|
||||
result = False
|
||||
continue
|
||||
|
||||
if interface.has_sub(yaml, member):
|
||||
msgs.append("bondethernet %s member %s has sub-interface(s)" % (ifname, member))
|
||||
@ -77,4 +86,8 @@ def validate_bondethernets(yaml):
|
||||
if interface.has_address(yaml, member):
|
||||
msgs.append("bondethernet %s member %s has an address" % (ifname, member))
|
||||
result = False
|
||||
member_mtu = interface.get_mtu(yaml, member)
|
||||
if member_mtu != bond_mtu:
|
||||
msgs.append("bondethernet %s member %s MTU %d does not match BondEthernet MTU %d" % (ifname, member, member_mtu, bond_mtu))
|
||||
result = False
|
||||
return result, msgs
|
||||
|
@ -25,9 +25,9 @@ interfaces:
|
||||
mtu: 2000
|
||||
|
||||
GigabitEthernet3/0/0:
|
||||
mtu: 9000
|
||||
mtu: 3000
|
||||
GigabitEthernet3/0/1:
|
||||
mtu: 9000
|
||||
mtu: 3000
|
||||
|
||||
GigabitEthernet4/0/0:
|
||||
mtu: 9000
|
||||
|
@ -31,6 +31,7 @@ interfaces:
|
||||
mtu: 3000
|
||||
|
||||
BondEthernet0:
|
||||
mtu: 3000
|
||||
description: "BE0 with two xconnected sub-ints"
|
||||
sub-interfaces:
|
||||
100:
|
||||
|
22
unittest/yaml/error-bondethernet5.yaml
Normal file
22
unittest/yaml/error-bondethernet5.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
test:
|
||||
description: "Members of a BondEthernet must have the same MTU as their bond"
|
||||
errors:
|
||||
expected:
|
||||
- "bondethernet .* member .* MTU 2500 does not match BondEthernet MTU 3000"
|
||||
- "bondethernet .* member .* MTU 2000 does not match BondEthernet MTU 3000"
|
||||
count: 2
|
||||
---
|
||||
bondethernets:
|
||||
BondEthernet0:
|
||||
interfaces: [ GigabitEthernet2/0/0, GigabitEthernet2/0/1 ]
|
||||
|
||||
interfaces:
|
||||
GigabitEthernet2/0/0:
|
||||
mtu: 2500
|
||||
description: "LAG with default MTU, needs to be 3000"
|
||||
GigabitEthernet2/0/1:
|
||||
mtu: 2000
|
||||
description: "LAG with default MTU, needs to be 3000"
|
||||
|
||||
BondEthernet0:
|
||||
mtu: 3000
|
20
unittest/yaml/error-bondethernet6.yaml
Normal file
20
unittest/yaml/error-bondethernet6.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
test:
|
||||
description: "A BondEthernet entry must also be an interface"
|
||||
errors:
|
||||
expected:
|
||||
- "bondethernet .* does not exist in interfaces"
|
||||
count: 1
|
||||
---
|
||||
bondethernets:
|
||||
BondEthernet0:
|
||||
interfaces: [ GigabitEthernet2/0/0, GigabitEthernet2/0/1 ]
|
||||
|
||||
interfaces:
|
||||
GigabitEthernet2/0/0:
|
||||
description: "LAG #2"
|
||||
GigabitEthernet2/0/1:
|
||||
description: "LAG #2"
|
||||
|
||||
# BondEthenet0:
|
||||
# description: "This entry should exist"
|
||||
# mtu: 1500
|
Reference in New Issue
Block a user