summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2025-01-21 17:23:50 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2025-01-21 17:23:50 +0000
commit63bd816bdfcc041d10941dab51a9a0792218ef42 (patch)
tree8d938dc051f959326df6080ed9de4eb35451eff7 /python
parentf1316bbcf852dfc29bb29cb5c4203eb4b625bc15 (diff)
downloadvyos-1x-63bd816bdfcc041d10941dab51a9a0792218ef42.tar.gz
vyos-1x-63bd816bdfcc041d10941dab51a9a0792218ef42.zip
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.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/vpp/interface/bond.py20
1 files changed, 20 insertions, 0 deletions
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)