summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
Diffstat (limited to 'src/op_mode')
-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__])