summaryrefslogtreecommitdiff
path: root/python/vyos/configtree.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-03-31 15:00:28 +0300
committerGitHub <noreply@github.com>2024-03-31 15:00:28 +0300
commitf62827c80466dc7ae74a2f8a1b360f59603bc3fa (patch)
tree25fd9193764bc84ba6f22ec30f0e9de7359e6af9 /python/vyos/configtree.py
parent252d03d6e419aae14ae75caed38d1b1001c916a2 (diff)
parentb6c5e66cc44fdec21e6731d98a1065e2adf87b3b (diff)
downloadvyos-1x-f62827c80466dc7ae74a2f8a1b360f59603bc3fa.tar.gz
vyos-1x-f62827c80466dc7ae74a2f8a1b360f59603bc3fa.zip
Merge pull request #3211 from jestabro/tree-mask
T6185: simplify marshalling of section and config data for config-sync
Diffstat (limited to 'python/vyos/configtree.py')
-rw-r--r--python/vyos/configtree.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index 423fe01ed..e4b282d72 100644
--- a/python/vyos/configtree.py
+++ b/python/vyos/configtree.py
@@ -401,6 +401,30 @@ def union(left, right, libpath=LIBPATH):
return tree
+def mask_inclusive(left, right, libpath=LIBPATH):
+ if not (isinstance(left, ConfigTree) and isinstance(right, ConfigTree)):
+ raise TypeError("Arguments must be instances of ConfigTree")
+
+ try:
+ __lib = cdll.LoadLibrary(libpath)
+ __mask_tree = __lib.mask_tree
+ __mask_tree.argtypes = [c_void_p, c_void_p]
+ __mask_tree.restype = c_void_p
+ __get_error = __lib.get_error
+ __get_error.argtypes = []
+ __get_error.restype = c_char_p
+
+ res = __mask_tree(left._get_config(), right._get_config())
+ except Exception as e:
+ raise ConfigTreeError(e)
+ if not res:
+ msg = __get_error().decode()
+ raise ConfigTreeError(msg)
+
+ tree = ConfigTree(address=res)
+
+ return tree
+
def reference_tree_to_json(from_dir, to_file, libpath=LIBPATH):
try:
__lib = cdll.LoadLibrary(libpath)