vxlan: add tunnel cache to graph node
[vpp.git] / test / vpp_devices.py
1 from vpp_interface import VppInterface
2
3
4 class VppTAPInterface(VppInterface):
5
6     @property
7     def tap_id(self):
8         """TAP id"""
9         return self._tap_id
10
11     def __init__(self, test, tap_id=0xffffffff, mac_addr=None):
12         self._test = test
13         self._tap_id = tap_id
14         self._mac_addr = mac_addr
15
16     def get_vpp_dump(self):
17         dump = self._test.vapi.sw_interface_tap_v2_dump(
18             sw_if_index=self.sw_if_index)
19         return dump
20
21     def add_vpp_config(self):
22         reply = self._test.vapi.tap_create_v2(
23             id=self._tap_id,
24             use_random_mac=bool(self._mac_addr),
25             mac_address=self._mac_addr)
26         self.set_sw_if_index(reply.sw_if_index)
27         self._test.registry.register(self, self.test.logger)
28
29     def remove_vpp_config(self):
30         self._test.vapi.tap_delete_v2(sw_if_index=self.sw_if_index)
31
32     def query_vpp_config(self):
33         dump = self.get_vpp_dump()
34         return bool(dump)
35
36     def object_id(self):
37         return "tap-%s" % self._tap_id