From fa6413272ee2a3330f9c4012084705d1effc86d9 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sun, 22 Nov 2020 19:11:27 -0600 Subject: defaults: T3082: multi_to_list must distinguish between values and defaults --- python/vyos/xml/definition.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'python/vyos/xml/definition.py') 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 -- cgit v1.2.3