From 77e578c90e32151603850c83082fb4e7b2875f60 Mon Sep 17 00:00:00 2001 From: Kuldeep Kashyap Date: Thu, 17 Mar 2022 13:58:29 +0530 Subject: [PATCH] tests: Fix topotests crash when KeyError found 1. Handle KeyError 2. logger object is defined in main function and its not not accessible in other functions so defined it in local functions. Signed-off-by: Kuldeep Kashyap --- tests/topotests/lib/micronet_cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/micronet_cli.py b/tests/topotests/lib/micronet_cli.py index 4292f47ce0..ef804f6dc2 100644 --- a/tests/topotests/lib/micronet_cli.py +++ b/tests/topotests/lib/micronet_cli.py @@ -110,7 +110,7 @@ def doline(unet, line, writef): args = oargs.split() if not args or (len(args) == 1 and args[0] == "*"): args = sorted(unet.hosts.keys()) - hosts = [unet.hosts[x] for x in args] + hosts = [unet.hosts[x] for x in args if x in unet.hosts] for host in hosts: if cmd == "t" or cmd == "term": host.run_in_window("bash", title="sh-%s" % host) @@ -250,6 +250,8 @@ def cli( prompt=None, background=True, ): + logger = logging.getLogger("cli-client") + if prompt is None: prompt = "unet> " -- 2.39.5