Add bond/bridge YAML emitter

Add int_to_mode() and int_to_lb() in config/bondethernet.py to map back
the retrieved values from VPP into their config strings.

Implement bond and bridge settings dumper, dumping all settings even if
they are default. This helps the user understand the configurable
options.
This commit is contained in:
Pim van Pelt
2022-04-05 15:50:49 +00:00
parent 2360d28d0a
commit 0a755a0745
4 changed files with 202 additions and 0 deletions

View File

@ -81,6 +81,20 @@ def mode_to_int(mode):
return -1
def int_to_mode(mode):
""" Returns the string representation in VPP of a given bondethernet mode,
or "" if 'mode' is not a valid id.
See src/vnet/bonding/bond.api and schema.yaml for valid pairs. """
ret = { 1: 'round-robin', 2: 'active-backup', 3: 'xor', 4: 'broadcast', 5: 'lacp' }
try:
return ret[mode]
except:
pass
return ""
def get_lb(yaml, ifname):
""" Return the loadbalance strategy of the BondEthernet as a string. Only
'xor' and 'lacp' modes have loadbalance strategies, so return None if
@ -116,6 +130,21 @@ def lb_to_int(lb):
return -1
def int_to_lb(lb):
""" Returns the string representation in VPP of a given load-balance strategy,
or "" if 'lb' is not a valid int.
See src/vnet/bonding/bond.api and schema.yaml for valid pairs, although
bond.api defined more than we use in vppcfg. """
ret = { 0: 'l2', 1: 'l34', 2: 'l23', 3: 'round-robin', 4: 'broadcast', 5: 'active-backup' }
try:
return ret[lb]
except:
pass
return ""
def validate_bondethernets(yaml):
result = True
msgs = []