diff options
author | John Estabrook <jestabro@vyos.io> | 2023-03-19 20:05:51 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-03-29 10:28:14 -0500 |
commit | e5758160c8a25523df9c8cde9baf958466bf1881 (patch) | |
tree | 4f154b4b423b92bca71e5d8b7500863a0b72fbe3 /python/vyos/configtree.py | |
parent | c57494027bd3b5865634c62ccd97f44e1d75c546 (diff) | |
download | vyos-1x-e5758160c8a25523df9c8cde9baf958466bf1881.tar.gz vyos-1x-e5758160c8a25523df9c8cde9baf958466bf1881.zip |
configdiff: T5089: add union of configtrees for unit test
Diffstat (limited to 'python/vyos/configtree.py')
-rw-r--r-- | python/vyos/configtree.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index c0b3ebd78..078a8ad0a 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -352,6 +352,27 @@ def show_diff(left, right, path=[], commands=False, libpath=LIBPATH): return res +def union(left, right, libpath=LIBPATH): + if left is None: + left = ConfigTree(config_string='\n') + if right is None: + right = ConfigTree(config_string='\n') + if not (isinstance(left, ConfigTree) and isinstance(right, ConfigTree)): + raise TypeError("Arguments must be instances of ConfigTree") + + __lib = cdll.LoadLibrary(libpath) + __tree_union = __lib.tree_union + __tree_union.argtypes = [c_void_p, c_void_p] + __tree_union.restype = c_void_p + __get_error = __lib.get_error + __get_error.argtypes = [] + __get_error.restype = c_char_p + + res = __tree_union( left._get_config(), right._get_config()) + tree = ConfigTree(address=res) + + return tree + class DiffTree: def __init__(self, left, right, path=[], libpath=LIBPATH): if left is None: |