summaryrefslogtreecommitdiff
path: root/python/vyos/configtree.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-03-27 20:44:35 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-03-28 22:15:19 -0500
commitb2248b68afac795ad391b7203117d6d40a7ba6ed (patch)
tree40039655df4b027998cb786896ca40701b9be3d6 /python/vyos/configtree.py
parentf30a22ebde92302916282be4fe40489efaaf3b3e (diff)
downloadvyos-1x-b2248b68afac795ad391b7203117d6d40a7ba6ed.tar.gz
vyos-1x-b2248b68afac795ad391b7203117d6d40a7ba6ed.zip
configtree: T6180: add masking function mask_inclusive
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)