fib: Compiile time option to use 8-8-8-8 stride tries for FIB rather
[vpp.git] / test / vpp_teib.py
1 #!/usr/bin/env python3
2 """
3   TEIB objects
4 """
5
6 from vpp_object import VppObject
7
8
9 def find_teib(test, ne):
10     ns = test.vapi.teib_dump()
11     for n in ns:
12         if ne.peer == str(n.entry.peer) \
13            and ne.itf._sw_if_index == n.entry.sw_if_index:
14             return True
15     return False
16
17
18 class VppTeib(VppObject):
19
20     def __init__(self, test, itf, peer, nh, table_id=0):
21         self._test = test
22         self.table_id = table_id
23         self.peer = peer
24         self.itf = itf
25         self.nh = nh
26
27     def add_vpp_config(self):
28         r = self._test.vapi.teib_entry_add_del(
29             is_add=1,
30             entry={
31                 'nh_table_id': self.table_id,
32                 'sw_if_index': self.itf.sw_if_index,
33                 'peer': self.peer,
34                 'nh': self.nh,
35             })
36         self._test.registry.register(self, self._test.logger)
37         return self
38
39     def remove_vpp_config(self):
40         r = self._test.vapi.teib_entry_add_del(
41             is_add=0,
42             entry={
43                 'nh_table_id': self.table_id,
44                 'sw_if_index': self.itf.sw_if_index,
45                 'peer': self.peer,
46             })
47
48     def query_vpp_config(self):
49         return find_teib(self._test, self)
50
51     def object_id(self):
52         return ("teib-%s-%s" % (self.itf, self.peer))