From 74fcfa7fb48601febd0d9d0e4d53db20b28e4898 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 3 Sep 2019 13:57:57 +0200 Subject: Python/ifconfig: T1557: bonding: add get_slaves() call --- python/vyos/ifconfig.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'python') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 0dba21ab1..e58c7e0bb 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1103,3 +1103,15 @@ class BondIf(Interface): return self._write_sysfs('/sys/class/net/{}/bonding/slaves' .format(self._ifname), '-' + interface) + def get_slaves(self): + """ + Return a list with all configured slave interfaces on this bond. + + Example: + >>> from vyos.ifconfig import Interface + >>> BondIf('bond0').get_slaves() + ['eth1', 'eth2'] + """ + slaves = self._read_sysfs('/sys/class/net/{}/bonding/slaves' + .format(self._ifname)) + return list(map(str, slaves.split())) -- cgit v1.2.3