diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-01-20 20:44:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 20:44:32 +0100 |
commit | 93cdb6f1ca00723f77f013203f946a256f36a7e3 (patch) | |
tree | 70c2b1edb6cdcc36142ef34e8c1a36a78db129fe /src | |
parent | fcb1b6c69ffc644769006ee605812461dcb1d048 (diff) | |
parent | a41826759ae79907eee673414c2de35807fb6b3a (diff) | |
download | vyos-1x-93cdb6f1ca00723f77f013203f946a256f36a7e3.tar.gz vyos-1x-93cdb6f1ca00723f77f013203f946a256f36a7e3.zip |
Merge pull request #1182 from jestabro/migrate-while-udev
interface-names: T3871: use tempfile during virtual migration
Diffstat (limited to 'src')
-rwxr-xr-x | src/helpers/vyos_net_name | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/helpers/vyos_net_name b/src/helpers/vyos_net_name index afeef8f2d..1798e92db 100755 --- a/src/helpers/vyos_net_name +++ b/src/helpers/vyos_net_name @@ -20,12 +20,14 @@ import os import re import time import logging +import tempfile import threading from sys import argv from vyos.configtree import ConfigTree from vyos.defaults import directories from vyos.util import cmd, boot_configuration_complete +from vyos.migrator import VirtualMigrator vyos_udev_dir = directories['vyos_udev_dir'] vyos_log_dir = '/run/udev/log' @@ -139,14 +141,20 @@ def get_configfile_interfaces() -> dict: try: config = ConfigTree(config_file) except Exception: - logging.debug(f"updating component version string syntax") try: - # this will update the component version string in place, for - # updates 1.2 --> 1.3/1.4 - os.system(f'/usr/libexec/vyos/run-config-migration.py {config_path} --virtual --set-vintage=vyos') - with open(config_path) as f: - config_file = f.read() + logging.debug(f"updating component version string syntax") + # this will update the component version string syntax, + # required for updates 1.2 --> 1.3/1.4 + with tempfile.NamedTemporaryFile() as fp: + with open(fp.name, 'w') as fd: + fd.write(config_file) + virtual_migration = VirtualMigrator(fp.name) + virtual_migration.run() + with open(fp.name) as fd: + config_file = fd.read() + config = ConfigTree(config_file) + except Exception as e: logging.critical(f"ConfigTree error: {e}") @@ -246,4 +254,3 @@ if not boot_configuration_complete(): else: logging.debug("boot configuration complete") lock.release() - |