summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-12-26 12:02:37 +0100
committerChristian Breunig <christian@breunig.cc>2025-12-26 12:03:54 +0100
commit7d765f35fb3a559769b36c554cb9bd5191cab9be (patch)
tree5446343705f243b347ffa7f2d71ecddbf18953b9 /python
parentf4f19d33b5568fe14117b0c55fc4ccf423541730 (diff)
downloadvyos-1x-7d765f35fb3a559769b36c554cb9bd5191cab9be.tar.gz
vyos-1x-7d765f35fb3a559769b36c554cb9bd5191cab9be.zip
bond: T2416: simplify collection of bond member interfaces
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/bond.py15
1 files changed, 4 insertions, 11 deletions
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 <http://www.gnu.org/licenses/>.
-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):
"""