Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 1 | from vpp_object import VppObject |
| 2 | from vpp_interface import VppInterface |
| 3 | |
| 4 | |
| 5 | class VppBondInterface(VppInterface): |
| 6 | """VPP bond interface.""" |
| 7 | |
| 8 | def __init__(self, test, mode, lb=0, |
| 9 | use_custom_mac=0, mac_address=''): |
| 10 | |
| 11 | """ Create VPP Bond interface """ |
| 12 | self._test = test |
| 13 | self.mode = mode |
| 14 | self.lb = lb |
| 15 | self.use_custom_mac = use_custom_mac |
| 16 | self.mac_address = mac_address |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 17 | |
| 18 | def add_vpp_config(self): |
| 19 | r = self.test.vapi.bond_create(self.mode, |
| 20 | self.lb, |
| 21 | self.use_custom_mac, |
| 22 | self.mac_address) |
| 23 | self._sw_if_index = r.sw_if_index |
Klement Sekera | c798bc5 | 2018-05-23 20:22:20 +0200 | [diff] [blame] | 24 | super(VppBondInterface, self).__init__(self._test) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 25 | |
| 26 | def remove_vpp_config(self): |
| 27 | self.test.vapi.bond_delete(self.sw_if_index) |
| 28 | |
| 29 | def enslave_vpp_bond_interface(self, |
| 30 | sw_if_index, |
| 31 | is_passive, |
| 32 | is_long_timeout): |
| 33 | self.test.vapi.bond_enslave(sw_if_index, |
| 34 | self.sw_if_index, |
| 35 | is_passive, |
| 36 | is_long_timeout) |
| 37 | |
| 38 | def detach_vpp_bond_interface(self, |
| 39 | sw_if_index): |
| 40 | self.test.vapi.bond_detach_slave(sw_if_index) |
| 41 | |
| 42 | def is_interface_config_in_dump(self, dump): |
| 43 | for i in dump: |
| 44 | if i.sw_if_index == self.sw_if_index: |
| 45 | return True |
| 46 | else: |
| 47 | return False |