summaryrefslogtreecommitdiff
path: root/src/conf_mode/accel_l2tp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-07 08:27:36 +0200
committerGitHub <noreply@github.com>2020-04-07 08:27:36 +0200
commit09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c (patch)
tree6e7b0971ecd8859cff864b3ebb37f86f8ba288f5 /src/conf_mode/accel_l2tp.py
parente0f13b79a669e7fc8cadac8757b2f5fbbf51dc99 (diff)
parent7256810914e6664bf92041dcd7c3daf649ce0001 (diff)
downloadvyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.tar.gz
vyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.zip
Merge pull request #307 from thomas-mangin/T2226
util: T2226: convert all call to use vyos.util.{popen, cmd, run}
Diffstat (limited to 'src/conf_mode/accel_l2tp.py')
-rwxr-xr-xsrc/conf_mode/accel_l2tp.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/conf_mode/accel_l2tp.py b/src/conf_mode/accel_l2tp.py
index 77e1ee874..4ca5a858a 100755
--- a/src/conf_mode/accel_l2tp.py
+++ b/src/conf_mode/accel_l2tp.py
@@ -17,7 +17,7 @@
import sys
import os
import re
-import subprocess
+import jinja2
import socket
import time
@@ -26,6 +26,8 @@ from jinja2 import FileSystemLoader, Environment
from vyos.config import Config
from vyos.defaults import directories as vyos_data_dir
from vyos import ConfigError
+from vyos.util import run
+
pidfile = r'/var/run/accel_l2tp.pid'
l2tp_cnf_dir = r'/etc/accel-ppp/l2tp'
@@ -61,17 +63,10 @@ def chk_con():
break
-def accel_cmd(cmd=''):
- if not cmd:
- return None
- try:
- ret = subprocess.check_output(
- ['/usr/bin/accel-cmd', '-p', '2004', cmd]).decode().strip()
- return ret
- except:
- return 1
+def _accel_cmd(command):
+ return run(f'/usr/bin/accel-cmd -p 2004 {command}')
-###
+###
# inline helper functions end
###
@@ -375,21 +370,20 @@ def generate(c):
def apply(c):
if c == None:
if os.path.exists(pidfile):
- accel_cmd('shutdown hard')
+ _accel_cmd('shutdown hard')
if os.path.exists(pidfile):
os.remove(pidfile)
return None
if not os.path.exists(pidfile):
- ret = subprocess.call(
- ['/usr/sbin/accel-pppd', '-c', l2tp_conf, '-p', pidfile, '-d'])
+ ret = run(f'/usr/sbin/accel-pppd -c {l2tp_conf} -p {pidfile} -d')
chk_con()
if ret != 0 and os.path.exists(pidfile):
os.remove(pidfile)
raise ConfigError('accel-pppd failed to start')
else:
# if gw ip changes, only restart doesn't work
- accel_cmd('restart')
+ _accel_cmd('restart')
if __name__ == '__main__':