blob: 6c8941a3f19d9cc166a44f1b5211c7e2afb5f685 [file] [log] [blame]
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001from vpp_interface import VppInterface
Neale Ranns0f26c5a2017-03-01 15:12:11 -08002
3
4class VppMPLSTunnelInterface(VppInterface):
5 """
6 VPP MPLS Tunnel interface
7 """
8
Neale Rannsda78f952017-05-24 09:15:43 -07009 def __init__(self, test, paths, is_multicast=0, is_l2=0):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020010 """Create MPLS Tunnel interface"""
Klement Sekerab9ef2732018-06-24 22:49:33 +020011 super(VppMPLSTunnelInterface, self).__init__(test)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080012 self.t_paths = paths
13 self.is_multicast = is_multicast
Neale Rannsda78f952017-05-24 09:15:43 -070014 self.is_l2 = is_l2
Neale Ranns097fa662018-05-01 05:17:55 -070015 self.encoded_paths = []
16 for path in self.t_paths:
17 self.encoded_paths.append(path.encode())
Neale Ranns0f26c5a2017-03-01 15:12:11 -080018
19 def add_vpp_config(self):
Neale Ranns097fa662018-05-01 05:17:55 -070020 reply = self.test.vapi.mpls_tunnel_add_del(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020021 0xFFFFFFFF,
Neale Ranns097fa662018-05-01 05:17:55 -070022 self.encoded_paths,
23 is_multicast=self.is_multicast,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020024 l2_only=self.is_l2,
25 )
Neale Ranns097fa662018-05-01 05:17:55 -070026 self.set_sw_if_index(reply.sw_if_index)
27 self.tunnel_index = reply.tunnel_index
Neale Ranns6a30b5f2018-09-25 07:22:36 -070028 self._test.registry.register(self, self._test.logger)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080029
30 def remove_vpp_config(self):
Neale Ranns097fa662018-05-01 05:17:55 -070031 reply = self.test.vapi.mpls_tunnel_add_del(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020032 self.sw_if_index, self.encoded_paths, is_add=0
33 )
Neale Ranns6a30b5f2018-09-25 07:22:36 -070034
35 def query_vpp_config(self):
36 dump = self._test.vapi.mpls_tunnel_dump()
37 for t in dump:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020038 if (
39 self.sw_if_index == t.mt_tunnel.mt_sw_if_index
40 and self.tunnel_index == t.mt_tunnel.mt_tunnel_index
41 ):
Neale Ranns6a30b5f2018-09-25 07:22:36 -070042 return True
43 return False
44
Neale Ranns6a30b5f2018-09-25 07:22:36 -070045 def object_id(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020046 return "mpls-tunnel%d-%d" % (self.tunnel_index, self.sw_if_index)