diff options
author | Nicolas Fort <nicolasfort1988@gmail.com> | 2024-03-27 17:16:53 +0000 |
---|---|---|
committer | Nicolas Fort <nicolasfort1988@gmail.com> | 2024-04-03 11:32:47 +0000 |
commit | 5cb8e78626988b9bad6dfe9122101c36d116afbf (patch) | |
tree | fb2b4bcd3e0823b37806d1ceb10eea727d7e88a9 /python/vyos/template.py | |
parent | 0fcab52921f27f8d2df9038a193be66c2ba18d11 (diff) | |
download | vyos-1x-5cb8e78626988b9bad6dfe9122101c36d116afbf.tar.gz vyos-1x-5cb8e78626988b9bad6dfe9122101c36d116afbf.zip |
T6068: dhcp-server: add command <set service dhcp-server high-availability mode> so user can define what type of ha use: active-active or active-passive
Diffstat (limited to 'python/vyos/template.py')
-rw-r--r-- | python/vyos/template.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py index bde8e3554..ab06c7752 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -809,10 +809,19 @@ def kea_high_availability_json(config): source_addr = config['source_address'] remote_addr = config['remote'] + ha_mode = 'hot-standby' if config['mode'] == 'active-passive' else 'load-balancing' + ha_role = config['status'] + + if ha_role == 'primary': + peer1_role = 'primary' + peer2_role = 'standby' if ha_mode == 'hot-standby' else 'secondary' + else: + peer1_role = 'standby' if ha_mode == 'hot-standby' else 'secondary' + peer2_role = 'primary' data = { 'this-server-name': os.uname()[1], - 'mode': 'hot-standby', + 'mode': ha_mode, 'heartbeat-delay': 10000, 'max-response-delay': 10000, 'max-ack-delay': 5000, @@ -821,13 +830,13 @@ def kea_high_availability_json(config): { 'name': os.uname()[1], 'url': f'http://{source_addr}:647/', - 'role': 'standby' if config['status'] == 'secondary' else 'primary', + 'role': peer1_role, 'auto-failover': True }, { 'name': config['name'], 'url': f'http://{remote_addr}:647/', - 'role': 'primary' if config['status'] == 'secondary' else 'standby', + 'role': peer2_role, 'auto-failover': True }] } |