summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-02-25 16:05:03 -0600
committerJohn Estabrook <jestabro@vyos.io>2022-02-28 13:42:24 -0600
commitff7e2cd622cf3679cd9265b2cb766395a1830f50 (patch)
tree2ad559070e1db708a6423f98e3b4b17d5c981f1b
parent257345cd152c23a465332dea4af034244007aaa7 (diff)
downloadvyos-1x-ff7e2cd622cf3679cd9265b2cb766395a1830f50.tar.gz
vyos-1x-ff7e2cd622cf3679cd9265b2cb766395a1830f50.zip
configtree: T4235: add utility get_subtree
-rw-r--r--python/vyos/configtree.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index 866f24e47..0ec15cf40 100644
--- a/python/vyos/configtree.py
+++ b/python/vyos/configtree.py
@@ -126,6 +126,10 @@ class ConfigTree(object):
self.__set_tag.argtypes = [c_void_p, c_char_p]
self.__set_tag.restype = c_int
+ self.__get_subtree = self.__lib.get_subtree
+ self.__get_subtree.argtypes = [c_void_p, c_char_p]
+ self.__get_subtree.restype = c_void_p
+
self.__destroy = self.__lib.destroy
self.__destroy.argtypes = [c_void_p]
@@ -291,6 +295,14 @@ class ConfigTree(object):
else:
raise ConfigTreeError("Path [{}] doesn't exist".format(path_str))
+ def get_subtree(self, path, with_node=False):
+ check_path(path)
+ path_str = " ".join(map(str, path)).encode()
+
+ res = self.__get_subtree(self.__config, path_str, with_node)
+ subt = ConfigTree(address=res)
+ return subt
+
class Diff:
def __init__(self, left, right, path=[], libpath=LIBPATH):
if not (isinstance(left, ConfigTree) and isinstance(right, ConfigTree)):