diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-03-31 04:53:08 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 04:53:08 +0700 |
commit | 41f810998729057a05f240625fffe946d2bf4711 (patch) | |
tree | c766470ec065a0edb9eeddd97fc27512dff891de /src | |
parent | 69dda9497229b56bf68e7e66135688561598b892 (diff) | |
parent | 1c74d7ec8a239427c8f7e9f6d864c5085372b0e6 (diff) | |
download | vyos-1x-41f810998729057a05f240625fffe946d2bf4711.tar.gz vyos-1x-41f810998729057a05f240625fffe946d2bf4711.zip |
Merge pull request #286 from jestabro/change-trailing-syntax
Change trailing syntax
Diffstat (limited to 'src')
-rwxr-xr-x | src/helpers/run-config-migration.py | 19 | ||||
-rwxr-xr-x | src/helpers/vyos-load-config.py | 8 | ||||
-rwxr-xr-x | src/helpers/vyos-merge-config.py | 10 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/helpers/run-config-migration.py b/src/helpers/run-config-migration.py index a57a19cdf..3c06e38f8 100755 --- a/src/helpers/run-config-migration.py +++ b/src/helpers/run-config-migration.py @@ -69,15 +69,22 @@ def main(): sys.exit(1) if not virtual: - migration = Migrator(config_file_name, force=force_on, - set_vintage=vintage) + virtual_migration = VirtualMigrator(config_file_name) + virtual_migration.run() + + migration = Migrator(config_file_name, force=force_on) + migration.run() + + if not migration.config_changed(): + os.remove(backup_file_name) else: - migration = VirtualMigrator(config_file_name) + virtual_migration = VirtualMigrator(config_file_name, + set_vintage=vintage) - migration.run() + virtual_migration.run() - if not migration._changed: - os.remove(backup_file_name) + if not virtual_migration.config_changed(): + os.remove(backup_file_name) if __name__ == '__main__': main() diff --git a/src/helpers/vyos-load-config.py b/src/helpers/vyos-load-config.py index 4e6d67efa..693529c23 100755 --- a/src/helpers/vyos-load-config.py +++ b/src/helpers/vyos-load-config.py @@ -28,7 +28,7 @@ import tempfile import vyos.defaults import vyos.remote from vyos.config import Config, VyOSError -from vyos.migrator import Migrator, MigratorError +from vyos.migrator import Migrator, VirtualMigrator, MigratorError system_config_file = 'config.boot' @@ -73,6 +73,12 @@ with tempfile.NamedTemporaryFile() as fp: with open(fp.name, 'w') as fd: fd.write(config_file) + virtual_migration = VirtualMigrator(fp.name) + try: + virtual_migration.run() + except MigratorError as err: + sys.exit('{}'.format(err)) + migration = Migrator(fp.name) try: migration.run() diff --git a/src/helpers/vyos-merge-config.py b/src/helpers/vyos-merge-config.py index c5216daa6..10a5ea4bc 100755 --- a/src/helpers/vyos-merge-config.py +++ b/src/helpers/vyos-merge-config.py @@ -21,9 +21,9 @@ import subprocess import tempfile import vyos.defaults import vyos.remote -import vyos.migrator from vyos.config import Config from vyos.configtree import ConfigTree +from vyos.migrator import Migrator, VirtualMigrator if (len(sys.argv) < 2): @@ -61,9 +61,13 @@ 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) + virtual_migration = VirtualMigrator(file_to_migrate.name) + virtual_migration.run() + + migration = Migrator(file_to_migrate.name) migration.run() - if migration.config_changed(): + + if virtual_migration.config_changed() or migration.config_changed(): with open(file_to_migrate.name, 'r') as fd: config_file = fd.read() |