summaryrefslogtreecommitdiff
path: root/src/conf_mode/snmp.py
diff options
context:
space:
mode:
authorNicolas Fort <nicolasfort1988@gmail.com>2023-07-05 12:35:05 +0000
committerNicolas Fort <nicolasfort1988@gmail.com>2023-07-05 12:35:05 +0000
commit572f79cdf0b13e8160f6a4ef4044f02851d30a1b (patch)
tree06509ac8c9eba82555dd3a0352dc5a2401631ddb /src/conf_mode/snmp.py
parent5c1865487c5cf1bfb92ff873a97df4b129c9566f (diff)
downloadvyos-1x-572f79cdf0b13e8160f6a4ef4044f02851d30a1b.tar.gz
vyos-1x-572f79cdf0b13e8160f6a4ef4044f02851d30a1b.zip
T5340: snmp: add checks while configuring snmp listen-address with and without vrf
Diffstat (limited to 'src/conf_mode/snmp.py')
-rwxr-xr-xsrc/conf_mode/snmp.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 9b7c04eb0..f4611e15e 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -161,8 +161,12 @@ def verify(snmp):
for address in snmp['listen_address']:
# We only wan't to configure addresses that exist on the system.
# Hint the user if they don't exist
- if not is_addr_assigned(address):
- Warning(f'SNMP listen address "{address}" not configured!')
+ if 'vrf' in snmp:
+ vrf_name = snmp['vrf']
+ if not is_addr_assigned(address, vrf_name) and address not in ['::1','127.0.0.1']:
+ raise ConfigError(f'SNMP listen address "{address}" not configured in vrf "{vrf_name}"!')
+ elif not is_addr_assigned(address):
+ raise ConfigError(f'SNMP listen address "{address}" not configured in default vrf!')
if 'trap_target' in snmp:
for trap, trap_config in snmp['trap_target'].items():