summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-12-14 20:08:23 +0200
committerGitHub <noreply@github.com>2022-12-14 20:08:23 +0200
commit4c10181bf2b162a2cd703157eaf4f72d6c7c4a71 (patch)
tree68af5df21587732d7f302b39d288291ac98df343 /src
parent92aa324fef80bdb0bcb3e93feba2f4e2aa787d38 (diff)
parentc4e56fe4f4d725592a873c1a77b0d11d347a2530 (diff)
downloadvyos-1x-4c10181bf2b162a2cd703157eaf4f72d6c7c4a71.tar.gz
vyos-1x-4c10181bf2b162a2cd703157eaf4f72d6c7c4a71.zip
Merge pull request #1707 from jestabro/op-mode-openconnect
ocserv: T4881: return vyos.opmode.Errors on failure
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/openconnect.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/op_mode/openconnect.py b/src/op_mode/openconnect.py
index 00992c66a..b21890728 100755
--- a/src/op_mode/openconnect.py
+++ b/src/op_mode/openconnect.py
@@ -31,14 +31,7 @@ occtl_socket = '/run/ocserv/occtl.socket'
def _get_raw_data_sessions():
rc, out = rc_cmd(f'sudo {occtl} --json --socket-file {occtl_socket} show users')
if rc != 0:
- output = {'openconnect':
- {
- 'configured': False,
- 'return_code': rc,
- 'reason': out
- }
- }
- return output
+ raise vyos.opmode.DataUnavailable(out)
sessions = json.loads(out)
return sessions
@@ -61,9 +54,8 @@ def _get_formatted_sessions(data):
def show_sessions(raw: bool):
config = ConfigTreeQuery()
- if not config.exists('vpn openconnect') and not raw:
- print('Openconnect is not configured')
- exit(0)
+ if not config.exists('vpn openconnect'):
+ raise vyos.opmode.UnconfiguredSubsystem('Openconnect is not configured')
openconnect_data = _get_raw_data_sessions()
if raw: