diff options
author | Christian Breunig <christian@breunig.cc> | 2023-08-02 12:30:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 12:30:00 +0200 |
commit | f8cc7f8ee7c87bd95198dfe6c28c966e840ab571 (patch) | |
tree | b04f27705b5dc6813ac188d4b0083f14082fe8fe | |
parent | ea30c0307996ec301474820bbcbf90d5eda7fda4 (diff) | |
parent | c7f872b038df835ba909d294156792e4119ffc5e (diff) | |
download | vyos-1x-f8cc7f8ee7c87bd95198dfe6c28c966e840ab571.tar.gz vyos-1x-f8cc7f8ee7c87bd95198dfe6c28c966e840ab571.zip |
Merge pull request #2128 from aapostoliuk/T5426-sagitta
ipsec: T5426: Added exceptions in vici functions calls
-rw-r--r-- | python/vyos/ipsec.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/python/vyos/ipsec.py b/python/vyos/ipsec.py index bb5611025..4603aab22 100644 --- a/python/vyos/ipsec.py +++ b/python/vyos/ipsec.py @@ -33,9 +33,11 @@ def get_vici_sas(): session = vici_session() except Exception: raise ViciInitiateError("IPsec not initialized") - sas = list(session.list_sas()) - return sas - + try: + sas = list(session.list_sas()) + return sas + except Exception: + raise ViciCommandError(f'Failed to get SAs') def get_vici_connections(): from vici import Session as vici_session @@ -44,9 +46,11 @@ def get_vici_connections(): session = vici_session() except Exception: raise ViciInitiateError("IPsec not initialized") - connections = list(session.list_conns()) - return connections - + try: + connections = list(session.list_conns()) + return connections + except Exception: + raise ViciCommandError(f'Failed to get connections') def get_vici_sas_by_name(ike_name: str, tunnel: str) -> list: """ |