summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-06-27 11:12:05 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-27 11:14:12 +0200
commit09efa0550dd169e30a851513781b611dd84e9c79 (patch)
tree8420086b1b50ed5f60822222d3b83edf3c38cf55 /python
parentd34cd9572dd6285b92d3e0f8f80dc109a674c205 (diff)
downloadvyos-1x-09efa0550dd169e30a851513781b611dd84e9c79.tar.gz
vyos-1x-09efa0550dd169e30a851513781b611dd84e9c79.zip
op-mode: bond: T2546: implement "show interface bond * slaves" command
Add implementation with XML and Python.
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