From 63bd816bdfcc041d10941dab51a9a0792218ef42 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Tue, 21 Jan 2025 17:23:50 +0000 Subject: bonding: set interface state up after adding By default VPP creates interface via API with the 'down' state. Add methods to set interface state UP/DOWN. It probably should reuse the common Class in the future. We do not have classes for interface (vpp) state settings. --- python/vyos/vpp/interface/bond.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'python') diff --git a/python/vyos/vpp/interface/bond.py b/python/vyos/vpp/interface/bond.py index 28aae74a1..a90f2950b 100644 --- a/python/vyos/vpp/interface/bond.py +++ b/python/vyos/vpp/interface/bond.py @@ -112,3 +112,23 @@ class BondInterface: a.kernel_delete() """ self.vpp.lcp_pair_del(self.ifname, self.kernel_interface) + + def set_state_up(self): + """Set Bond interface state to UP + Example: + from vyos.vpp.interface import BondInterface + a = BondInterface(ifname='bond0') + a.set_state_up() + """ + bond_if_index = self.vpp.get_sw_if_index(self.ifname) + self.vpp.api.sw_interface_set_flags(sw_if_index=bond_if_index, flags=1) + + def set_state_down(self): + """Set Bond interface state to DOWN + Example: + from vyos.vpp.interface import BondInterface + a = BondInterface(ifname='bond0') + a.set_state_down() + """ + bond_if_index = self.vpp.get_sw_if_index(self.ifname) + self.vpp.api.sw_interface_set_flags(sw_if_index=bond_if_index, flags=0) -- cgit v1.2.3