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 """ |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 12 | super(VppBondInterface, self).__init__(test) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 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) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 23 | self.set_sw_if_index(r.sw_if_index) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 24 | |
| 25 | def remove_vpp_config(self): |
| 26 | self.test.vapi.bond_delete(self.sw_if_index) |
| 27 | |
| 28 | def enslave_vpp_bond_interface(self, |
| 29 | sw_if_index, |
| 30 | is_passive, |
| 31 | is_long_timeout): |
| 32 | self.test.vapi.bond_enslave(sw_if_index, |
| 33 | self.sw_if_index, |
| 34 | is_passive, |
| 35 | is_long_timeout) |
| 36 | |
| 37 | def detach_vpp_bond_interface(self, |
| 38 | sw_if_index): |
| 39 | self.test.vapi.bond_detach_slave(sw_if_index) |
| 40 | |
| 41 | def is_interface_config_in_dump(self, dump): |
| 42 | for i in dump: |
| 43 | if i.sw_if_index == self.sw_if_index: |
| 44 | return True |
| 45 | else: |
| 46 | return False |