diff options
author | Indrajit Raychaudhuri <irc@indrajit.com> | 2023-12-03 02:41:54 -0600 |
---|---|---|
committer | Indrajit Raychaudhuri <irc@indrajit.com> | 2023-12-05 19:53:50 -0600 |
commit | 5674a29374ad0a2a0d3634ceabd7db6932a9f1ab (patch) | |
tree | 167fe02f5a4f1a248f55546f51d8ae4e02b41f17 /src | |
parent | 706528f53af73ab15b1b2841f68250cb14bbcca0 (diff) | |
download | vyos-1x-5674a29374ad0a2a0d3634ceabd7db6932a9f1ab.tar.gz vyos-1x-5674a29374ad0a2a0d3634ceabd7db6932a9f1ab.zip |
ddclient: T5791: Simplify and fix migration script for dynamic dns
Mark 'dns dynamic name' as tag node to avoid unexpected nesting.
Also, fix file exec permission for migration script.
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | 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 100644..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) |