summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/bond.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/bond.py b/python/vyos/ifconfig/bond.py
index 233d53688..2b9afe109 100644
--- a/python/vyos/ifconfig/bond.py
+++ b/python/vyos/ifconfig/bond.py
@@ -86,6 +86,9 @@ class BondIf(Interface):
_sysfs_get = {**Interface._sysfs_get, **{
'bond_arp_ip_target': {
'location': '/sys/class/net/{ifname}/bonding/arp_ip_target',
+ },
+ 'bond_mode': {
+ 'location': '/sys/class/net/{ifname}/bonding/mode',
}
}}
@@ -317,6 +320,19 @@ class BondIf(Interface):
return enslaved_ifs
+ def get_mode(self):
+ """
+ Return bond operation mode.
+
+ Example:
+ >>> from vyos.ifconfig import BondIf
+ >>> BondIf('bond0').get_mode()
+ '802.3ad'
+ """
+ mode = self.get_interface('bond_mode')
+ # mode is now "802.3ad 4", we are only interested in "802.3ad"
+ return mode.split()[0]
+
def set_primary(self, interface):
"""
A string (eth0, eth2, etc) specifying which slave is the primary