summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-03-28 14:34:20 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-05-03 13:32:07 -0500
commitbd8993540c6c1fc089943052aac51c9c318ffe6f (patch)
tree693437a75d857478d25ed242e38f7804afb38456 /python/vyos
parent841747cbb4e9252fed60d4a6c6227b41c4986e84 (diff)
downloadvyos-1x-bd8993540c6c1fc089943052aac51c9c318ffe6f.tar.gz
vyos-1x-bd8993540c6c1fc089943052aac51c9c318ffe6f.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. (cherry picked from commit 30a530839cdbd934ea62369e385dc33fa50ab6de)
Diffstat (limited to 'python/vyos')
-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 = [""]