From ee494c3a1dbfca3457bcaffe89d45971348e4848 Mon Sep 17 00:00:00 2001 From: Simon <965089+sarthurdev@users.noreply.github.com> Date: Thu, 11 Jan 2024 06:46:33 +0100 Subject: dhcp: dhcpv6: T3316: Add `subnet-id` so leases remain mapped to entries in the lease file (#2796) --- src/migration-scripts/dhcp-server/8-to-9 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/migration-scripts/dhcp-server') diff --git a/src/migration-scripts/dhcp-server/8-to-9 b/src/migration-scripts/dhcp-server/8-to-9 index 908420c18..810e403a6 100755 --- a/src/migration-scripts/dhcp-server/8-to-9 +++ b/src/migration-scripts/dhcp-server/8-to-9 @@ -16,6 +16,7 @@ # T3316: # - Migrate dhcp options under new option node +# - Add subnet IDs to existing subnets import sys import re @@ -44,6 +45,8 @@ option_nodes = ['bootfile-name', 'bootfile-server', 'bootfile-size', 'captive-po 'tftp-server-name', 'time-offset', 'time-server', 'time-zone', 'vendor-option', 'wins-server', 'wpad-url'] +subnet_id = 1 + for network in config.list_nodes(base): for option in option_nodes: if config.exists(base + [network, option]): @@ -56,10 +59,13 @@ for network in config.list_nodes(base): base_subnet = base + [network, 'subnet', subnet] for option in option_nodes: - if config.exists(base + [network, 'subnet', subnet, option]): - config.set(base + [network, 'subnet', subnet, 'option']) - config.copy(base + [network, 'subnet', subnet, option], base + [network, 'subnet', subnet, 'option', option]) - config.delete(base + [network, 'subnet', subnet, option]) + 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 try: with open(file_name, 'w') as f: -- cgit v1.2.3