summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/interface.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-07-19 20:45:29 +0200
committerChristian Poessinger <christian@poessinger.com>2020-07-25 15:36:07 +0200
commita25d7095e009469d8ef60b63deddd94d30921723 (patch)
treedefbe9b68845e714e2d3ddf93b5191592be97f61 /python/vyos/ifconfig/interface.py
parent2b1c3dc86fe4033030855d61bf453aa730b6c230 (diff)
downloadvyos-1x-a25d7095e009469d8ef60b63deddd94d30921723.tar.gz
vyos-1x-a25d7095e009469d8ef60b63deddd94d30921723.zip
bridge: 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. While providing a new update() method in vyos.ifconfig.interfaces() this is extended for bridge interfaces in the derived bridge class. Signed-off-by: Christian Poessinger <christian@poessinger.com>
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
-rw-r--r--python/vyos/ifconfig/interface.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index be3617f7d..ea770af23 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -922,6 +922,31 @@ class Interface(Control):
if 'mtu' in config:
self.set_mtu(config.get('mtu'))
+ # Delete old IPv6 EUI64 addresses before changing MAC
+ tmp = jmespath.search('ipv6.address.eui64_old', config)
+ if tmp:
+ for addr in tmp:
+ self.del_ipv6_eui64_address(addr)
+
+ # Change interface MAC address - re-set to real hardware address (hw-id)
+ # if custom mac is removed. Skip if bond member.
+ if 'is_bond_member' not in config:
+ mac = config.get('hw_id')
+ if 'mac' in config:
+ mac = config.get('mac')
+ if mac:
+ self.set_mac(mac)
+
+ # Add IPv6 EUI-based addresses
+ tmp = jmespath.search('ipv6.address.eui64', config)
+ if tmp:
+ # XXX: T2636 workaround: convert string to a list with one element
+ if isinstance(tmp, str):
+ tmp = [tmp]
+ for addr in tmp:
+ self.add_ipv6_eui64_address(addr)
+
+
# Interface administrative state
state = 'down' if 'disable' in config else 'up'
self.set_admin_state(state)