virtio: Add RX queue full statisitics
[vpp.git] / test / vpp_mpls_tunnel_interface.py
1 from vpp_interface import VppInterface
2
3
4 class VppMPLSTunnelInterface(VppInterface):
5     """
6     VPP MPLS Tunnel interface
7     """
8
9     def __init__(self, test, paths, is_multicast=0, is_l2=0):
10         """Create MPLS Tunnel interface"""
11         super(VppMPLSTunnelInterface, self).__init__(test)
12         self.t_paths = paths
13         self.is_multicast = is_multicast
14         self.is_l2 = is_l2
15         self.encoded_paths = []
16         for path in self.t_paths:
17             self.encoded_paths.append(path.encode())
18
19     def add_vpp_config(self):
20         reply = self.test.vapi.mpls_tunnel_add_del(
21             0xFFFFFFFF,
22             self.encoded_paths,
23             is_multicast=self.is_multicast,
24             l2_only=self.is_l2,
25         )
26         self.set_sw_if_index(reply.sw_if_index)
27         self.tunnel_index = reply.tunnel_index
28         self._test.registry.register(self, self._test.logger)
29
30     def remove_vpp_config(self):
31         reply = self.test.vapi.mpls_tunnel_add_del(
32             self.sw_if_index, self.encoded_paths, is_add=0
33         )
34
35     def query_vpp_config(self):
36         dump = self._test.vapi.mpls_tunnel_dump()
37         for t in dump:
38             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             ):
42                 return True
43         return False
44
45     def object_id(self):
46         return "mpls-tunnel%d-%d" % (self.tunnel_index, self.sw_if_index)