From 3508feea888bfc0d95eb8928d98afd50bc335eb9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 1 Oct 2020 19:43:12 +0200 Subject: configdict: T2372: use config.exists() when probing for interface removal We must use exists() as get_config_dict() will always return {} - even when an empty interface node like +macsec macsec1 { +} exists. --- python/vyos/configdict.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 58ecd3f17..660d779d4 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -290,8 +290,12 @@ def get_interface_dict(config, base, ifname=''): config.set_level(base + [ifname]) dict = config.get_config_dict([], key_mangling=('-', '_'), get_first_key=True) - # Check if interface has been removed - if dict == {}: + # Check if interface has been removed. We must use exists() as get_config_dict() + # will always return {} - even when an empty interface node like + # +macsec macsec1 { + # +} + # exists. + if not config.exists([]): dict.update({'deleted' : ''}) # Add interface instance name into dictionary -- cgit v1.2.3