From 7a49b5bde4cc220977bd5719a1ecd2ffabe03ca9 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sun, 12 Apr 2026 15:09:11 -0500 Subject: T8488: add wrapper for mask_exclusive --- python/vyos/configtree.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index 61ef6428c..2876130cf 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -584,13 +584,38 @@ def mask_inclusive(left, right, libpath=LIBPATH): try: __lib = cdll.LoadLibrary(libpath) __mask_tree = __lib.mask_tree - __mask_tree.argtypes = [c_void_p, c_void_p] + __mask_tree.argtypes = [c_void_p, c_void_p, c_bool] __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_tree(), right.get_tree()) + res = __mask_tree(left.get_tree(), right.get_tree(), False) + except Exception as e: + raise ConfigTreeError(e) + if not res: + msg = __get_error().decode() + raise ConfigTreeError(msg) + + tree = ConfigTree(address=res) + + return tree + + +def mask_exclusive(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, c_bool] + __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_tree(), right.get_tree(), True) except Exception as e: raise ConfigTreeError(e) if not res: -- cgit v1.2.3