diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-10-27 15:22:49 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2019-10-27 15:22:49 +0100 |
commit | 2673f4790e19531fba719810a3a38e1917e57214 (patch) | |
tree | 66b805d1d93cd65da917e3bc7a0c6cef7119991a /python | |
parent | 556b528ef9cc1eca9d142ebe1f8f88cd02d536da (diff) | |
download | vyos-1x-2673f4790e19531fba719810a3a38e1917e57214.tar.gz vyos-1x-2673f4790e19531fba719810a3a38e1917e57214.zip |
T1773: add a script for converting the config to JSON.
It also exposes those functions in vyos.configtree
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configtree.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index 8832a5a63..77cffe90b 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -105,6 +105,14 @@ class ConfigTree(object): self.__to_commands.argtypes = [c_void_p] self.__to_commands.restype = c_char_p + self.__to_json = self.__lib.to_json + self.__to_json.argtypes = [c_void_p] + self.__to_json.restype = c_char_p + + self.__to_json_ast = self.__lib.to_json_ast + self.__to_json_ast.argtypes = [c_void_p] + self.__to_json_ast.restype = c_char_p + self.__set_add_value = self.__lib.set_add_value self.__set_add_value.argtypes = [c_void_p, c_char_p, c_char_p] self.__set_add_value.restype = c_int @@ -184,6 +192,12 @@ class ConfigTree(object): def to_commands(self): return self.__to_commands(self.__config).decode() + def to_json(self): + return self.__to_json(self.__config).decode() + + def to_json_ast(self): + return self.__to_json_ast(self.__config).decode() + def set(self, path, value=None, replace=True): """Set new entry in VyOS configuration. path: configuration path e.g. 'system dns forwarding listen-address' |