summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-10-27 15:22:49 +0100
committerDaniil Baturin <daniil@baturin.org>2021-01-24 18:25:14 +0100
commitb7ac68bf28c7a3966c298e7daa850d2b1db00709 (patch)
tree44b7ea68a6c01509932d5e2e4dcd62f5f7e3be3e /python/vyos
parent482e3695dcdc1fcbd89ffce12974246c7bfb8695 (diff)
downloadvyos-1x-b7ac68bf28c7a3966c298e7daa850d2b1db00709.tar.gz
vyos-1x-b7ac68bf28c7a3966c298e7daa850d2b1db00709.zip
T1773: add a script for converting the config to JSON.
It also exposes those functions in vyos.configtree
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configtree.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index 90716baf2..50040d957 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
@@ -180,6 +188,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):
check_path(path)
path_str = " ".join(map(str, path)).encode()