summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-04 07:25:09 +0100
committerGitHub <noreply@github.com>2023-12-04 07:25:09 +0100
commitf26d788008fe187e00a8afe59ff4bfdace51866d (patch)
treeae584a3ddb0ccc7e065d15781b2210b1e8d0d9fc /src/migration-scripts
parent3581a4372aad6e0f259b34bca17c1dd721a41f89 (diff)
parent4b53e99b53c85beaea2b2d33286b66d8d63d9870 (diff)
downloadvyos-1x-f26d788008fe187e00a8afe59ff4bfdace51866d.tar.gz
vyos-1x-f26d788008fe187e00a8afe59ff4bfdace51866d.zip
Merge pull request #2569 from indrajitr/ddclient-update-20231203-04
ddclient: T5791: Simplify and fix migration script for dynamic dns
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-xsrc/migration-scripts/dns-dynamic/2-to-331
1 files changed, 17 insertions, 14 deletions
diff --git a/src/migration-scripts/dns-dynamic/2-to-3 b/src/migration-scripts/dns-dynamic/2-to-3
index 02bc9324a..187c2a895 100755
--- a/src/migration-scripts/dns-dynamic/2-to-3
+++ b/src/migration-scripts/dns-dynamic/2-to-3
@@ -44,35 +44,38 @@ if not config.exists(address_path):
# Nothing to do
sys.exit(0)
-# config.copy does not recursively create a path, so initialize the name path
+# config.copy does not recursively create a path, so initialize the name path as tagged node
if not config.exists(name_path):
config.set(name_path)
+ config.set_tag(name_path)
for address in config.list_nodes(address_path):
+ address_path_tag = address_path + [address]
+
# Move web-option as a configuration in each service instead of top level web-option
- if config.exists(address_path + [address, 'web-options']) and address == 'web':
+ if config.exists(address_path_tag + ['web-options']) and address == 'web':
for svc_type in ['service', 'rfc2136']:
- if config.exists(address_path + [address, svc_type]):
- for svc_cfg in config.list_nodes(address_path + [address, svc_type]):
- config.copy(address_path + [address, 'web-options'],
- address_path + [address, svc_type, svc_cfg, 'web-options'])
- config.delete(address_path + [address, 'web-options'])
+ if config.exists(address_path_tag + [svc_type]):
+ for svc_cfg in config.list_nodes(address_path_tag + [svc_type]):
+ config.copy(address_path_tag + ['web-options'],
+ address_path_tag + [svc_type, svc_cfg, 'web-options'])
+ config.delete(address_path_tag + ['web-options'])
for svc_type in ['service', 'rfc2136']:
- if config.exists(address_path + [address, svc_type]):
+ if config.exists(address_path_tag + [svc_type]):
# Move RFC2136 as service configuration, rename to avoid name conflict and set protocol to 'nsupdate'
if svc_type == 'rfc2136':
- for rfc_cfg_old in config.list_nodes(address_path + [address, 'rfc2136']):
+ for rfc_cfg_old in config.list_nodes(address_path_tag + ['rfc2136']):
rfc_cfg_new = f'{rfc_cfg_old}-rfc2136'
- config.rename(address_path + [address, 'rfc2136', rfc_cfg_old], rfc_cfg_new)
- config.set(address_path + [address, 'rfc2136', rfc_cfg_new, 'protocol'], 'nsupdate')
+ config.rename(address_path_tag + ['rfc2136', rfc_cfg_old], rfc_cfg_new)
+ config.set(address_path_tag + ['rfc2136', rfc_cfg_new, 'protocol'], 'nsupdate')
# Add address as config value in each service before moving the service path
# And then copy the services from 'address <interface> service <service>' to 'name <service>'
- for svc_cfg in config.list_nodes(address_path + [address, svc_type]):
- config.set(address_path + [address, svc_type, svc_cfg, 'address'], address)
- config.copy(address_path + [address, svc_type, svc_cfg], name_path + [svc_cfg])
+ for svc_cfg in config.list_nodes(address_path_tag + [svc_type]):
+ config.set(address_path_tag + [svc_type, svc_cfg, 'address'], address)
+ config.copy(address_path_tag + [svc_type, svc_cfg], name_path + [svc_cfg])
# Finally cleanup the old address path
config.delete(address_path)