summaryrefslogtreecommitdiff
path: root/python/vyos/configsession.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-03-31 15:00:28 +0300
committerGitHub <noreply@github.com>2024-03-31 15:00:28 +0300
commitf62827c80466dc7ae74a2f8a1b360f59603bc3fa (patch)
tree25fd9193764bc84ba6f22ec30f0e9de7359e6af9 /python/vyos/configsession.py
parent252d03d6e419aae14ae75caed38d1b1001c916a2 (diff)
parentb6c5e66cc44fdec21e6731d98a1065e2adf87b3b (diff)
downloadvyos-1x-f62827c80466dc7ae74a2f8a1b360f59603bc3fa.tar.gz
vyos-1x-f62827c80466dc7ae74a2f8a1b360f59603bc3fa.zip
Merge pull request #3211 from jestabro/tree-mask
T6185: simplify marshalling of section and config data for config-sync
Diffstat (limited to 'python/vyos/configsession.py')
-rw-r--r--python/vyos/configsession.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py
index 90842b749..ab7a631bb 100644
--- a/python/vyos/configsession.py
+++ b/python/vyos/configsession.py
@@ -176,6 +176,25 @@ class ConfigSession(object):
except (ValueError, ConfigSessionError) as e:
raise ConfigSessionError(e)
+ def set_section_tree(self, d: dict):
+ try:
+ if d:
+ for p in dict_to_paths(d):
+ self.set(p)
+ except (ValueError, ConfigSessionError) as e:
+ raise ConfigSessionError(e)
+
+ def load_section_tree(self, mask: dict, d: dict):
+ try:
+ if mask:
+ for p in dict_to_paths(mask):
+ self.delete(p)
+ if d:
+ for p in dict_to_paths(d):
+ self.set(p)
+ except (ValueError, ConfigSessionError) as e:
+ raise ConfigSessionError(e)
+
def comment(self, path, value=None):
if not value:
value = [""]