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 | |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 8 | def __init__(self, test, mode, lb=0, numa_only=0, |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 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 |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 15 | self.numa_only = numa_only |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 16 | self.use_custom_mac = use_custom_mac |
| 17 | self.mac_address = mac_address |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 18 | |
| 19 | def add_vpp_config(self): |
| 20 | r = self.test.vapi.bond_create(self.mode, |
| 21 | self.lb, |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 22 | self.numa_only, |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 23 | self.use_custom_mac, |
| 24 | self.mac_address) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 25 | self.set_sw_if_index(r.sw_if_index) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 26 | |
| 27 | def remove_vpp_config(self): |
| 28 | self.test.vapi.bond_delete(self.sw_if_index) |
| 29 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 30 | def add_member_vpp_bond_interface(self, |
| 31 | sw_if_index, |
| 32 | is_passive=0, |
| 33 | is_long_timeout=0): |
| 34 | self.test.vapi.bond_add_member(sw_if_index, |
| 35 | self.sw_if_index, |
| 36 | is_passive, |
| 37 | is_long_timeout) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 38 | |
| 39 | def detach_vpp_bond_interface(self, |
| 40 | sw_if_index): |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 41 | self.test.vapi.bond_detach_member(sw_if_index) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 42 | |
| 43 | def is_interface_config_in_dump(self, dump): |
| 44 | for i in dump: |
| 45 | if i.sw_if_index == self.sw_if_index: |
| 46 | return True |
| 47 | else: |
| 48 | return False |