summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authoraapostoliuk <a.apostoliuk@vyos.io>2023-08-02 11:54:16 +0300
committeraapostoliuk <a.apostoliuk@vyos.io>2023-08-02 11:54:16 +0300
commitc7f872b038df835ba909d294156792e4119ffc5e (patch)
tree3ee29c08fb869866e78710a762aae3f1b5b81f14 /python
parentad57339e9ce655823e1f8e7ad25dc5560359b8da (diff)
downloadvyos-1x-c7f872b038df835ba909d294156792e4119ffc5e.tar.gz
vyos-1x-c7f872b038df835ba909d294156792e4119ffc5e.zip
ipsec: T5426: Added exceptions in vici functions calls
Added exceptions in vici functions calls
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ipsec.py16
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:
"""