diff options
author | John Estabrook <jestabro@vyos.io> | 2024-03-28 14:34:20 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-03-28 22:15:19 -0500 |
commit | 30a530839cdbd934ea62369e385dc33fa50ab6de (patch) | |
tree | f50026468131d97d2ae963047594742e251cae73 /python/vyos/configsession.py | |
parent | b2248b68afac795ad391b7203117d6d40a7ba6ed (diff) | |
download | vyos-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/vyos/configsession.py')
-rw-r--r-- | python/vyos/configsession.py | 19 |
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 = [""] |