summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2026-04-03 15:23:33 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2026-04-10 15:08:59 +0000
commitbe66e4a5e97c2ab846515f5b483abafb21b6759c (patch)
tree02ca6c916b11bbfadf6bd71519edd7495073fc0f
parentb476308dc3f64cb1b250b101568f49ab870b6bd1 (diff)
downloadvyos-1x-be66e4a5e97c2ab846515f5b483abafb21b6759c.tar.gz
vyos-1x-be66e4a5e97c2ab846515f5b483abafb21b6759c.zip
T8448: VRRP add configuration for the SNMP traps
Allow to configure Keepalived VRRP traps - set high-availability vrrp snmp trap
-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