summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-07-30 19:52:03 +0200
committerChristian Poessinger <christian@poessinger.com>2022-07-30 19:52:20 +0200
commit54227591a0eb3c7aa8c896c6ec8b1826ce070ddf (patch)
tree055851a34d7faddef0c8d5bcae0281e920eee7e2 /src/conf_mode
parent41477cc85208507be55f8db4e412ad78eae764eb (diff)
downloadvyos-1x-54227591a0eb3c7aa8c896c6ec8b1826ce070ddf.tar.gz
vyos-1x-54227591a0eb3c7aa8c896c6ec8b1826ce070ddf.zip
bridge: T4579: cleanup interface dict (remove empty keys)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-bridge.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py
index cd0d9003b..b961408db 100755
--- a/src/conf_mode/interfaces-bridge.py
+++ b/src/conf_mode/interfaces-bridge.py
@@ -61,7 +61,7 @@ def get_config(config=None):
else:
bridge.update({'member' : {'interface_remove' : tmp }})
- if dict_search('member.interface', bridge):
+ if dict_search('member.interface', bridge) != None:
# XXX: T2665: we need a copy of the dict keys for iteration, else we will get:
# RuntimeError: dictionary changed size during iteration
for interface in list(bridge['member']['interface']):
@@ -103,6 +103,14 @@ def get_config(config=None):
if 'enable_vlan' in bridge and tmp:
bridge['member']['interface'][interface].update({'has_vlan' : ''})
+ # delete empty dictionary keys - no need to run code paths if nothing is there to do
+ if 'member' in bridge:
+ if 'interface' in bridge['member'] and len(bridge['member']['interface']) == 0:
+ del bridge['member']['interface']
+
+ if len(bridge['member']) == 0:
+ del bridge['member']
+
return bridge
def verify(bridge):