summaryrefslogtreecommitdiff
path: root/src/conf_mode/intel_qat.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-05 17:12:50 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-04-06 20:22:35 +0100
commitdade749c3bc170e038ab676022e9ee8870753aa8 (patch)
tree6df3a6997c3b518a54b67c6f0e0e11487ead8b13 /src/conf_mode/intel_qat.py
parent9e920477511d6d6286767597e17d09bd66aae70b (diff)
downloadvyos-1x-dade749c3bc170e038ab676022e9ee8870753aa8.tar.gz
vyos-1x-dade749c3bc170e038ab676022e9ee8870753aa8.zip
util: T2226: rewrite qat to use run vyos.util
Diffstat (limited to 'src/conf_mode/intel_qat.py')
-rwxr-xr-xsrc/conf_mode/intel_qat.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/conf_mode/intel_qat.py b/src/conf_mode/intel_qat.py
index a1abd5e81..cc7d4a915 100755
--- a/src/conf_mode/intel_qat.py
+++ b/src/conf_mode/intel_qat.py
@@ -19,10 +19,10 @@
import sys
import os
import re
-import subprocess
from vyos.config import Config
from vyos import ConfigError
+from vyos.util import popen, run
# Define for recovering
gl_ipsec_conf = None
@@ -49,13 +49,10 @@ def get_config():
# Control configured VPN service which can use QAT
def vpn_control(action):
+ # XXX: Should these commands report failure
if action == 'restore' and gl_ipsec_conf:
- ret = subprocess.Popen(['sudo', 'ipsec', 'start'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (output, err) = ret.communicate()
- return
-
- ret = subprocess.Popen(['sudo', 'ipsec', action], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (output, err) = ret.communicate()
+ return run('sudo ipsec start')
+ return run(f'sudo ipsec {action}')
def verify(c):
# Check if QAT service installed
@@ -66,10 +63,9 @@ def verify(c):
return
# Check if QAT device exist
- ret = subprocess.Popen(['sudo', 'lspci', '-nn'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (output, err) = ret.communicate()
+ output, err = popen('sudo lspci -nn', decode='utf-8')
if not err:
- data = re.findall('(8086:19e2)|(8086:37c8)|(8086:0435)|(8086:6f54)', output.decode("utf-8"))
+ data = re.findall('(8086:19e2)|(8086:37c8)|(8086:0435)|(8086:6f54)', output)
#If QAT devices found
if not data:
print("\t No QAT acceleration device found")
@@ -82,17 +78,13 @@ def apply(c):
# Disable QAT service
if c['qat_conf'] == None:
- ret = subprocess.Popen(['sudo', '/etc/init.d/vyos-qat-utilities', 'stop'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (output, err) = ret.communicate()
+ run('sudo /etc/init.d/vyos-qat-utilities stop')
if c['ipsec_conf']:
vpn_control('start')
-
return
# Run qat init.d script
- ret = subprocess.Popen(['sudo', '/etc/init.d/vyos-qat-utilities', 'start'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (output, err) = ret.communicate()
-
+ run('sudo /etc/init.d/vyos-qat-utilities start')
if c['ipsec_conf']:
# Recovery VPN service
vpn_control('start')