From a6c51fe49e7f0703849cd2bde822ade793d7755f Mon Sep 17 00:00:00 2001 From: Sun Austin Date: Tue, 8 Jan 2019 11:41:46 +0800 Subject: [PATCH] Make lldp check neighbors more robust for config_management it can not find neighbors in some env and will throw exception when config_management is running. this change will catch all exception and not break config. Closes-bug: 1811040 Change-Id: I11b73a647addddf198723bc2654dac444d82d165 Signed-off-by: Sun Austin --- .../controllerconfig/controllerconfig/config_management.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllerconfig/controllerconfig/controllerconfig/config_management.py b/controllerconfig/controllerconfig/controllerconfig/config_management.py index b76c7168b6..db42355336 100644 --- a/controllerconfig/controllerconfig/controllerconfig/config_management.py +++ b/controllerconfig/controllerconfig/controllerconfig/config_management.py @@ -67,7 +67,11 @@ def configure_management(): print("Retrieving neighbor details... ", end=' ') lldpcli_show_output = subprocess.check_output( ['sudo', 'lldpcli', 'show', 'neighbors', 'summary', '-f', 'json']) - lldp_interfaces = json.loads(lldpcli_show_output)['lldp'][0]['interface'] + try: + lldp_interfaces = json.loads( + lldpcli_show_output)['lldp'][0]['interface'] + except Exception as e: + lldp_interfaces = {} print("DONE") print("\nAvailable interfaces:")