Add the ability to set any mode/lb on bonds

This requires a schema change, adding 'mode' and 'load-balance' fields,
a semantic invariant that 'load-balance' can only be set in the case of
LACP and XOR bonds, a mapper from the mode/lb strings, ie.
"round-robin" to their VPP numeric counterparts, a bunch of unit tests.

Then in the reconciler, changing bonds (__bond_has_diff()) will
invalidate any LCP or sub-interfaces built on them, so those will have
to be pruned. create_bondethernet() will now create (or re-create)
the bond with the correct flags.

Unit-tests, YAML tests and the integration test all pass.

Updated config-guide.
This commit is contained in:
Pim van Pelt
2022-04-05 15:05:03 +00:00
parent 289138da94
commit 2360d28d0a
11 changed files with 241 additions and 13 deletions

View File

@ -31,7 +31,34 @@ class TestBondEthernetMethods(unittest.TestCase):
def test_enumerators(self):
ifs = bondethernet.get_bondethernets(self.cfg)
self.assertEqual(len(ifs), 1)
self.assertEqual(len(ifs), 3)
self.assertIn("BondEthernet0", ifs)
self.assertIn("BondEthernet1", ifs)
self.assertIn("BondEthernet2", ifs)
self.assertNotIn("BondEthernet-noexist", ifs)
def test_get_mode(self):
self.assertEqual('lacp', bondethernet.get_mode(self.cfg, "BondEthernet0"))
self.assertEqual('xor', bondethernet.get_mode(self.cfg, "BondEthernet1"))
def test_mode_to_int(self):
self.assertEqual(1, bondethernet.mode_to_int("round-robin"))
self.assertEqual(2, bondethernet.mode_to_int("active-backup"))
self.assertEqual(3, bondethernet.mode_to_int("xor"))
self.assertEqual(4, bondethernet.mode_to_int("broadcast"))
self.assertEqual(5, bondethernet.mode_to_int("lacp"))
self.assertEqual(-1, bondethernet.mode_to_int("not-exist"))
def test_get_lb(self):
self.assertEqual('l34', bondethernet.get_lb(self.cfg, "BondEthernet0"))
self.assertEqual('l2', bondethernet.get_lb(self.cfg, "BondEthernet1"))
self.assertIsNone(bondethernet.get_lb(self.cfg, "BondEthernet2"))
def test_lb_to_int(self):
self.assertEqual(0, bondethernet.lb_to_int("l2"))
self.assertEqual(1, bondethernet.lb_to_int("l34"))
self.assertEqual(2, bondethernet.lb_to_int("l23"))
self.assertEqual(3, bondethernet.lb_to_int("round-robin"))
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"))