summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@sentrium.io>2019-06-12 12:04:34 -0500
committerJohn Estabrook <jestabro@sentrium.io>2019-06-12 12:04:34 -0500
commit441f95d499f42f57b3a15d78aec826f794fab59f (patch)
treec002cf0c7aadb312d7539bd7394c67850fcbcace
parentaa88d5192338e2263516de791665f819a00b5c36 (diff)
downloadvyos-1x-441f95d499f42f57b3a15d78aec826f794fab59f.tar.gz
vyos-1x-441f95d499f42f57b3a15d78aec826f794fab59f.zip
T1397: use revised migration method
-rw-r--r--python/vyos/migrator.py2
-rwxr-xr-xsrc/helpers/vyos-merge-config.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/python/vyos/migrator.py b/python/vyos/migrator.py
index 2d4bc7ffc..59d68f0f7 100644
--- a/python/vyos/migrator.py
+++ b/python/vyos/migrator.py
@@ -165,6 +165,8 @@ class Migrator(object):
self.write_config_file_versions(rev_versions)
+ def config_changed(self):
+ return self._changed
class VirtualMigrator(Migrator):
def __init__(self, config_file, vintage='vyos'):
diff --git a/src/helpers/vyos-merge-config.py b/src/helpers/vyos-merge-config.py
index bb2919de2..e97a1c08d 100755
--- a/src/helpers/vyos-merge-config.py
+++ b/src/helpers/vyos-merge-config.py
@@ -18,8 +18,10 @@
import sys
import os
import subprocess
+import tempfile
import vyos.defaults
import vyos.remote
+import vyos.migrator
from vyos.config import Config
from vyos.configtree import ConfigTree
@@ -59,6 +61,16 @@ path = None
if (len(sys.argv) > 2):
path = " ".join(sys.argv[2:])
+with tempfile.NamedTemporaryFile() as file_to_migrate:
+ with open(file_to_migrate.name, 'w') as fd:
+ fd.write(config_file)
+
+ migration = vyos.migrator.Migrator(file_to_migrate.name)
+ migration.run()
+ if migration.config_changed():
+ with open(file_to_migrate.name, 'r') as fd:
+ config_file = fd.read()
+
merge_config_tree = ConfigTree(config_file)
effective_config = Config()