summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-05 18:06:11 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-04-06 20:22:35 +0100
commit7f1cef22f0b1a1d7a2b16a2800abdff0a9d5179f (patch)
treee0e9550e2453d12e5ee4274f0982a177ff912935 /src
parent5d7f48ad03bff62e6350c1a30cf9929c39d9d2e6 (diff)
downloadvyos-1x-7f1cef22f0b1a1d7a2b16a2800abdff0a9d5179f.tar.gz
vyos-1x-7f1cef22f0b1a1d7a2b16a2800abdff0a9d5179f.zip
util: T2226: rewrite keepalived to use cmd
Diffstat (limited to 'src')
-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):