diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-09 19:08:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 20:08:24 +0200 |
commit | 9875a21bdb26df19f2faf3e81153dea15e4f9e3c (patch) | |
tree | 8a1ecc1b318d80db156f397c34bc75f40c184728 /src/op_mode/restart_frr.py | |
parent | c8a86d3ccee63b972c36346e6cb1c712c6801ad2 (diff) | |
download | vyos-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/op_mode/restart_frr.py')
-rwxr-xr-x | src/op_mode/restart_frr.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/op_mode/restart_frr.py b/src/op_mode/restart_frr.py index 6304e72db..d1b66b33f 100755 --- a/src/op_mode/restart_frr.py +++ b/src/op_mode/restart_frr.py @@ -22,7 +22,7 @@ from logging.handlers import SysLogHandler from pathlib import Path import psutil -from vyos.util import run +from vyos.util import call # some default values watchfrr = '/usr/lib/frr/watchfrr.sh' @@ -87,7 +87,7 @@ def _write_config(): Path(frrconfig_tmp).mkdir(parents=False, exist_ok=True) # save frr.conf to it command = "{} -n -w --config_dir {} 2> /dev/null".format(vtysh, frrconfig_tmp) - return_code = run(command) + return_code = call(command) if not return_code == 0: logger.error("Failed to save active config: \"{}\" returned exit code: {}".format(command, return_code)) return False @@ -109,7 +109,7 @@ def _cleanup(): # check if daemon is running def _daemon_check(daemon): command = "{} print_status {}".format(watchfrr, daemon) - return_code = run(command) + return_code = call(command) if not return_code == 0: logger.error("Daemon \"{}\" is not running".format(daemon)) return False @@ -120,7 +120,7 @@ def _daemon_check(daemon): # restart daemon def _daemon_restart(daemon): command = "{} restart {}".format(watchfrr, daemon) - return_code = run(command) + return_code = call(command) if not return_code == 0: logger.error("Failed to restart daemon \"{}\"".format(daemon)) return False @@ -136,7 +136,7 @@ def _reload_config(daemon): else: command = "{} -n -b --config_dir {} 2> /dev/null".format(vtysh, frrconfig_tmp) - return_code = run(command) + return_code = call(command) if not return_code == 0: logger.error("Failed to reinstall configuration") return False |