dpdk: output switch information
[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         for entry in dump:
19             if entry.sw_if_index == self.sw_if_index:
20                 return entry
21
22     def add_vpp_config(self):
23         use_random_mac = True if self._mac_addr else False
24         reply = self._test.vapi.tap_create_v2(
25             id=self._tap_id,
26             use_random_mac=use_random_mac,
27             mac_address=self._mac_addr)
28         self.set_sw_if_index(reply.sw_if_index)
29         self._test.registry.register(self, self.test.logger)
30
31     def remove_vpp_config(self):
32         self._test.vapi.tap_delete_v2(sw_if_index=self.sw_if_index)
33
34     def query_vpp_config(self):
35         dump = self.get_vpp_dump()
36         if dump:
37             return True
38         return False
39
40     def object_id(self):
41         return "tap-%s" % self._tap_id