summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-11-18 09:41:52 -0600
committerJohn Estabrook <jestabro@vyos.io>2021-11-18 09:43:00 -0600
commit57ffa79bbde2b4144d0b8be71feafea6043193dd (patch)
tree16e60ca0ac0bd17fbe0a237c1c511b2bb10603b3 /src
parentd13b91462487e090b32c0d1ecf9139a2271b4837 (diff)
downloadvyos-1x-57ffa79bbde2b4144d0b8be71feafea6043193dd.tar.gz
vyos-1x-57ffa79bbde2b4144d0b8be71feafea6043193dd.zip
interface-names: T3871: 'migrate' component string syntax as needed
With the rewrite of vyatta_net_name to Python using ConfigTree, one runs into the change in the syntax of the component version string when updating 1.2 --> 1.3/1.4, since the udev rule is run before the migration of the config file; add an explicit 'virtual' migration on configtree error.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/helpers/vyos_net_name14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/helpers/vyos_net_name b/src/helpers/vyos_net_name
index 13fb9e31f..e21d8c9ff 100755
--- a/src/helpers/vyos_net_name
+++ b/src/helpers/vyos_net_name
@@ -144,7 +144,19 @@ def get_configfile_interfaces() -> dict:
logging.critical(f"OSError {e}")
exit(1)
- config = ConfigTree(config_file)
+ 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()
+ config = ConfigTree(config_file)
+ except Exception as e:
+ logging.critical(f"ConfigTree error: {e}")
base = ['interfaces', 'ethernet']
if config.exists(base):