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
|
result = False
|
||||||
|
|
||||||
return result, msgs
|
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("loop1", ifs)
|
||||||
self.assertIn("loop2", ifs)
|
self.assertIn("loop2", ifs)
|
||||||
self.assertNotIn("loop-noexist", 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"))
|
||||||
|
@ -91,6 +91,7 @@ loopbacks:
|
|||||||
mtu: 1500
|
mtu: 1500
|
||||||
mac: 02:de:ad:11:be:ef
|
mac: 02:de:ad:11:be:ef
|
||||||
addresses: [ 10.0.2.1/24, 2001:db8:2::1/64 ]
|
addresses: [ 10.0.2.1/24, 2001:db8:2::1/64 ]
|
||||||
|
mpls: true
|
||||||
|
|
||||||
bridgedomains:
|
bridgedomains:
|
||||||
bd1:
|
bd1:
|
||||||
|
@ -33,6 +33,7 @@ loopback:
|
|||||||
lcp: str(max=15,matches='[a-z]+[a-z0-9-]*',required=False)
|
lcp: str(max=15,matches='[a-z]+[a-z0-9-]*',required=False)
|
||||||
mtu: int(min=128,max=9216,required=False)
|
mtu: int(min=128,max=9216,required=False)
|
||||||
addresses: list(ip_interface(),min=1,max=6,required=False)
|
addresses: list(ip_interface(),min=1,max=6,required=False)
|
||||||
|
mpls: bool(required=False)
|
||||||
---
|
---
|
||||||
bondethernet:
|
bondethernet:
|
||||||
description: str(exclude='\'"',len=64,required=False)
|
description: str(exclude='\'"',len=64,required=False)
|
||||||
|
@ -6,6 +6,7 @@ loopbacks:
|
|||||||
mtu: 2000
|
mtu: 2000
|
||||||
lcp: "loop56789012345"
|
lcp: "loop56789012345"
|
||||||
addresses: [ 192.0.2.1/29, 2001:db8::1/64 ]
|
addresses: [ 192.0.2.1/29, 2001:db8::1/64 ]
|
||||||
|
mpls: true
|
||||||
loop2:
|
loop2:
|
||||||
description: "Loopback, invalid because it has an address but no LCP"
|
description: "Loopback, invalid because it has an address but no LCP"
|
||||||
mtu: 2000
|
mtu: 2000
|
||||||
|
Reference in New Issue
Block a user