From 7d765f35fb3a559769b36c554cb9bd5191cab9be Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Fri, 26 Dec 2025 12:02:37 +0100 Subject: bond: T2416: simplify collection of bond member interfaces --- python/vyos/ifconfig/bond.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig/bond.py b/python/vyos/ifconfig/bond.py index ba31ae0c9..0d4c035c7 100644 --- a/python/vyos/ifconfig/bond.py +++ b/python/vyos/ifconfig/bond.py @@ -13,8 +13,6 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . -import os - from vyos.ifconfig.interface import Interface from vyos.utils.dict import dict_search from vyos.utils.assertion import assert_list @@ -90,6 +88,9 @@ class BondIf(Interface): 'bond_arp_ip_target': { 'location': '/sys/class/net/{ifname}/bonding/arp_ip_target', }, + 'bond_members': { + 'location': '/sys/class/net/{ifname}/bonding/slaves', + }, 'bond_mode': { 'location': '/sys/class/net/{ifname}/bonding/mode', } @@ -335,15 +336,7 @@ class BondIf(Interface): >>> BondIf('bond0').get_slaves() ['eth1', 'eth2'] """ - enslaved_ifs = [] - # retrieve real enslaved interfaces from OS kernel - sysfs_bond = '/sys/class/net/{}'.format(self.config['ifname']) - if os.path.isdir(sysfs_bond): - for directory in os.listdir(sysfs_bond): - if 'lower_' in directory: - enslaved_ifs.append(directory.replace('lower_', '')) - - return enslaved_ifs + return self.get_interface('bond_members').split() def get_mode(self): """ -- cgit v1.2.3