diff options
author | John Estabrook <jestabro@vyos.io> | 2024-06-23 12:40:36 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-06-26 15:45:19 -0500 |
commit | 51865448599ec40283fffe4dc15729f88f389886 (patch) | |
tree | dbc1bb252d58acef71ac0a74f97aaca9d3eb346a /python/vyos/component_version.py | |
parent | 403f1d2f2159f5436bb7c71a3694647a870357b7 (diff) | |
download | vyos-1x-51865448599ec40283fffe4dc15729f88f389886.tar.gz vyos-1x-51865448599ec40283fffe4dc15729f88f389886.zip |
migration: T6007: add util add_system_version to replace *_system_footer
Diffstat (limited to 'python/vyos/component_version.py')
-rw-r--r-- | python/vyos/component_version.py | 15 |
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. |