diff options
author | John Estabrook <jestabro@vyos.io> | 2020-11-22 19:11:27 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2020-11-22 20:07:09 -0600 |
commit | fa6413272ee2a3330f9c4012084705d1effc86d9 (patch) | |
tree | dda0305753cd2d0038d20494a28ba5b6f15b64b5 /python/vyos/xml/definition.py | |
parent | 9311dcda624f871b063b8a52fa56d04e807b7890 (diff) | |
download | vyos-1x-fa6413272ee2a3330f9c4012084705d1effc86d9.tar.gz vyos-1x-fa6413272ee2a3330f9c4012084705d1effc86d9.zip |
defaults: T3082: multi_to_list must distinguish between values and defaults
Diffstat (limited to 'python/vyos/xml/definition.py')
-rw-r--r-- | python/vyos/xml/definition.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/python/vyos/xml/definition.py b/python/vyos/xml/definition.py index a25fc50c5..f556c5ced 100644 --- a/python/vyos/xml/definition.py +++ b/python/vyos/xml/definition.py @@ -255,7 +255,7 @@ class XML(dict): if not flat: # _flatten will make this conversion - d = self.multi_to_list(lpath, d) + d = self.multi_to_list(lpath, d, defaults=True) r = {} for k in d: @@ -284,7 +284,7 @@ class XML(dict): return _flatten(lpath, len(lpath), d) - def multi_to_list(self, lpath, conf): + def multi_to_list(self, lpath, conf, defaults=False): r = {} for k in conf: # key mangling could also be done here @@ -293,11 +293,14 @@ class XML(dict): under = k fpath = lpath + [k] if isinstance(conf[k],dict): - r[under] = self.multi_to_list(fpath, conf[k]) + r[under] = self.multi_to_list(fpath, conf[k], defaults) continue value = conf[k] if self.is_multi(fpath) and not isinstance(value, list): - value = [value] + if not defaults: + value = [value] + else: + value = value.split(' ') r[under] = value return r |