summaryrefslogtreecommitdiff
path: root/src/op_mode/openvpn.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-12-06 14:10:21 -0600
committerJohn Estabrook <jestabro@vyos.io>2022-12-12 09:17:20 -0600
commit9af23d814aa37e90aca350375eeb7b9e83069eee (patch)
tree968d5cffe65ca03cac8a1bdcfcf27169a1c7b7bb /src/op_mode/openvpn.py
parente65fd4853996375687bd3094ec8338a1ad317b3d (diff)
downloadvyos-1x-9af23d814aa37e90aca350375eeb7b9e83069eee.tar.gz
vyos-1x-9af23d814aa37e90aca350375eeb7b9e83069eee.zip
openvpn: T4770: add reset function to openvpn.py
Diffstat (limited to 'src/op_mode/openvpn.py')
-rwxr-xr-xsrc/op_mode/openvpn.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/op_mode/openvpn.py b/src/op_mode/openvpn.py
index d66fa08fe..3797a7153 100755
--- a/src/op_mode/openvpn.py
+++ b/src/op_mode/openvpn.py
@@ -22,6 +22,8 @@ from tabulate import tabulate
import vyos.opmode
from vyos.util import bytes_to_human
+from vyos.util import commit_in_progress
+from vyos.util import call
from vyos.config import Config
def _get_tunnel_address(peer_host, peer_port, status_file):
@@ -200,6 +202,14 @@ def show(raw: bool, mode: str) -> str:
return _format_openvpn(openvpn_data)
+def reset(interface: str):
+ if os.path.isfile(f'/run/openvpn/{interface}.conf'):
+ if commit_in_progress():
+ raise vyos.opmode.CommitInProgress('Retry OpenVPN reset: commit in progress.')
+ call(f'systemctl restart openvpn@{interface}.service')
+ else:
+ raise vyos.opmode.IncorrectValue(f'OpenVPN interface "{interface}" does not exist!')
+
if __name__ == '__main__':
try:
res = vyos.opmode.run(sys.modules[__name__])