diff options
author | John Estabrook <jestabro@vyos.io> | 2024-03-27 20:44:35 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-05-03 13:27:27 -0500 |
commit | 841747cbb4e9252fed60d4a6c6227b41c4986e84 (patch) | |
tree | 781a5b887938d554222630a17ce16347514b3080 /python/vyos | |
parent | b83b9c4492f8af8228363d2dad2e748d621e4da7 (diff) | |
download | vyos-1x-841747cbb4e9252fed60d4a6c6227b41c4986e84.tar.gz vyos-1x-841747cbb4e9252fed60d4a6c6227b41c4986e84.zip |
configtree: T6180: add masking function mask_inclusive
(cherry picked from commit b2248b68afac795ad391b7203117d6d40a7ba6ed)
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/configtree.py | 24 |
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) |