summaryrefslogtreecommitdiff
path: root/python/vyos/migrator.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-03-08 11:46:18 -0600
committerJohn Estabrook <jestabro@vyos.io>2022-03-08 11:46:18 -0600
commit534f677d36285863decb2cdff179687b4fd690cb (patch)
treeb79abe885d3b5392f8b2fa434cd4816833eea581 /python/vyos/migrator.py
parentf8b7846ba3e008aaf0cde77e00e60d9af7b61446 (diff)
downloadvyos-1x-534f677d36285863decb2cdff179687b4fd690cb.tar.gz
vyos-1x-534f677d36285863decb2cdff179687b4fd690cb.zip
component_version: T4291: consolidate read/write functions
Diffstat (limited to 'python/vyos/migrator.py')
-rw-r--r--python/vyos/migrator.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/python/vyos/migrator.py b/python/vyos/migrator.py
index a2e0daabd..266a2e58e 100644
--- a/python/vyos/migrator.py
+++ b/python/vyos/migrator.py
@@ -17,10 +17,8 @@ import sys
import os
import json
import subprocess
-import vyos.version
import vyos.defaults
-import vyos.systemversions as systemversions
-import vyos.formatversions as formatversions
+import vyos.component_version as component_version
class MigratorError(Exception):
pass
@@ -42,13 +40,13 @@ class Migrator(object):
cfg_file = self._config_file
component_versions = {}
- cfg_versions = formatversions.read_vyatta_versions(cfg_file)
+ cfg_versions = component_version.from_file(cfg_file, vintage='vyatta')
if cfg_versions:
self._config_file_vintage = 'vyatta'
component_versions = cfg_versions
- cfg_versions = formatversions.read_vyos_versions(cfg_file)
+ cfg_versions = component_version.from_file(cfg_file, vintage='vyos')
if cfg_versions:
self._config_file_vintage = 'vyos'
@@ -152,19 +150,11 @@ class Migrator(object):
"""
Write new versions string.
"""
- versions_string = formatversions.format_versions_string(cfg_versions)
-
- os_version_string = vyos.version.get_version()
-
if self._config_file_vintage == 'vyatta':
- formatversions.write_vyatta_versions_foot(self._config_file,
- versions_string,
- os_version_string)
+ component_version.write_footer(self._config_file, vintage='vyatta')
if self._config_file_vintage == 'vyos':
- formatversions.write_vyos_versions_foot(self._config_file,
- versions_string,
- os_version_string)
+ component_version.write_footer(self._config_file, vintage='vyos')
def save_json_record(self, component_versions: dict):
"""
@@ -195,7 +185,7 @@ class Migrator(object):
# This will force calling all migration scripts:
cfg_versions = {}
- sys_versions = systemversions.get_system_component_version()
+ sys_versions = component_version.from_system()
# save system component versions in json file for easy reference
self.save_json_record(sys_versions)
@@ -211,7 +201,7 @@ class Migrator(object):
if not self._changed:
return
- formatversions.remove_versions(cfg_file)
+ component_version.remove_footer(cfg_file)
self.write_config_file_versions(rev_versions)
@@ -232,7 +222,7 @@ class VirtualMigrator(Migrator):
if not self._changed:
return
- formatversions.remove_versions(cfg_file)
+ component_version.remove_footer(cfg_file)
self.write_config_file_versions(cfg_versions)