From 90e58236898918a3bc27ce451e245647e712ad40 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 3 Sep 2019 13:56:49 +0200 Subject: Python/ifconfig: T1557: bonding: disable interface prior enslaving them An interface can only be added to a bond if it is in 'down' state. If interface is in 'up' state, the following Kernel error will be thrown: > bond0: eth1 is up - this may be due to an out of date ifenslave. --- python/vyos/ifconfig.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 5247ac3d7..0dba21ab1 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1077,15 +1077,20 @@ class BondIf(Interface): def add_port(self, interface): """ - Enslave physical interface to bond + Enslave physical interface to bond. Example: >>> from vyos.ifconfig import Interface >>> BondIf('bond0').add_port('eth0') >>> BondIf('bond0').add_port('eth1') """ + # An interface can only be added to a bond if it is in 'down' state. If + # interface is in 'up' state, the following Kernel error will be thrown: + # bond0: eth1 is up - this may be due to an out of date ifenslave. + Interface(interface).state = 'down' + return self._write_sysfs('/sys/class/net/{}/bonding/slaves' - .format(self._ifname), '+' + target) + .format(self._ifname), '+' + interface) def del_port(self, interface): """ @@ -1096,5 +1101,5 @@ class BondIf(Interface): >>> BondIf('bond0').del_port('eth1') """ return self._write_sysfs('/sys/class/net/{}/bonding/slaves' - .format(self._ifname), '-' + target) + .format(self._ifname), '-' + interface) -- cgit v1.2.3