summaryrefslogtreecommitdiff
path: root/src/conf_mode/host_name.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-05-02 17:09:32 +0200
committerGitHub <noreply@github.com>2024-05-02 17:09:32 +0200
commit330379503281506fcfc66fd53b6e67bc2e887bd0 (patch)
tree74cd4fb2c11aad2a1b65e186a4b9a21999dc10cd /src/conf_mode/host_name.py
parent087a04327ca37fd6781e21f645b53962b6bf2cc8 (diff)
parent637e5faaa0af9b897a8d20c6dbb7ac670842b092 (diff)
downloadvyos-1x-330379503281506fcfc66fd53b6e67bc2e887bd0.tar.gz
vyos-1x-330379503281506fcfc66fd53b6e67bc2e887bd0.zip
Merge pull request #3397 from vyos/mergify/bp/equuleus/pr-33861.3.7
T6056: Change static-host-mapping should not restart snmpd (backport #3386)
Diffstat (limited to 'src/conf_mode/host_name.py')
-rwxr-xr-xsrc/conf_mode/host_name.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py
index 1e4667cac..8363e585e 100755
--- a/src/conf_mode/host_name.py
+++ b/src/conf_mode/host_name.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018-2021 VyOS maintainers and contributors
+# Copyright (C) 2018-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -23,6 +23,7 @@ import vyos.hostsd_client
from vyos import ConfigError
from vyos.config import Config
+from vyos.configdict import leaf_node_changed
from vyos.ifconfig import Section
from vyos.template import is_ip
from vyos.util import cmd
@@ -37,6 +38,7 @@ default_config_data = {
'domain_search': [],
'nameserver': [],
'nameservers_dhcp_interfaces': {},
+ 'snmpd_restart_reqired': False,
'static_host_mapping': {}
}
@@ -52,6 +54,10 @@ def get_config(config=None):
hosts['hostname'] = conf.return_value(['system', 'host-name'])
+ base = ['system']
+ if leaf_node_changed(conf, base + ['host-name']) or leaf_node_changed(conf, base + ['domain-name']):
+ hosts['snmpd_restart_reqired'] = True
+
# This may happen if the config is not loaded yet,
# e.g. if run by cloud-init
if not hosts['hostname']:
@@ -170,7 +176,7 @@ def apply(config):
call("systemctl restart rsyslog.service")
# If SNMP is running, restart it too
- if process_named_running('snmpd'):
+ if process_named_running('snmpd') and config['snmpd_restart_reqired']:
call('systemctl restart snmpd.service')
return None