fib: fib api updates
[vpp.git] / test / vpp_mpls_tunnel_interface.py
1
2 from vpp_interface import VppInterface
3
4
5 class VppMPLSTunnelInterface(VppInterface):
6     """
7     VPP MPLS Tunnel interface
8     """
9
10     def __init__(self, test, paths, is_multicast=0, is_l2=0):
11         """ Create MPLS Tunnel interface """
12         super(VppMPLSTunnelInterface, self).__init__(test)
13         self.t_paths = paths
14         self.is_multicast = is_multicast
15         self.is_l2 = is_l2
16         self.encoded_paths = []
17         for path in self.t_paths:
18             self.encoded_paths.append(path.encode())
19
20     def add_vpp_config(self):
21         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
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,
33             self.encoded_paths,
34             is_add=0)
35
36     def query_vpp_config(self):
37         dump = self._test.vapi.mpls_tunnel_dump()
38         for t in dump:
39             if self.sw_if_index == t.mt_tunnel.mt_sw_if_index and \
40                self.tunnel_index == t.mt_tunnel.mt_tunnel_index:
41                 return True
42         return False
43
44     def object_id(self):
45         return ("mpls-tunnel%d-%d" % (self.tunnel_index,
46                                       self.sw_if_index))