diff options
author | John Estabrook <jestabro@vyos.io> | 2021-08-19 14:30:32 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2021-08-20 14:24:16 -0500 |
commit | c9cfc599615cdcd54195ee45f71b78d507a8407d (patch) | |
tree | bc53cc0a49536e746c799cc5694f3a2d3d005ae1 /python | |
parent | 50280c9ec8dbf87a5ddea65374c651fc379b4cb3 (diff) | |
download | vyos-1x-c9cfc599615cdcd54195ee45f71b78d507a8407d.tar.gz vyos-1x-c9cfc599615cdcd54195ee45f71b78d507a8407d.zip |
T1950: write component versions to json file during migration
(cherry picked from commit 1a498915efdc433dda7bd6e5fcc08703a48560c6)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/defaults.py | 3 | ||||
-rw-r--r-- | python/vyos/migrator.py | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py index 354e4d362..ca5e02834 100644 --- a/python/vyos/defaults.py +++ b/python/vyos/defaults.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. +import os directories = { "data": "/usr/share/vyos/", @@ -31,6 +32,8 @@ cfg_vintage = 'vyos' commit_lock = '/opt/vyatta/config/.lock' +component_version_json = os.path.join(directories['data'], 'component-versions.json') + https_data = { 'listen_addresses' : { '*': ['_'] } } diff --git a/python/vyos/migrator.py b/python/vyos/migrator.py index 9a5fdef2f..37c4e5902 100644 --- a/python/vyos/migrator.py +++ b/python/vyos/migrator.py @@ -15,6 +15,7 @@ import sys import os +import json import subprocess import vyos.version import vyos.defaults @@ -165,6 +166,14 @@ class Migrator(object): versions_string, os_version_string) + def save_json_record(self, component_versions: dict): + """ + Write component versions to a json file + """ + version_file = vyos.defaults.component_version_json + with open(version_file, 'w') as f: + f.write(json.dumps(component_versions, indent=2, sort_keys=True)) + def run(self): """ Gather component versions from config file and system. @@ -182,6 +191,9 @@ class Migrator(object): sys_versions = systemversions.get_system_versions() + # save system component versions in json file for easy reference + self.save_json_record(sys_versions) + rev_versions = self.run_migration_scripts(cfg_versions, sys_versions) if rev_versions != cfg_versions: |