diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-01-13 00:28:01 +0100 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-01-13 02:37:30 +0100 |
commit | 45d472c8782f927980044eaba0d49421e91fc0c8 (patch) | |
tree | 0d532f2fbc3218ac9be69f7146270e73a5172b87 /src/migration-scripts/dhcpv6-server/3-to-4 | |
parent | bc3cf0a0a18ad70448322f90bdb6bf8292b59ccf (diff) | |
download | vyos-1x-45d472c8782f927980044eaba0d49421e91fc0c8.tar.gz vyos-1x-45d472c8782f927980044eaba0d49421e91fc0c8.zip |
dhcpv6: T3316: Move options to separate node and extend scopes
* Also migrate `address-range` to `range` tag node for consistency with dhcpv4 server syntax
Diffstat (limited to 'src/migration-scripts/dhcpv6-server/3-to-4')
-rwxr-xr-x | src/migration-scripts/dhcpv6-server/3-to-4 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/migration-scripts/dhcpv6-server/3-to-4 b/src/migration-scripts/dhcpv6-server/3-to-4 index c065e3d43..4747ebd60 100755 --- a/src/migration-scripts/dhcpv6-server/3-to-4 +++ b/src/migration-scripts/dhcpv6-server/3-to-4 @@ -16,6 +16,8 @@ # T3316: # - Add subnet IDs to existing subnets +# - Move options to option node +# - Migrate address-range to range tagNode import sys import re @@ -37,6 +39,10 @@ if not config.exists(base): # Nothing to do sys.exit(0) +option_nodes = ['captive-portal', 'domain-search', 'name-server', + 'nis-domain', 'nis-server', 'nisplus-domain', 'nisplus-server', + 'sip-server', 'sntp-server', 'vendor-option'] + subnet_id = 1 for network in config.list_nodes(base): @@ -44,6 +50,35 @@ for network in config.list_nodes(base): for subnet in config.list_nodes(base + [network, 'subnet']): base_subnet = base + [network, 'subnet', subnet] + if config.exists(base_subnet + ['address-range']): + config.set(base_subnet + ['range']) + config.set_tag(base_subnet + ['range']) + + range_id = 1 + + if config.exists(base_subnet + ['address-range', 'prefix']): + for prefix in config.return_values(base_subnet + ['address-range', 'prefix']): + config.set(base_subnet + ['range', range_id, 'prefix'], value=prefix) + + range_id += 1 + + if config.exists(base_subnet + ['address-range', 'start']): + for start in config.list_nodes(base_subnet + ['address-range', 'start']): + stop = config.return_value(base_subnet + ['address-range', 'start', start, 'stop']) + + config.set(base_subnet + ['range', range_id, 'start'], value=start) + config.set(base_subnet + ['range', range_id, 'stop'], value=stop) + + range_id += 1 + + config.delete(base_subnet + ['address-range']) + + for option in option_nodes: + if config.exists(base_subnet + [option]): + config.set(base_subnet + ['option']) + config.copy(base_subnet + [option], base_subnet + ['option', option]) + config.delete(base_subnet + [option]) + config.set(base_subnet + ['subnet-id'], value=subnet_id) subnet_id += 1 |