From fb72bc367234bf35628bdccf84b0b76108f6341e Mon Sep 17 00:00:00 2001 From: Eshenko Dmitriy Date: Mon, 18 Nov 2019 23:15:08 +0300 Subject: migration-scripts: l2tp: T1811: add missing check on server existence --- src/migration-scripts/l2tp/0-to-1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/migration-scripts/l2tp/0-to-1 b/src/migration-scripts/l2tp/0-to-1 index f6c716df1..686ebc655 100755 --- a/src/migration-scripts/l2tp/0-to-1 +++ b/src/migration-scripts/l2tp/0-to-1 @@ -35,17 +35,18 @@ else: # Migrate "vpn l2tp authentication radius-server" tag node to new # "vpn l2tp authentication radius server" tag node - for server in config.list_nodes(cfg_base + ['radius-server']): - base_server = cfg_base + ['radius-server', server] - key = config.return_value(base_server + ['key']) + if config.exists(cfg_base + ['radius-server']): + for server in config.list_nodes(cfg_base + ['radius-server']): + base_server = cfg_base + ['radius-server', server] + key = config.return_value(base_server + ['key']) - # delete old configuration node - config.delete(base_server) - # write new configuration node - config.set(cfg_base + ['radius', 'server', server, 'key'], value=key) + # delete old configuration node + config.delete(base_server) + # write new configuration node + config.set(cfg_base + ['radius', 'server', server, 'key'], value=key) - # format as tag node - config.set_tag(cfg_base + ['radius', 'server']) + # format as tag node + config.set_tag(cfg_base + ['radius', 'server']) # delete top level tag node if config.exists(cfg_base + ['radius-server']): -- cgit v1.2.3