summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-09-15 18:52:18 +0200
committerChristian Poessinger <christian@poessinger.com>2020-09-15 18:56:05 +0200
commitf8a6fa6a5a574851292e77e08cff16cdf6195334 (patch)
tree3d9f180c55cd78a3e83799e1846d1ae082fef2b5
parentbf1d6fff80eebb579f2c33b1352a7162b8474730 (diff)
downloadvyos-1x-f8a6fa6a5a574851292e77e08cff16cdf6195334.tar.gz
vyos-1x-f8a6fa6a5a574851292e77e08cff16cdf6195334.zip
vyos.configdict: T2515: leaf_node_changed() should return list or None
-rw-r--r--python/vyos/configdict.py6
-rwxr-xr-xsrc/conf_mode/interfaces-l2tpv3.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index e8c0aa5b3..bfc70b772 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -148,8 +148,8 @@ def T2665_default_dict_cleanup(dict):
def leaf_node_changed(conf, path):
"""
Check if a leaf node was altered. If it has been altered - values has been
- changed, or it was added/removed, we will return the old value. If nothing
- has been changed, None is returned
+ changed, or it was added/removed, we will return a list containing the old
+ value(s). If nothing has been changed, None is returned
"""
from vyos.configdiff import get_config_diff
D = get_config_diff(conf, key_mangling=('-', '_'))
@@ -157,7 +157,7 @@ def leaf_node_changed(conf, path):
(new, old) = D.get_value_diff(path)
if new != old:
if isinstance(old, str):
- return old
+ return [old]
elif isinstance(old, list):
if isinstance(new, str):
new = [new]
diff --git a/src/conf_mode/interfaces-l2tpv3.py b/src/conf_mode/interfaces-l2tpv3.py
index 8250a3df8..144cee5fe 100755
--- a/src/conf_mode/interfaces-l2tpv3.py
+++ b/src/conf_mode/interfaces-l2tpv3.py
@@ -56,10 +56,11 @@ def get_config(config=None):
# To delete an l2tpv3 interface we need the current tunnel and session-id
if 'deleted' in l2tpv3:
tmp = leaf_node_changed(conf, ['tunnel-id'])
- l2tpv3.update({'tunnel_id': tmp})
+ # leaf_node_changed() returns a list
+ l2tpv3.update({'tunnel_id': tmp[0]})
tmp = leaf_node_changed(conf, ['session-id'])
- l2tpv3.update({'session_id': tmp})
+ l2tpv3.update({'session_id': tmp[0]})
return l2tpv3