diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-09-19 10:51:15 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-09-19 12:25:18 +0200 |
commit | 81dbce734c207a0fce836bf2a5d283910509f4ff (patch) | |
tree | 35d90bfe3efe6bc5fa11cffaa284b118d0e812d8 /src/migration-scripts/dhcp-server | |
parent | abad387fcaf700a32f8fc85183d617fcfbb0b8f4 (diff) | |
download | vyos-1x-81dbce734c207a0fce836bf2a5d283910509f4ff.tar.gz vyos-1x-81dbce734c207a0fce836bf2a5d283910509f4ff.zip |
dhcp-server: T3672: only one failover peer is supported
(cherry picked from commit a8ccf72c222caad8cd7aaca9bca773be39e87f5c)
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()) |