Skip to content

Commit

Permalink
migration: T6007: update vyos-load-config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jestabro committed Jun 20, 2024
1 parent 5726d84 commit d47e6cd
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/helpers/vyos-load-config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019 VyOS maintainers and contributors
# Copyright (C) 2019-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand Down Expand Up @@ -30,7 +30,7 @@
import vyos.defaults
import vyos.remote
from vyos.configsource import ConfigSourceSession, VyOSError
from vyos.migrator import Migrator, VirtualMigrator, MigratorError
from vyos.migrate import ConfigMigrate

class LoadConfig(ConfigSourceSession):
"""A subclass for calling 'loadFile'.
Expand Down Expand Up @@ -81,22 +81,13 @@ def get_local_config(filename):
with open(fp.name, 'w') as fd:
fd.write(config_string)

virtual_migration = VirtualMigrator(fp.name)
try:
virtual_migration.run()
except MigratorError as err:
sys.exit('{}'.format(err))

migration = Migrator(fp.name)
try:
migration.run()
except MigratorError as err:
sys.exit('{}'.format(err))
config_migrate = ConfigMigrate(fp.name)
config_migrate.run()

try:
config.load_config(fp.name)
except VyOSError as err:
sys.exit('{}'.format(err))
sys.exit(err)

if config.session_changed():
print("Load complete. Use 'commit' to make changes effective.")
Expand Down

0 comments on commit d47e6cd

Please sign in to comment.