summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-03-28 14:34:20 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-03-28 22:15:19 -0500
commit30a530839cdbd934ea62369e385dc33fa50ab6de (patch)
treef50026468131d97d2ae963047594742e251cae73 /python
parentb2248b68afac795ad391b7203117d6d40a7ba6ed (diff)
downloadvyos-1x-30a530839cdbd934ea62369e385dc33fa50ab6de.tar.gz
vyos-1x-30a530839cdbd934ea62369e385dc33fa50ab6de.zip
config-sync: T6185: combine data for sections/configs in one command
Package path/section data in single command containing a tree (dict) of section paths and the accompanying config data. This drops the call to get_config_dict and the need for a list of commands in request.
Diffstat (limited to 'python')
-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 = [""]