summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorDmitriyEshenko <dmitriy.eshenko@vyos.io>2019-12-18 18:47:16 +0000
committerChristian Poessinger <christian@poessinger.com>2019-12-18 19:58:45 +0100
commitf1cc9b0e08dfc4ae38c40f70db89b808d73fe7f9 (patch)
treebef7e139b66ff15f8a8c3d6b402c2e40dbef9d4c /src/conf_mode
parent01af8f619091a2a5634159bcd271411f0d89711f (diff)
downloadvyos-1x-f1cc9b0e08dfc4ae38c40f70db89b808d73fe7f9.tar.gz
vyos-1x-f1cc9b0e08dfc4ae38c40f70db89b808d73fe7f9.zip
snmp: T1881: Add path for ext-scripts without path
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/snmp.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 6c0ef91c3..918c7f128 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -36,6 +36,7 @@ config_file_daemon = r'/etc/snmp/snmpd.conf'
config_file_access = r'/usr/share/snmp/snmpd.conf'
config_file_user = r'/var/lib/snmp/snmpd.conf'
config_file_init = r'/etc/default/snmpd'
+default_script_dir = r'/config/user-data/'
# SNMP OIDs used to mark auth/priv type
OIDs = {
@@ -201,7 +202,7 @@ group {{ u.group }} usm {{ u.name }}
{% if script_ext %}
# extension scripts
-{%- for ext in script_ext|sort %}
+{%- for ext in script_ext|sort(attribute='name') %}
extend {{ ext.name }} {{ ext.script }}
{%- endfor %}
{% endif %}
@@ -348,9 +349,14 @@ def get_config():
#
if conf.exists('script-extensions'):
for extname in conf.list_nodes('script-extensions extension-name'):
+ conf_script = conf.return_value('script-extensions extension-name {} script'.format(extname))
+ # if script has not absolute path, use pre configured path
+ if "/" not in conf_script:
+ conf_script = default_script_dir + conf_script
+
extension = {
'name': extname,
- 'script' : conf.return_value('script-extensions extension-name {} script'.format(extname))
+ 'script' : conf_script
}
snmp['script_ext'].append(extension)
@@ -546,7 +552,7 @@ def verify(snmp):
if snmp is None:
return None
- ### check if the configured script actually exist under /config/user-data
+ ### check if the configured script actually exist
if snmp['script_ext']:
for ext in snmp['script_ext']:
if not os.path.isfile(ext['script']):