summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configtree.py22
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],