From 7b093d84e008789ba03448d966e3d706c3500e34 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Thu, 13 Jul 2017 08:43:32 -0300 Subject: [PATCH] topogen: handle JSON decode failures Instead of raise()ing, return a empty dictionary. --- tests/topotests/lib/topogen.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 758ebcf2bf..ad8dd813c2 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -645,7 +645,11 @@ class TopoRouter(TopoGear): if isjson is False: return output - return json.loads(output) + try: + return json.loads(output) + except ValueError: + logger.warning('vtysh_cmd: failed to convert json output') + return {} def vtysh_multicmd(self, commands, pretty_output=True): """ -- 2.39.5