summaryrefslogtreecommitdiff
path: root/src/op_mode/restart_frr.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-05 18:23:34 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-04-06 20:22:35 +0100
commit12fc1f7de98d582b289735c6a0ccedd83c5dfcc8 (patch)
treea1020a1fdb28a619fbcc43039290b3e1dc59f116 /src/op_mode/restart_frr.py
parenta0d8238710b56c53523800c181ae6639c577d38a (diff)
downloadvyos-1x-12fc1f7de98d582b289735c6a0ccedd83c5dfcc8.tar.gz
vyos-1x-12fc1f7de98d582b289735c6a0ccedd83c5dfcc8.zip
util: T2226: rewrite restart frr to use run
Diffstat (limited to 'src/op_mode/restart_frr.py')
-rwxr-xr-xsrc/op_mode/restart_frr.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/op_mode/restart_frr.py b/src/op_mode/restart_frr.py
index da6407e23..6304e72db 100755
--- a/src/op_mode/restart_frr.py
+++ b/src/op_mode/restart_frr.py
@@ -17,12 +17,13 @@
import sys
import argparse
-import subprocess
import logging
from logging.handlers import SysLogHandler
from pathlib import Path
import psutil
+from vyos.util import run
+
# some default values
watchfrr = '/usr/lib/frr/watchfrr.sh'
vtysh = '/usr/bin/vtysh'
@@ -86,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 = subprocess.call(command, shell=True)
+ return_code = run(command)
if not return_code == 0:
logger.error("Failed to save active config: \"{}\" returned exit code: {}".format(command, return_code))
return False
@@ -108,7 +109,7 @@ def _cleanup():
# check if daemon is running
def _daemon_check(daemon):
command = "{} print_status {}".format(watchfrr, daemon)
- return_code = subprocess.call(command, shell=True)
+ return_code = run(command)
if not return_code == 0:
logger.error("Daemon \"{}\" is not running".format(daemon))
return False
@@ -119,7 +120,7 @@ def _daemon_check(daemon):
# restart daemon
def _daemon_restart(daemon):
command = "{} restart {}".format(watchfrr, daemon)
- return_code = subprocess.call(command, shell=True)
+ return_code = run(command)
if not return_code == 0:
logger.error("Failed to restart daemon \"{}\"".format(daemon))
return False
@@ -135,7 +136,7 @@ def _reload_config(daemon):
else:
command = "{} -n -b --config_dir {} 2> /dev/null".format(vtysh, frrconfig_tmp)
- return_code = subprocess.call(command, shell=True)
+ return_code = run(command)
if not return_code == 0:
logger.error("Failed to reinstall configuration")
return False