summaryrefslogtreecommitdiff
path: root/python/vyos/xml/definition.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2020-08-30 12:33:00 -0500
committerGitHub <noreply@github.com>2020-08-30 12:33:00 -0500
commit9f3f7812eeec009e12133d3cd354d4a63e378ac8 (patch)
treef582fdaf8c0aa5ce769d63ab54518233fa2fb4bc /python/vyos/xml/definition.py
parentbab1534e0fc1e6da538414b8b032342eb2598f03 (diff)
parentb40c52682a25664f7018ab8b4e5ba6f467f10d17 (diff)
downloadvyos-1x-9f3f7812eeec009e12133d3cd354d4a63e378ac8.tar.gz
vyos-1x-9f3f7812eeec009e12133d3cd354d4a63e378ac8.zip
Merge pull request #536 from jestabro/T2636
config: T2636: get_config_dict() returns a list on multi node by default
Diffstat (limited to 'python/vyos/xml/definition.py')
-rw-r--r--python/vyos/xml/definition.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/vyos/xml/definition.py b/python/vyos/xml/definition.py
index 098e64f7e..6d6fcb5c7 100644
--- a/python/vyos/xml/definition.py
+++ b/python/vyos/xml/definition.py
@@ -281,6 +281,23 @@ class XML(dict):
return _flatten(lpath, len(lpath), d)
+ def multi_to_list(self, lpath, conf):
+ r = {}
+ for k in conf:
+ # key mangling could also be done here
+ # it would prevent two parsing of the config tree
+ # under = k.replace('-','_')
+ under = k
+ fpath = lpath + [k]
+ if isinstance(conf[k],dict):
+ r[under] = self.multi_to_list(fpath, conf[k])
+ continue
+ value = conf[k]
+ if self.is_multi(fpath) and not isinstance(value, list):
+ value = [value]
+ r[under] = value
+ return r
+
# from functools import lru_cache
# @lru_cache(maxsize=100)
# XXX: need to use cachetool instead - for later