summaryrefslogtreecommitdiff
path: root/src/migration-scripts/ipoe-server/1-to-2
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-04-07 07:41:15 +0200
committerChristian Breunig <christian@breunig.cc>2024-04-07 07:43:16 +0200
commitc2b0381a0c26d82288fcc39f9fba1f3c25132aec (patch)
tree945e56928cecfca091a280e1f29021b1d53c04d9 /src/migration-scripts/ipoe-server/1-to-2
parent4ad1185536756890295fdd8b566fb65a75ef429d (diff)
downloadvyos-1x-c2b0381a0c26d82288fcc39f9fba1f3c25132aec.tar.gz
vyos-1x-c2b0381a0c26d82288fcc39f9fba1f3c25132aec.zip
ipoe: T6205: fix conditional branch error in config migrator
Commit a5ccc06c0 ("ipoe: T6205: error in migration script logic while renaming mac-address to mac node") added a conditional path into the config which could result in the migrated config not beeing written if precondition was not met. (cherry picked from commit 2bbded1e485614d40b2e95165629487537fd1757)
Diffstat (limited to 'src/migration-scripts/ipoe-server/1-to-2')
-rwxr-xr-xsrc/migration-scripts/ipoe-server/1-to-267
1 files changed, 32 insertions, 35 deletions
diff --git a/src/migration-scripts/ipoe-server/1-to-2 b/src/migration-scripts/ipoe-server/1-to-2
index f1335b5a5..6a7111541 100755
--- a/src/migration-scripts/ipoe-server/1-to-2
+++ b/src/migration-scripts/ipoe-server/1-to-2
@@ -62,7 +62,6 @@ for interface in config.list_nodes(base + ['interface']):
base_path = base + ['interface', interface]
for vlan in ['vlan-id', 'vlan-range']:
if config.exists(base_path + [vlan]):
- print(interface, vlan)
for tmp in config.return_values(base_path + [vlan]):
config.set(base_path + ['vlan'], value=tmp, replace=False)
config.delete(base_path + [vlan])
@@ -74,40 +73,38 @@ for interface in config.list_nodes(base + ['interface']):
config.set(base_path + ['mode'], value=tmp.lower())
pool_base = base + ['client-ip-pool']
-if not config.exists(pool_base):
- exit(0)
-
-default_pool = ''
-gateway = ''
-
-#named pool migration
-namedpools_base = pool_base + ['name']
-
-for pool_name in config.list_nodes(namedpools_base):
- pool_path = namedpools_base + [pool_name]
- if config.exists(pool_path + ['subnet']):
- subnet = config.return_value(pool_path + ['subnet'])
- config.set(pool_base + [pool_name, 'range'], value=subnet, replace=False)
- # Get netmask from subnet
- mask = subnet.split("/")[1]
- if config.exists(pool_path + ['next-pool']):
- next_pool = config.return_value(pool_path + ['next-pool'])
- config.set(pool_base + [pool_name, 'next-pool'], value=next_pool)
- if not default_pool:
- default_pool = pool_name
- if config.exists(pool_path + ['gateway-address']) and mask:
- gateway = f'{config.return_value(pool_path + ["gateway-address"])}/{mask}'
- config.set(base + ['gateway-address'], value=gateway, replace=False)
-
-if not default_pool and config.list_nodes(namedpools_base):
- default_pool = config.list_nodes(namedpools_base)[0]
-
-config.delete(namedpools_base)
-
-if default_pool:
- config.set(base + ['default-pool'], value=default_pool)
-# format as tag node
-config.set_tag(pool_base)
+if config.exists(pool_base):
+ default_pool = ''
+ gateway = ''
+
+ #named pool migration
+ namedpools_base = pool_base + ['name']
+
+ for pool_name in config.list_nodes(namedpools_base):
+ pool_path = namedpools_base + [pool_name]
+ if config.exists(pool_path + ['subnet']):
+ subnet = config.return_value(pool_path + ['subnet'])
+ config.set(pool_base + [pool_name, 'range'], value=subnet, replace=False)
+ # Get netmask from subnet
+ mask = subnet.split("/")[1]
+ if config.exists(pool_path + ['next-pool']):
+ next_pool = config.return_value(pool_path + ['next-pool'])
+ config.set(pool_base + [pool_name, 'next-pool'], value=next_pool)
+ if not default_pool:
+ default_pool = pool_name
+ if config.exists(pool_path + ['gateway-address']) and mask:
+ gateway = f'{config.return_value(pool_path + ["gateway-address"])}/{mask}'
+ config.set(base + ['gateway-address'], value=gateway, replace=False)
+
+ if not default_pool and config.list_nodes(namedpools_base):
+ default_pool = config.list_nodes(namedpools_base)[0]
+
+ config.delete(namedpools_base)
+
+ if default_pool:
+ config.set(base + ['default-pool'], value=default_pool)
+ # format as tag node
+ config.set_tag(pool_base)
try:
with open(file_name, 'w') as f: