diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-05-05 13:50:13 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2026-05-28 08:31:26 -0500 |
| commit | bc541bbcc3e7da924ab1d21aed360eba09621e0b (patch) | |
| tree | ebe8580bb0c14fe5386c36455a6044584c9f8e21 /python | |
| parent | 8b2d2a80c0f9272d80ee4d90077978c9e43021b9 (diff) | |
| download | vyos-1x-bc541bbcc3e7da924ab1d21aed360eba09621e0b.tar.gz vyos-1x-bc541bbcc3e7da924ab1d21aed360eba09621e0b.zip | |
T8502: add library support for config-sync exclude paths
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/configtree.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index d92137c14..47e56bc46 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -667,6 +667,28 @@ def mask_exclusive(left, right, libpath=LIBPATH): return tree +def delete_tree_from_masks( + config_tree: ConfigTree, include_mask: ConfigTree, exclude_mask: ConfigTree +): + masked_inc = mask_inclusive(config_tree, include_mask) + # Here we want the reversed stand-alone exclusion/inclusion. + # This simplifies definition of delete paths as (delete) + # difference between the two trees of config data. + masked_upper_bound = mask_exclusive(config_tree, include_mask) + masked_lower_bound = mask_inclusive(config_tree, exclude_mask) + masked_exc = union(masked_upper_bound, masked_lower_bound) + + ret = DiffTree(masked_inc, masked_exc) + return ret.delete + + +def delete_dict_from_masks( + config_tree: ConfigTree, include_mask: ConfigTree, exclude_mask: ConfigTree +): + ret = delete_tree_from_masks(config_tree, include_mask, exclude_mask) + return json.loads(ret.to_json()) + + def subtree_from_partial( config_tree: ConfigTree, path: list[str], |
