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 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 8 | def __init__( |
| 9 | self, |
| 10 | test, |
| 11 | mode, |
| 12 | lb=0, |
| 13 | numa_only=0, |
| 14 | enable_gso=0, |
| 15 | use_custom_mac=0, |
| 16 | mac_address="", |
| 17 | id=0xFFFFFFFF, |
| 18 | ): |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 19 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 20 | """Create VPP Bond interface""" |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 21 | super(VppBondInterface, self).__init__(test) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 22 | self.mode = mode |
| 23 | self.lb = lb |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 24 | self.numa_only = numa_only |
Steven Luong | ea71786 | 2020-07-30 07:31:40 -0700 | [diff] [blame] | 25 | self.enable_gso = enable_gso |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 26 | self.use_custom_mac = use_custom_mac |
| 27 | self.mac_address = mac_address |
Steven Luong | ea71786 | 2020-07-30 07:31:40 -0700 | [diff] [blame] | 28 | self.id = id |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 29 | |
| 30 | def add_vpp_config(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 31 | r = self.test.vapi.bond_create2( |
| 32 | self.mode, |
| 33 | self.lb, |
| 34 | self.numa_only, |
| 35 | self.enable_gso, |
| 36 | self.use_custom_mac, |
| 37 | self.mac_address, |
| 38 | self.id, |
| 39 | ) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 40 | self.set_sw_if_index(r.sw_if_index) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 41 | |
| 42 | def remove_vpp_config(self): |
| 43 | self.test.vapi.bond_delete(self.sw_if_index) |
| 44 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 45 | def add_member_vpp_bond_interface( |
| 46 | self, sw_if_index, is_passive=0, is_long_timeout=0 |
| 47 | ): |
| 48 | self.test.vapi.bond_add_member( |
| 49 | sw_if_index, self.sw_if_index, is_passive, is_long_timeout |
| 50 | ) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 51 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 52 | def detach_vpp_bond_interface(self, sw_if_index): |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 53 | self.test.vapi.bond_detach_member(sw_if_index) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 54 | |
| 55 | def is_interface_config_in_dump(self, dump): |
| 56 | for i in dump: |
| 57 | if i.sw_if_index == self.sw_if_index: |
| 58 | return True |
| 59 | else: |
| 60 | return False |