summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-06-23 12:40:36 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-09-11 12:01:37 -0500
commit70720e5f3d8616d66d93a4899b6d0a9aac6151f0 (patch)
tree791566e915e8215c07a97880909a4bb0d301edf6 /python/vyos
parent9ed150798a835d8ddf0845813e75132a4eea00d0 (diff)
downloadvyos-1x-70720e5f3d8616d66d93a4899b6d0a9aac6151f0.tar.gz
vyos-1x-70720e5f3d8616d66d93a4899b6d0a9aac6151f0.zip
migration: T6007: add util add_system_version to replace *_system_footer
(cherry picked from commit 51865448599ec40283fffe4dc15729f88f389886)
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/component_version.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/component_version.py b/python/vyos/component_version.py
index 648d690b9..1513ac5ed 100644
--- a/python/vyos/component_version.py
+++ b/python/vyos/component_version.py
@@ -191,6 +191,21 @@ 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(config_str: str = None, out_file: str = None):
+ """
+ Wrap config string with system version and write to out_file.
+ For convenience, calling with no argument will write system version
+ string to stdout, for use in bash scripts.
+ """
+ version_info = version_info_from_system()
+ if config_str is not None:
+ version_info.update_config_body(config_str)
+ version_info.update_footer()
+ if out_file is not None:
+ version_info.write(out_file)
+ else:
+ sys.stdout.write(version_info.write_string())
+
def from_string(string_line, vintage='vyos'):
"""
Get component version dictionary from string.