summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
Diffstat (limited to 'src/system')
-rwxr-xr-xsrc/system/keepalived-fifo.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/system/keepalived-fifo.py b/src/system/keepalived-fifo.py
index 5e85da4a4..2778deaab 100755
--- a/src/system/keepalived-fifo.py
+++ b/src/system/keepalived-fifo.py
@@ -20,7 +20,6 @@ import time
import signal
import argparse
import threading
-import subprocess
import re
import json
from pathlib import Path
@@ -28,6 +27,8 @@ from queue import Queue
import logging
from logging.handlers import SysLogHandler
+from vyos.util import cmd
+
# configure logging
logger = logging.getLogger(__name__)
logs_format = logging.Formatter('%(filename)s: %(message)s')
@@ -84,14 +85,11 @@ class KeepalivedFifo:
# run command
def _run_command(self, command):
+ logger.debug("Running the command: {}".format(command))
try:
- logger.debug("Running the command: {}".format(command))
- process = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
- stdout, stderr = process.communicate()
- if process.returncode != 0:
- raise Exception("The command \"{}\" returned status {}. Error: {}".format(command, process.returncode, stderr))
- except Exception as err:
- logger.error("Unable to execute command \"{}\": {}".format(command, err))
+ cmd(command, universal_newlines=True)
+ except OSError as err:
+ logger.error(f'Unable to execute command "{command}": {err}')
# create FIFO pipe
def pipe_create(self):