diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-05-01 17:22:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 17:22:05 +0200 |
commit | 3286835c3167096983a6816b13e3904f038db4d5 (patch) | |
tree | 335ec22f994b65b7dc0487736c2c3812b371fd35 | |
parent | 91c1a8556eedc9e9aa50d8bf415b37e53d52cb7d (diff) | |
parent | 4f1db505791deed533dddf0c2f5bdedd6fba34b8 (diff) | |
download | vyos-1x-3286835c3167096983a6816b13e3904f038db4d5.tar.gz vyos-1x-3286835c3167096983a6816b13e3904f038db4d5.zip |
Merge pull request #3386 from sever-sever/T6056
T6056: Change static-host-mapping should not restart snmpd
-rwxr-xr-x | src/conf_mode/system_host-name.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/conf_mode/system_host-name.py b/src/conf_mode/system_host-name.py index 8975cadb6..3f245f166 100755 --- a/src/conf_mode/system_host-name.py +++ b/src/conf_mode/system_host-name.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2018-2023 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 @@ -22,6 +22,7 @@ import vyos.hostsd_client from vyos.base import Warning 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.utils.process 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']: @@ -171,7 +177,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 |