diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-09-19 10:51:15 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-09-19 10:51:15 +0200 |
commit | a8ccf72c222caad8cd7aaca9bca773be39e87f5c (patch) | |
tree | 66d974b0ea3afbfc7b4adb3e69177dc887d88f45 /src/migration-scripts/dhcp-server | |
parent | 224f0b8042f439b8dcc0eb32730da669e8b163af (diff) | |
download | vyos-1x-a8ccf72c222caad8cd7aaca9bca773be39e87f5c.tar.gz vyos-1x-a8ccf72c222caad8cd7aaca9bca773be39e87f5c.zip |
dhcp-server: T3672: only one failover peer is supported
Diffstat (limited to 'src/migration-scripts/dhcp-server')
-rwxr-xr-x | src/migration-scripts/dhcp-server/5-to-6 | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/migration-scripts/dhcp-server/5-to-6 b/src/migration-scripts/dhcp-server/5-to-6 index 7f447ac17..39bbb9f50 100755 --- a/src/migration-scripts/dhcp-server/5-to-6 +++ b/src/migration-scripts/dhcp-server/5-to-6 @@ -29,16 +29,16 @@ file_name = sys.argv[1] with open(file_name, 'r') as f: config_file = f.read() -base = ['service', 'dhcp-server', 'shared-network-name'] +base = ['service', 'dhcp-server'] config = ConfigTree(config_file) -if not config.exists(base): +if not config.exists(base + ['shared-network-name']): # Nothing to do exit(0) # Run this for every instance if 'shared-network-name' -for network in config.list_nodes(base): - base_network = base + [network] +for network in config.list_nodes(base + ['shared-network-name']): + base_network = base + ['shared-network-name', network] if not config.exists(base_network + ['subnet']): continue @@ -60,6 +60,23 @@ for network in config.list_nodes(base): if config.exists(base_subnet + ['dns-server']): config.rename(base_subnet + ['dns-server'], 'name-server') + + # T3672: ISC DHCP server only supports one failover peer + if config.exists(base_subnet + ['failover']): + # There can only be one failover configuration, if none is present + # we add the first one + if not config.exists(base + ['failover']): + local = config.return_value(base_subnet + ['failover', 'local-address']) + remote = config.return_value(base_subnet + ['failover', 'peer-address']) + status = config.return_value(base_subnet + ['failover', 'status']) + + config.set(base + ['failover', 'remote'], value=remote) + config.set(base + ['failover', 'source-address'], value=local) + config.set(base + ['failover', 'status'], value=status) + + config.delete(base_subnet + ['failover']) + config.set(base_subnet + ['enable-failover']) + try: with open(file_name, 'w') as f: f.write(config.to_string()) |