From 68ebb2a39c6d98a4d2cc25b9b84e4a9594238608 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 18 Apr 2020 21:30:57 +0200 Subject: pppoe-server: T2314: fix RADIUS migration --- src/migration-scripts/pppoe-server/2-to-3 | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/migration-scripts') diff --git a/src/migration-scripts/pppoe-server/2-to-3 b/src/migration-scripts/pppoe-server/2-to-3 index 3f5415a94..d5d88d373 100755 --- a/src/migration-scripts/pppoe-server/2-to-3 +++ b/src/migration-scripts/pppoe-server/2-to-3 @@ -68,12 +68,27 @@ else: config.delete(wins_base) - # Remove RADIUS server req-limit node - radius_base = base + ['authentication', 'radius'] - if config.exists(radius_base): - for server in config.list_nodes(radius_base + ['server']): - if config.exists(radius_base + ['server', server, 'req-limit']): - config.delete(radius_base + ['server', server, 'req-limit']) + # Migrate radius-settings node to RADIUS and use this as base for the + # later migration of the RADIUS servers - this will save a lot of code + radius_settings = base + ['authentication', 'radius-settings'] + if config.exists(radius_settings): + config.rename(radius_settings, 'radius') + + # Migrate RADIUS server + radius_server = base + ['authentication', 'radius-server'] + if config.exists(radius_server): + new_base = base + ['authentication', 'radius', 'server'] + config.set(new_base) + config.set_tag(new_base) + for server in config.list_nodes(radius_server): + old_base = radius_server + [server] + config.copy(old_base, new_base + [server]) + + # remove old req-limit node + if config.exists(new_base + [server, 'req-limit']): + config.delete(new_base + [server, 'req-limit']) + + config.delete(radius_server) # Migrate IPv6 prefixes ipv6_base = base + ['client-ipv6-pool'] -- cgit v1.2.3