summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-03 13:56:49 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-03 13:57:00 +0200
commit90e58236898918a3bc27ce451e245647e712ad40 (patch)
treeba0a9ddbe895d0d645407cb0b02687edc8e488d4
parent98e14d27dee4e8e0619abd479583aac472a5fc08 (diff)
downloadvyos-1x-90e58236898918a3bc27ce451e245647e712ad40.tar.gz
vyos-1x-90e58236898918a3bc27ce451e245647e712ad40.zip
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.
-rw-r--r--python/vyos/ifconfig.py11
1 files changed, 8 insertions, 3 deletions
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)