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

@ -49,6 +49,15 @@ class TestBondEthernetMethods(unittest.TestCase):
self.assertEqual(5, bondethernet.mode_to_int("lacp"))
self.assertEqual(-1, bondethernet.mode_to_int("not-exist"))
def test_int_to_mode(self):
self.assertEqual("round-robin", bondethernet.int_to_mode(1))
self.assertEqual("active-backup", bondethernet.int_to_mode(2))
self.assertEqual("xor", bondethernet.int_to_mode(3))
self.assertEqual("broadcast", bondethernet.int_to_mode(4))
self.assertEqual("lacp", bondethernet.int_to_mode(5))
self.assertEqual("", bondethernet.int_to_mode(0))
self.assertEqual("", bondethernet.int_to_mode(6))
def test_get_lb(self):
self.assertEqual('l34', bondethernet.get_lb(self.cfg, "BondEthernet0"))
self.assertEqual('l2', bondethernet.get_lb(self.cfg, "BondEthernet1"))
@ -62,3 +71,12 @@ class TestBondEthernetMethods(unittest.TestCase):
self.assertEqual(4, bondethernet.lb_to_int("broadcast"))
self.assertEqual(5, bondethernet.lb_to_int("active-backup"))
self.assertEqual(-1, bondethernet.lb_to_int("not-exist"))
def test_int_to_lb(self):
self.assertEqual("l2", bondethernet.int_to_lb(0))
self.assertEqual("l34", bondethernet.int_to_lb(1))
self.assertEqual("l23", bondethernet.int_to_lb(2))
self.assertEqual("round-robin", bondethernet.int_to_lb(3))
self.assertEqual("broadcast", bondethernet.int_to_lb(4))
self.assertEqual("active-backup", bondethernet.int_to_lb(5))
self.assertEqual("", bondethernet.int_to_lb(-1))