diff options
author | John Estabrook <jestabro@vyos.io> | 2022-12-14 11:47:41 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-12-14 11:49:43 -0600 |
commit | c4e56fe4f4d725592a873c1a77b0d11d347a2530 (patch) | |
tree | 68af5df21587732d7f302b39d288291ac98df343 | |
parent | 92aa324fef80bdb0bcb3e93feba2f4e2aa787d38 (diff) | |
download | vyos-1x-c4e56fe4f4d725592a873c1a77b0d11d347a2530.tar.gz vyos-1x-c4e56fe4f4d725592a873c1a77b0d11d347a2530.zip |
ocserv: T4881: return vyos.opmode.Errors on failure
-rwxr-xr-x | src/op_mode/openconnect.py | 14 |
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: |