Allow MPLS on loopbacks too -- needed for BVIs and such. Add tests.
This commit is contained in:
@ -96,3 +96,14 @@ def validate_loopbacks(yaml):
|
||||
result = False
|
||||
|
||||
return result, msgs
|
||||
|
||||
|
||||
def is_mpls(yaml, ifname):
|
||||
"""Returns True if the loopback exists and has mpls enabled. Returns false otherwise."""
|
||||
ifname, iface = get_by_name(yaml, ifname)
|
||||
try:
|
||||
if iface["mpls"] == True:
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
|
@ -50,3 +50,8 @@ class TestLoopbackMethods(unittest.TestCase):
|
||||
self.assertIn("loop1", ifs)
|
||||
self.assertIn("loop2", ifs)
|
||||
self.assertNotIn("loop-noexist", ifs)
|
||||
|
||||
def test_is_mpls(self):
|
||||
self.assertTrue(loopback.is_mpls(self.cfg, "loop1"))
|
||||
self.assertFalse(loopback.is_mpls(self.cfg, "loop2"))
|
||||
self.assertFalse(loopback.is_mpls(self.cfg, "loop-noexist"))
|
||||
|
Reference in New Issue
Block a user