From cdd9a35e1bcfc2b8d7fe32785bc7065793a3591b Mon Sep 17 00:00:00 2001 From: Gonza Rafuls Date: Mon, 7 Feb 2022 15:42:25 +0100 Subject: [PATCH] fix: netcat issue with async initalization Change-Id: Ie508d0bab7dd7d106522737b00cfe897777e5ee9 --- quads/tools/netcat.py | 1 + quads/tools/validate_env.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/quads/tools/netcat.py b/quads/tools/netcat.py index 31ed800a9..bde583cf1 100755 --- a/quads/tools/netcat.py +++ b/quads/tools/netcat.py @@ -15,6 +15,7 @@ def __init__(self, ip, port=22, loop=None): self.loop = loop if loop else get_running_loop() async def __aenter__(self): + await self.connect() return self async def __aexit__(self, *args): diff --git a/quads/tools/validate_env.py b/quads/tools/validate_env.py index 45bf4c935..79c26dd19 100755 --- a/quads/tools/validate_env.py +++ b/quads/tools/validate_env.py @@ -127,8 +127,8 @@ async def post_system_test(self): for host in pending: logger.info(host) try: - async with Netcat(host) as nc: - healthy = await nc.health_check() + nc = Netcat(host) + healthy = await nc.health_check() except OSError: healthy = False if not healthy: @@ -190,8 +190,8 @@ async def post_network_test(self): hosts_down = [] for host in self.hosts: try: - async with Netcat(host.name) as nc: - healthy = await nc.health_check() + nc = Netcat(host.name) + healthy = await nc.health_check() except OSError: healthy = False if not healthy: