Allow bondethernet members list to be empty, and omitted from the YAML config
This commit is contained in:
@ -171,6 +171,9 @@ def validate_bondethernets(yaml):
|
|||||||
msgs.append("bondethernet %s can only have load-balance if in mode XOR or LACP" % (ifname))
|
msgs.append("bondethernet %s can only have load-balance if in mode XOR or LACP" % (ifname))
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
|
if not 'interfaces' in iface:
|
||||||
|
continue
|
||||||
|
|
||||||
for member in iface['interfaces']:
|
for member in iface['interfaces']:
|
||||||
if (None, None) == interface.get_by_name(yaml, member):
|
if (None, None) == interface.get_by_name(yaml, member):
|
||||||
msgs.append("bondethernet %s member %s does not exist" % (ifname, member))
|
msgs.append("bondethernet %s member %s does not exist" % (ifname, member))
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
bondethernets:
|
bondethernets:
|
||||||
BondEthernet0:
|
BondEthernet0:
|
||||||
interfaces: [ GigabitEthernet3/0/0, GigabitEthernet3/0/1 ]
|
interfaces: [ GigabitEthernet3/0/0, GigabitEthernet3/0/1 ]
|
||||||
|
BondEthernet1:
|
||||||
|
mode: xor
|
||||||
|
|
||||||
interfaces:
|
interfaces:
|
||||||
GigabitEthernet3/0/0:
|
GigabitEthernet3/0/0:
|
||||||
@ -59,6 +61,10 @@ interfaces:
|
|||||||
encapsulation:
|
encapsulation:
|
||||||
dot1ad: 501
|
dot1ad: 501
|
||||||
exact-match: False
|
exact-match: False
|
||||||
|
|
||||||
|
BondEthernet1:
|
||||||
|
mtu: 1500
|
||||||
|
|
||||||
vxlan_tunnel1:
|
vxlan_tunnel1:
|
||||||
mtu: 2000
|
mtu: 2000
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ loopback:
|
|||||||
---
|
---
|
||||||
bondethernet:
|
bondethernet:
|
||||||
description: str(exclude='\'"',len=64,required=False)
|
description: str(exclude='\'"',len=64,required=False)
|
||||||
interfaces: list(str(matches='.*GigabitEthernet[0-9]+/[0-9]+/[0-9]+'))
|
interfaces: list(str(matches='.*GigabitEthernet[0-9]+/[0-9]+/[0-9]+'),required=False)
|
||||||
mode: enum('round-robin','active-backup','broadcast','lacp','xor',required=False)
|
mode: enum('round-robin','active-backup','broadcast','lacp','xor',required=False)
|
||||||
load-balance: enum('l2','l23','l34',required=False)
|
load-balance: enum('l2','l23','l34',required=False)
|
||||||
---
|
---
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
test:
|
test:
|
||||||
description: "An example of well formed bondethernet"
|
description: "An example of well formed bondethernets"
|
||||||
errors:
|
errors:
|
||||||
count: 0
|
count: 0
|
||||||
---
|
---
|
||||||
@ -8,6 +8,10 @@ bondethernets:
|
|||||||
interfaces: [ GigabitEthernet1/0/0, GigabitEthernet1/0/1 ]
|
interfaces: [ GigabitEthernet1/0/0, GigabitEthernet1/0/1 ]
|
||||||
BondEthernet1:
|
BondEthernet1:
|
||||||
interfaces: [ GigabitEthernet2/0/0, GigabitEthernet2/0/1 ]
|
interfaces: [ GigabitEthernet2/0/0, GigabitEthernet2/0/1 ]
|
||||||
|
mode: xor
|
||||||
|
load-balance: l2
|
||||||
|
BondEthernet2:
|
||||||
|
mode: round-robin
|
||||||
|
|
||||||
interfaces:
|
interfaces:
|
||||||
GigabitEthernet1/0/0:
|
GigabitEthernet1/0/0:
|
||||||
@ -35,3 +39,6 @@ interfaces:
|
|||||||
mtu: 2000
|
mtu: 2000
|
||||||
lcp: "be1.2000"
|
lcp: "be1.2000"
|
||||||
addresses: [ 192.0.2.9/29, 2001:db8:1::1/64 ]
|
addresses: [ 192.0.2.9/29, 2001:db8:1::1/64 ]
|
||||||
|
|
||||||
|
BondEthernet2:
|
||||||
|
mtu: 1500
|
||||||
|
@ -275,7 +275,10 @@ class VPPApiDumper(VPPApi):
|
|||||||
for idx, iface in self.cache['bondethernets'].items():
|
for idx, iface in self.cache['bondethernets'].items():
|
||||||
bond = {"description": ""}
|
bond = {"description": ""}
|
||||||
if iface.sw_if_index in self.cache['bondethernet_members']:
|
if iface.sw_if_index in self.cache['bondethernet_members']:
|
||||||
bond['interfaces'] = [self.cache['interfaces'][x].interface_name for x in self.cache['bondethernet_members'][iface.sw_if_index]]
|
members = [self.cache['interfaces'][x].interface_name for x in self.cache['bondethernet_members'][iface.sw_if_index]]
|
||||||
|
if len(members) > 0:
|
||||||
|
bond['interfaces'] = members
|
||||||
|
|
||||||
mode = bondethernet.int_to_mode(iface.mode)
|
mode = bondethernet.int_to_mode(iface.mode)
|
||||||
bond['mode'] = mode
|
bond['mode'] = mode
|
||||||
if mode in ['xor', 'lacp']:
|
if mode in ['xor', 'lacp']:
|
||||||
|
Reference in New Issue
Block a user