diff options
author | aapostoliuk <a.apostoliuk@vyos.io> | 2022-08-25 18:59:10 +0300 |
---|---|---|
committer | aapostoliuk <a.apostoliuk@vyos.io> | 2022-08-26 15:24:14 +0300 |
commit | 141bf8d437b6c0c76fd0fc21659d10d4477c92a0 (patch) | |
tree | 05e629b5a1c16ac465c2c763c1a6fda2c65a85e9 /src/etc/opennhrp | |
parent | 38ab693dc9755f249283a6ded00c2e4d966b3380 (diff) | |
download | vyos-1x-141bf8d437b6c0c76fd0fc21659d10d4477c92a0.tar.gz vyos-1x-141bf8d437b6c0c76fd0fc21659d10d4477c92a0.zip |
opennhrp: T1070: Fixed creating IPSEC tunnel to Hub
Fixed creating IPSEC tunnel to Hub. Added continues of execution
generator functions.
Diffstat (limited to 'src/etc/opennhrp')
-rwxr-xr-x | src/etc/opennhrp/opennhrp-script.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/etc/opennhrp/opennhrp-script.py b/src/etc/opennhrp/opennhrp-script.py index a5293c97e..bf25a7331 100755 --- a/src/etc/opennhrp/opennhrp-script.py +++ b/src/etc/opennhrp/opennhrp-script.py @@ -81,7 +81,13 @@ def vici_ike_terminate(list_ikeid: list[str]) -> bool: session = vici.Session() for ikeid in list_ikeid: logger.info(f'Terminating IKE SA with id {ikeid}') - session.terminate({'ike-id': ikeid, 'timeout': '-1'}) + session_generator = session.terminate( + {'ike-id': ikeid, 'timeout': '-1'}) + # a dummy `for` loop is required because of requirements + # from vici. Without a full iteration on the output, the + # command to vici may not be executed completely + for _ in session_generator: + pass return True except Exception as err: logger.error(f'Failed to terminate SA for IKE ids {list_ikeid}: {err}') @@ -175,13 +181,18 @@ def vici_initiate(conn: str, child_sa: str, src_addr: str, f'src_addr: {src_addr}, dst_addr: {dest_addr}') try: session = vici.Session() - session.initiate({ + session_generator = session.initiate({ 'ike': conn, 'child': child_sa, 'timeout': '-1', 'my-host': src_addr, 'other-host': dest_addr }) + # a dummy `for` loop is required because of requirements + # from vici. Without a full iteration on the output, the + # command to vici may not be executed completely + for _ in session_generator: + pass return True except Exception as err: logger.error(f'Unable to initiate connection {err}') |