summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-09-24 18:27:08 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-09-24 19:02:27 -0500
commitfbdf1fb8914a6b0ff3a64f4f359eaf3abd8be031 (patch)
tree183da8152b506b1e9274c6674f33d576f1e2695d /python
parent629ff86edb9e5f68dd5849c6300a2ad97aaed4a0 (diff)
downloadvyos-1x-fbdf1fb8914a6b0ff3a64f4f359eaf3abd8be031.tar.gz
vyos-1x-fbdf1fb8914a6b0ff3a64f4f359eaf3abd8be031.zip
T7709: use write_file_sync/atomic in vyos-save-config.py script
Config save is provided by the helper script in both CLI and configsession (hence also in the http api). Use utilities write_file_sync and write_file_atomic, in accordance with permissions and location: If the target is in /opt/vyatta/etc/config or /config, use write_file_sync; if, moreover, the caller has permissions, use write_file_atomic. Otherwise, fall back to util write_file.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/component_version.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/component_version.py b/python/vyos/component_version.py
index 136bd36e8..13fb8333f 100644
--- a/python/vyos/component_version.py
+++ b/python/vyos/component_version.py
@@ -209,6 +209,16 @@ def version_info_prune_component(x: VersionInfo, y: VersionInfo) -> VersionInfo:
x.component = {k: v for k, v in x.component.items() if k in y.component}
+def add_system_version_string(config_str: str = None) -> str:
+ """Wrap config string with system version and return string."""
+ version_info = version_info_from_system()
+ if config_str is not None:
+ version_info.update_config_body(config_str)
+ version_info.update_footer()
+
+ return version_info.write_string()
+
+
def add_system_version(config_str: str = None, out_file: str = None):
"""Wrap config string with system version and write to out_file.