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 """ |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 12 | super(VppVhostInterface, self).__init__(test) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 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) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 29 | self.set_sw_if_index(r.sw_if_index) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 30 | |
| 31 | def remove_vpp_config(self): |
| 32 | self.test.vapi.delete_vhost_user_if(self.sw_if_index) |
| 33 | |
| 34 | def is_interface_config_in_dump(self, dump): |
| 35 | for i in dump: |
| 36 | if i.sw_if_index == self.sw_if_index: |
| 37 | return True |
| 38 | else: |
| 39 | return False |