diff options
author | Indrajit Raychaudhuri <irc@indrajit.com> | 2023-12-03 15:01:35 -0600 |
---|---|---|
committer | Indrajit Raychaudhuri <irc@indrajit.com> | 2023-12-03 18:50:31 -0600 |
commit | 4b53e99b53c85beaea2b2d33286b66d8d63d9870 (patch) | |
tree | 3fae81931bae12090b3011d232e390cca7311527 /src/migration-scripts | |
parent | 075bb7a834ac9ebf4f70f55c1e06bc3da9ecb5dd (diff) | |
download | vyos-1x-4b53e99b53c85beaea2b2d33286b66d8d63d9870.tar.gz vyos-1x-4b53e99b53c85beaea2b2d33286b66d8d63d9870.zip |
ddclient: T5791: Simplify and fix migration script for dynamic dns
Mark 'dns dynamic name' as tag node to avoid unexpected nesting.
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-x | src/migration-scripts/dns-dynamic/2-to-3 | 31 |
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) |