blob: e04e3054fd2db88b738d131dd15e856279d69bbf [file] [log] [blame]
Neale Ranns5f8f6172019-04-18 10:23:56 +00001#!/usr/bin/env python
2"""
3 NHRP objects
4"""
5
6from vpp_object import VppObject
7
8
9def find_nhrp(test, ne):
10 ns = test.vapi.nhrp_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
18class VppNhrp(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.nhrp_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
38 def remove_vpp_config(self):
39 r = self._test.vapi.nhrp_entry_add_del(
40 is_add=0,
41 entry={
42 'nh_table_id': self.table_id,
43 'sw_if_index': self.itf.sw_if_index,
44 'peer': self.peer,
45 })
46
47 def query_vpp_config(self):
48 return find_nhrp(self._test, self)
49
50 def object_id(self):
51 return ("nhrp-%s-%s" % (self.itf, self.peer))