2017-03-01 15:12:11 -08:00
|
|
|
|
|
|
|
from vpp_interface import VppInterface
|
|
|
|
|
|
|
|
|
|
|
|
class VppMPLSTunnelInterface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP MPLS Tunnel interface
|
|
|
|
"""
|
|
|
|
|
2017-05-24 09:15:43 -07:00
|
|
|
def __init__(self, test, paths, is_multicast=0, is_l2=0):
|
2017-03-01 15:12:11 -08:00
|
|
|
""" Create MPLS Tunnel interface """
|
2018-06-24 22:49:33 +02:00
|
|
|
super(VppMPLSTunnelInterface, self).__init__(test)
|
2017-03-01 15:12:11 -08:00
|
|
|
self.t_paths = paths
|
|
|
|
self.is_multicast = is_multicast
|
2017-05-24 09:15:43 -07:00
|
|
|
self.is_l2 = is_l2
|
2018-05-01 05:17:55 -07:00
|
|
|
self.encoded_paths = []
|
2017-03-01 15:12:11 -08:00
|
|
|
for path in self.t_paths:
|
2018-05-01 05:17:55 -07:00
|
|
|
self.encoded_paths.append(path.encode())
|
2018-02-23 05:29:09 -08:00
|
|
|
|
2018-05-01 05:17:55 -07:00
|
|
|
def add_vpp_config(self):
|
|
|
|
reply = self.test.vapi.mpls_tunnel_add_del(
|
|
|
|
0xffffffff,
|
|
|
|
self.encoded_paths,
|
|
|
|
is_multicast=self.is_multicast,
|
|
|
|
l2_only=self.is_l2)
|
|
|
|
self.set_sw_if_index(reply.sw_if_index)
|
|
|
|
self.tunnel_index = reply.tunnel_index
|
2018-09-25 07:22:36 -07:00
|
|
|
self._test.registry.register(self, self._test.logger)
|
2017-03-01 15:12:11 -08:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
2018-05-01 05:17:55 -07:00
|
|
|
reply = self.test.vapi.mpls_tunnel_add_del(
|
|
|
|
self.sw_if_index,
|
|
|
|
self.encoded_paths,
|
|
|
|
is_add=0)
|
2018-09-25 07:22:36 -07:00
|
|
|
|
|
|
|
def query_vpp_config(self):
|
|
|
|
dump = self._test.vapi.mpls_tunnel_dump()
|
|
|
|
for t in dump:
|
2018-05-01 05:17:55 -07:00
|
|
|
if self.sw_if_index == t.mt_tunnel.mt_sw_if_index and \
|
|
|
|
self.tunnel_index == t.mt_tunnel.mt_tunnel_index:
|
2018-09-25 07:22:36 -07:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def object_id(self):
|
2018-09-26 05:07:25 -07:00
|
|
|
return ("mpls-tunnel%d-%d" % (self.tunnel_index,
|
|
|
|
self.sw_if_index))
|