Add MPLS config option and interface.is_mpls()
Also add tests and documentation
This commit is contained in:
@ -306,6 +306,8 @@ exist as a PHY in VPP (ie. `HundredGigabitEthernet12/0/0`) or as a specified `Bo
|
|||||||
If it is not specified, the link is considered admin 'up'.
|
If it is not specified, the link is considered admin 'up'.
|
||||||
* ***device-type***: An optional interface type in VPP. Currently the only supported vlaue is
|
* ***device-type***: An optional interface type in VPP. Currently the only supported vlaue is
|
||||||
`dpdk`, and it is used to generate correct mock interfaces if the `--novpp` flag is used.
|
`dpdk`, and it is used to generate correct mock interfaces if the `--novpp` flag is used.
|
||||||
|
* ***mpls***: An optional boolean that configures MPLS on the interface or sub-interface. The
|
||||||
|
default value is `false`, if the field is not specified, which means MPLS will not be enabled.
|
||||||
|
|
||||||
Further, top-level interfaces, that is to say those that do not have an encapsulation, are permitted
|
Further, top-level interfaces, that is to say those that do not have an encapsulation, are permitted
|
||||||
to have any number of sub-interfaces specified by `subid`, an integer between [0,2G), which further
|
to have any number of sub-interfaces specified by `subid`, an integer between [0,2G), which further
|
||||||
@ -330,6 +332,7 @@ interfaces:
|
|||||||
lcp: "ice0"
|
lcp: "ice0"
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
addresses: [ 192.0.2.1/30, 2001:db8:1::1/64 ]
|
addresses: [ 192.0.2.1/30, 2001:db8:1::1/64 ]
|
||||||
|
mpls: true
|
||||||
sub-interfaces:
|
sub-interfaces:
|
||||||
1234:
|
1234:
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
@ -338,6 +341,7 @@ interfaces:
|
|||||||
1235:
|
1235:
|
||||||
mtu: 1500
|
mtu: 1500
|
||||||
lcp: "ice0.qinq"
|
lcp: "ice0.qinq"
|
||||||
|
mpls: true
|
||||||
addresses: [ 192.0.2.9/30, 2001:db8:3::1/64 ]
|
addresses: [ 192.0.2.9/30, 2001:db8:3::1/64 ]
|
||||||
encapsulation:
|
encapsulation:
|
||||||
dot1q: 1234
|
dot1q: 1234
|
||||||
|
@ -701,3 +701,14 @@ def validate_interfaces(yaml):
|
|||||||
result = False
|
result = False
|
||||||
|
|
||||||
return result, msgs
|
return result, msgs
|
||||||
|
|
||||||
|
|
||||||
|
def is_mpls(yaml, ifname):
|
||||||
|
"""Returns True if the interface 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
|
||||||
|
@ -277,3 +277,10 @@ class TestInterfaceMethods(unittest.TestCase):
|
|||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
interface.get_admin_state(self.cfg, "GigabitEthernet1/0/0.102")
|
interface.get_admin_state(self.cfg, "GigabitEthernet1/0/0.102")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_is_mpls(self):
|
||||||
|
self.assertTrue(interface.is_mpls(self.cfg, "GigabitEthernet1/0/1"))
|
||||||
|
self.assertTrue(interface.is_mpls(self.cfg, "GigabitEthernet1/0/1.101"))
|
||||||
|
self.assertFalse(interface.is_mpls(self.cfg, "GigabitEthernet1/0/0"))
|
||||||
|
self.assertFalse(interface.is_mpls(self.cfg, "GigabitEthernet1/0/0.100"))
|
||||||
|
self.assertFalse(interface.is_mpls(self.cfg, "notexist"))
|
||||||
|
@ -20,7 +20,8 @@ interfaces:
|
|||||||
lcp: "ice12-0-0"
|
lcp: "ice12-0-0"
|
||||||
mac: f2:01:00:12:00:00
|
mac: f2:01:00:12:00:00
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
addresses: [ 192.0.2.17/30, 2001:DB8:3::1/64 ]
|
addresses: [ 192.0.2.17/30, 2001:db8:3::1/64 ]
|
||||||
|
mpls: true
|
||||||
sub-interfaces:
|
sub-interfaces:
|
||||||
1234:
|
1234:
|
||||||
mtu: 1200
|
mtu: 1200
|
||||||
|
@ -52,6 +52,7 @@ interface:
|
|||||||
sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False)
|
sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False)
|
||||||
l2xc: str(required=False)
|
l2xc: str(required=False)
|
||||||
state: enum('up', 'down', required=False)
|
state: enum('up', 'down', required=False)
|
||||||
|
mpls: bool(required=False)
|
||||||
device-type: enum('dpdk', required=False)
|
device-type: enum('dpdk', required=False)
|
||||||
---
|
---
|
||||||
sub-interface:
|
sub-interface:
|
||||||
@ -62,6 +63,7 @@ sub-interface:
|
|||||||
encapsulation: include('encapsulation',required=False)
|
encapsulation: include('encapsulation',required=False)
|
||||||
l2xc: str(required=False)
|
l2xc: str(required=False)
|
||||||
state: enum('up', 'down', required=False)
|
state: enum('up', 'down', required=False)
|
||||||
|
mpls: bool(required=False)
|
||||||
---
|
---
|
||||||
encapsulation:
|
encapsulation:
|
||||||
dot1q: int(min=1,max=4095,required=False)
|
dot1q: int(min=1,max=4095,required=False)
|
||||||
|
@ -23,6 +23,7 @@ interfaces:
|
|||||||
mtu: 9216
|
mtu: 9216
|
||||||
lcp: "e1"
|
lcp: "e1"
|
||||||
addresses: [ "192.0.2.1/30", "2001:db8:1::1/64" ]
|
addresses: [ "192.0.2.1/30", "2001:db8:1::1/64" ]
|
||||||
|
mpls: true
|
||||||
sub-interfaces:
|
sub-interfaces:
|
||||||
100:
|
100:
|
||||||
lcp: "foo"
|
lcp: "foo"
|
||||||
@ -33,6 +34,7 @@ interfaces:
|
|||||||
exact-match: True
|
exact-match: True
|
||||||
lcp: "e1.100"
|
lcp: "e1.100"
|
||||||
addresses: [ "10.0.2.1/30" ]
|
addresses: [ "10.0.2.1/30" ]
|
||||||
|
mpls: true
|
||||||
102:
|
102:
|
||||||
encapsulation:
|
encapsulation:
|
||||||
dot1ad: 100
|
dot1ad: 100
|
||||||
|
Reference in New Issue
Block a user