summaryrefslogtreecommitdiff
path: root/src/conf_mode/host_name.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-09 19:08:24 +0100
committerGitHub <noreply@github.com>2020-04-09 20:08:24 +0200
commit9875a21bdb26df19f2faf3e81153dea15e4f9e3c (patch)
tree8a1ecc1b318d80db156f397c34bc75f40c184728 /src/conf_mode/host_name.py
parentc8a86d3ccee63b972c36346e6cb1c712c6801ad2 (diff)
downloadvyos-1x-9875a21bdb26df19f2faf3e81153dea15e4f9e3c.tar.gz
vyos-1x-9875a21bdb26df19f2faf3e81153dea15e4f9e3c.zip
util: T2226: os.system was wrongly converted to run
os.system does print the ouput of the command, run() does not. A new function called call() does the printing and return the error code.
Diffstat (limited to 'src/conf_mode/host_name.py')
-rwxr-xr-xsrc/conf_mode/host_name.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py
index 690d1e030..7c2f79abc 100755
--- a/src/conf_mode/host_name.py
+++ b/src/conf_mode/host_name.py
@@ -33,7 +33,9 @@ import vyos.hostsd_client
from vyos.config import Config
from vyos import ConfigError
-from vyos.util import cmd, run
+from vyos.util import cmd
+from vyos.util import call
+from vyos.util import run
default_config_data = {
@@ -157,21 +159,21 @@ def apply(config):
# rsyslog runs into a race condition at boot time with systemd
# restart rsyslog only if the hostname changed.
hostname_old = cmd('hostnamectl --static')
- cmd(f'hostnamectl set-hostname --static {hostname_new}')
+ call(f'hostnamectl set-hostname --static {hostname_new}')
# Restart services that use the hostname
if hostname_new != hostname_old:
- run("systemctl restart rsyslog.service")
+ call("systemctl restart rsyslog.service")
# If SNMP is running, restart it too
- ret = run("pgrep snmpd > /dev/null")
+ ret = run("pgrep snmpd")
if ret == 0:
- run("systemctl restart snmpd.service")
+ call("systemctl restart snmpd.service")
# restart pdns if it is used
- ret = run('/usr/bin/rec_control ping >/dev/null 2>&1')
+ ret = run('/usr/bin/rec_control ping')
if ret == 0:
- run('/etc/init.d/pdns-recursor restart >/dev/null')
+ call('/etc/init.d/pdns-recursor restart >/dev/null')
return None