summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/interface.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-07-24 17:20:50 +0200
committerChristian Poessinger <christian@poessinger.com>2020-07-25 17:30:12 +0200
commitf81b0443cf09c34cb1f2060094e3eb294b8fa192 (patch)
treeda5c3b85a8fc3cd113ceae3a2f2a8b8c770954e9 /python/vyos/ifconfig/interface.py
parentadd7eaebe7b8ebd4e143eb939d3ba7871ead0502 (diff)
downloadvyos-1x-f81b0443cf09c34cb1f2060094e3eb294b8fa192.tar.gz
vyos-1x-f81b0443cf09c34cb1f2060094e3eb294b8fa192.zip
bonding: ifconfig: T2653: move to get_config_dict()
The current VyOS CLI parser code written in Python contains a ton of duplicates which I can also hold myself accountable for - or maybe mainly me - depends on the angle of judge.
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
-rw-r--r--python/vyos/ifconfig/interface.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 1fe4f74f2..7e887db1b 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -205,6 +205,7 @@ class Interface(Control):
# make sure the ifname is the first argument and not from the dict
self.config['ifname'] = ifname
+ self._admin_state_down_cnt = 0
# we must have updated config before initialising the Interface
super().__init__(**kargs)
@@ -594,7 +595,13 @@ class Interface(Control):
if not int(flags, 16) & 1:
return None
- return self.set_interface('admin_state', state)
+ if state == 'up':
+ self._admin_state_down_cnt -= 1
+ if self._admin_state_down_cnt < 1:
+ return self.set_interface('admin_state', state)
+ else:
+ self._admin_state_down_cnt += 1
+ return self.set_interface('admin_state', state)
def set_proxy_arp(self, enable):
"""
@@ -829,8 +836,11 @@ class Interface(Control):
# There are some items in the configuration which can only be applied
# if this instance is not bound to a bridge. This should be checked
# by the caller but better save then sorry!
- if not config.get('is_bridge_member', False):
- # Bind interface instance into VRF
+ if not any(k in ['is_bond_member', 'is_bridge_member'] for k in config):
+ # Bind interface to given VRF or unbind it if vrf node is not set.
+ # unbinding will call 'ip link set dev eth0 nomaster' which will
+ # also drop the interface out of a bridge or bond - thus this is
+ # checked before
self.set_vrf(config.get('vrf', ''))
# DHCP options