From 09efa0550dd169e30a851513781b611dd84e9c79 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 27 Jun 2021 11:12:05 +0200 Subject: op-mode: bond: T2546: implement "show interface bond * slaves" command Add implementation with XML and Python. --- python/vyos/ifconfig/bond.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'python/vyos/ifconfig') 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 -- cgit v1.2.3