summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/derivedtree.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/vyos/derivedtree.py b/python/vyos/derivedtree.py
index dc46b8eb3..61e1a4d94 100644
--- a/python/vyos/derivedtree.py
+++ b/python/vyos/derivedtree.py
@@ -18,6 +18,7 @@ from vyos.referencetree import ReferenceTree
from vyos.configtree import ConfigTree
from vyos.configtree import ConfigTreeError
from vyos.configtree import subtree_from_partial
+from vyos.configtree import mask_exclusive
class DerivedTreeError(Exception):
@@ -29,7 +30,7 @@ def subtree_from_list_of_partial_paths(
paths: list[list[str]],
accumulator: ConfigTree = None,
reference_tree: ReferenceTree = None,
-):
+) -> ConfigTree:
"""Return the union of subtrees of the ConfigTree argument matching each
of the 'partial' paths. A partial path is one that may or may not
contain intervening tag node values, in which case it will match for all
@@ -61,3 +62,15 @@ def subtree_from_list_of_partial_paths(
raise DerivedTreeError(f'Nonsensical paths: {errors}')
return accumulator
+
+
+def apply_exclusion_list(
+ config_tree: ConfigTree, exclusion_list: list[list[str]]
+) -> ConfigTree:
+ mask_ex = subtree_from_list_of_partial_paths(config_tree, exclusion_list)
+ try:
+ masked = mask_exclusive(config_tree, mask_ex)
+ except ConfigTreeError as e:
+ raise DerivedTreeError(str(e)) from e
+
+ return masked