summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-04-10 15:20:21 +0000
committerGitHub <noreply@github.com>2026-04-10 15:20:21 +0000
commite5abe253584e0a60e19abcefad06140754649145 (patch)
tree3da9b7495e397d17e751fb6b0a252daf0e84a0fb
parent9dccb75c72644fbdf80001259f0438b5f17c8f19 (diff)
parentbe66e4a5e97c2ab846515f5b483abafb21b6759c (diff)
downloadvyos-1x-e5abe253584e0a60e19abcefad06140754649145.tar.gz
vyos-1x-e5abe253584e0a60e19abcefad06140754649145.zip
Merge pull request #5108 from sever-sever/T8448
T8448: add an option to enable SNMP traps in VRRP
-rw-r--r--data/templates/high-availability/keepalived.conf.j23
-rw-r--r--interface-definitions/high-availability.xml.in13
-rwxr-xr-xsmoketest/scripts/cli/test_high-availability_vrrp.py12
-rwxr-xr-xsrc/conf_mode/high-availability.py4
4 files changed, 27 insertions, 5 deletions
diff --git a/data/templates/high-availability/keepalived.conf.j2 b/data/templates/high-availability/keepalived.conf.j2
index c0d66ae54..f0ed7909c 100644
--- a/data/templates/high-availability/keepalived.conf.j2
+++ b/data/templates/high-availability/keepalived.conf.j2
@@ -5,6 +5,9 @@
# Global definitions configuration block
global_defs {
dynamic_interfaces
+{% if vrrp.snmp.trap is vyos_defined %}
+ enable_traps
+{% endif %}
script_user root
{% if vrrp.global_parameters.startup_delay is vyos_defined %}
vrrp_startup_delay {{ vrrp.global_parameters.startup_delay }}
diff --git a/interface-definitions/high-availability.xml.in b/interface-definitions/high-availability.xml.in
index 6cf6237ca..bb132e337 100644
--- a/interface-definitions/high-availability.xml.in
+++ b/interface-definitions/high-availability.xml.in
@@ -12,12 +12,19 @@
<help>Virtual Router Redundancy Protocol settings</help>
</properties>
<children>
- <leafNode name="snmp">
+ <node name="snmp">
<properties>
- <valueless/>
<help>Enable SNMP</help>
</properties>
- </leafNode>
+ <children>
+ <leafNode name="trap">
+ <properties>
+ <valueless/>
+ <help>Enable SNMP traps</help>
+ </properties>
+ </leafNode>
+ </children>
+ </node>
<node name="global-parameters">
<properties>
<help>VRRP global parameters</help>
diff --git a/smoketest/scripts/cli/test_high-availability_vrrp.py b/smoketest/scripts/cli/test_high-availability_vrrp.py
index 5a4c41b6d..f1f1c7df2 100755
--- a/smoketest/scripts/cli/test_high-availability_vrrp.py
+++ b/smoketest/scripts/cli/test_high-availability_vrrp.py
@@ -137,6 +137,9 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.cli_set(global_param_base + ['garp', 'master-refresh-repeat', f'{garp_master_refresh_repeat}'])
self.cli_set(global_param_base + ['version', vrrp_version])
+ # SNMP
+ self.cli_set(base_path + ['vrrp', 'snmp', 'trap'])
+
# commit changes
self.cli_commit()
@@ -149,6 +152,7 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'vrrp_garp_master_refresh {garp_master_refresh}', config)
self.assertIn(f'vrrp_garp_master_refresh_repeat {garp_master_refresh_repeat}', config)
self.assertIn(f'vrrp_version {vrrp_version}', config)
+ self.assertIn('enable_traps', config)
for group in groups:
vlan_id = group.lstrip('VLAN')
@@ -174,6 +178,14 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'garp_master_refresh {group_garp_master_refresh}', config)
self.assertIn(f'garp_master_repeat {group_garp_master_repeat}', config)
+ # Remove SNMP traps
+ self.cli_delete(base_path + ['vrrp', 'snmp', 'trap'])
+
+ # commit changes
+ self.cli_commit()
+ config = getConfig(f'global_defs')
+ self.assertNotIn('enable_traps', config)
+
def test_03_sync_group(self):
sync_group = 'VyOS'
diff --git a/src/conf_mode/high-availability.py b/src/conf_mode/high-availability.py
index 005bb6cce..48a7d8abc 100755
--- a/src/conf_mode/high-availability.py
+++ b/src/conf_mode/high-availability.py
@@ -25,7 +25,7 @@ from ipaddress import IPv6Interface
from vyos.base import Warning
from vyos.config import Config
-from vyos.configdict import leaf_node_changed
+from vyos.configdict import node_changed
from vyos.ifconfig.vrrp import VRRP
from vyos.template import render
from vyos.template import is_ipv4
@@ -59,7 +59,7 @@ def get_config(config=None):
if conf.exists(conntrack_path):
ha['conntrack_sync_group'] = conf.return_value(conntrack_path)
- if leaf_node_changed(conf, base + ['vrrp', 'snmp']):
+ if node_changed(conf, base + ['vrrp', 'snmp']):
ha.update({'restart_required': {}})
return ha