diff options
author | John Estabrook <jestabro@vyos.io> | 2022-02-25 16:05:03 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-04-20 18:23:04 -0500 |
commit | 5d299e9f9bfbcacec15834805dc276b5594bdabb (patch) | |
tree | 2f1ad994af07e0c343d3878f0d07543f431c6b7b /python | |
parent | b0b5654a1f99489e93ed255065818860c92045e5 (diff) | |
download | vyos-1x-5d299e9f9bfbcacec15834805dc276b5594bdabb.tar.gz vyos-1x-5d299e9f9bfbcacec15834805dc276b5594bdabb.zip |
configtree: T4235: add utility get_subtree
(cherry picked from commit ff7e2cd622cf3679cd9265b2cb766395a1830f50)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configtree.py | 12 |
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)): |