blob: 598936136ad63d4bb8b490639ad6058a06fce4c2 [file] [log] [blame]
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001
2from vpp_interface import VppInterface
Neale Ranns0f26c5a2017-03-01 15:12:11 -08003
4
5class VppMPLSTunnelInterface(VppInterface):
6 """
7 VPP MPLS Tunnel interface
8 """
9
Neale Rannsda78f952017-05-24 09:15:43 -070010 def __init__(self, test, paths, is_multicast=0, is_l2=0):
Neale Ranns0f26c5a2017-03-01 15:12:11 -080011 """ Create MPLS Tunnel interface """
Klement Sekerab9ef2732018-06-24 22:49:33 +020012 super(VppMPLSTunnelInterface, self).__init__(test)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080013 self.t_paths = paths
14 self.is_multicast = is_multicast
Neale Rannsda78f952017-05-24 09:15:43 -070015 self.is_l2 = is_l2
Neale Ranns097fa662018-05-01 05:17:55 -070016 self.encoded_paths = []
17 for path in self.t_paths:
18 self.encoded_paths.append(path.encode())
Neale Ranns0f26c5a2017-03-01 15:12:11 -080019
20 def add_vpp_config(self):
Neale Ranns097fa662018-05-01 05:17:55 -070021 reply = self.test.vapi.mpls_tunnel_add_del(
22 0xffffffff,
23 self.encoded_paths,
24 is_multicast=self.is_multicast,
25 l2_only=self.is_l2)
26 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(
32 self.sw_if_index,
33 self.encoded_paths,
34 is_add=0)
Neale Ranns6a30b5f2018-09-25 07:22:36 -070035
36 def query_vpp_config(self):
37 dump = self._test.vapi.mpls_tunnel_dump()
38 for t in dump:
Neale Ranns097fa662018-05-01 05:17:55 -070039 if self.sw_if_index == t.mt_tunnel.mt_sw_if_index and \
40 self.tunnel_index == t.mt_tunnel.mt_tunnel_index:
Neale Ranns6a30b5f2018-09-25 07:22:36 -070041 return True
42 return False
43
Neale Ranns6a30b5f2018-09-25 07:22:36 -070044 def object_id(self):
Neale Rannsf5fa5ae2018-09-26 05:07:25 -070045 return ("mpls-tunnel%d-%d" % (self.tunnel_index,
46 self.sw_if_index))