summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-04-04 17:11:21 +0200
committerGitHub <noreply@github.com>2024-04-04 17:11:21 +0200
commite7891a830aa25ae13ccfbe7b401a8262908387d9 (patch)
tree7265200f33e44fa3235bdf981822f2a245c654d2 /python
parentfe87ed94a3af6b97d2481e96c63d48ba87849627 (diff)
parent5cb8e78626988b9bad6dfe9122101c36d116afbf (diff)
downloadvyos-1x-e7891a830aa25ae13ccfbe7b401a8262908387d9.tar.gz
vyos-1x-e7891a830aa25ae13ccfbe7b401a8262908387d9.zip
Merge pull request #3214 from nicolas-fort/T6068-kea
T6068: dhcp-server: add command <set service dhcp-server high-availability mode>
Diffstat (limited to 'python')
-rw-r--r--python/vyos/template.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 3e468eb82..ac77e8a3d 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -823,10 +823,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,
@@ -835,13 +844,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
}]
}