Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 1 | from vpp_interface import VppInterface |
| 2 | |
| 3 | |
| 4 | class VppVhostInterface(VppInterface): |
| 5 | """VPP vhost interface.""" |
| 6 | |
| 7 | def __init__(self, test, sock_filename, is_server=0, renumber=0, |
| 8 | custom_dev_instance=0, use_custom_mac=0, mac_address='', |
| 9 | tag=''): |
| 10 | |
| 11 | """ Create VPP Vhost interface """ |
| 12 | self._test = test |
| 13 | self.is_server = is_server |
| 14 | self.sock_filename = sock_filename |
| 15 | self.renumber = renumber |
| 16 | self.custom_dev_instance = custom_dev_instance |
| 17 | self.use_custom_mac = use_custom_mac |
| 18 | self.mac_address = mac_address |
| 19 | self.tag = tag |
| 20 | |
| 21 | def add_vpp_config(self): |
| 22 | r = self.test.vapi.create_vhost_user_if(self.is_server, |
| 23 | self.sock_filename, |
| 24 | self.renumber, |
| 25 | self.custom_dev_instance, |
| 26 | self.use_custom_mac, |
| 27 | self.mac_address, |
| 28 | self.tag) |
| 29 | self._sw_if_index = r.sw_if_index |
| 30 | super(VppVhostInterface, self).__init__(self._test) |
| 31 | |
| 32 | def remove_vpp_config(self): |
| 33 | self.test.vapi.delete_vhost_user_if(self.sw_if_index) |
| 34 | |
| 35 | def is_interface_config_in_dump(self, dump): |
| 36 | for i in dump: |
| 37 | if i.sw_if_index == self.sw_if_index: |
| 38 | return True |
| 39 | else: |
| 40 | return False |