From e5165b79dfe722052ea86694e5fe98429c735e36 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 9 Mar 2021 10:26:15 -0800 Subject: [PATCH] [xcvrd] Fix crash: If 'dom_capability' not in port_info_dict, insert 'N/A' (#162) Currently, some vendors are using custom transceiver info parsers which do not yet provide the `dom_capability` field in the results of `get_transceiver_info()`. However, PR https://github.com/Azure/sonic-platform-daemons/pull/72 introduced storing this value to State DB under the assumption that it would always be present. On platforms where this value is not present, it would cause xcvrd to crash (see issue: https://github.com/Azure/sonic-buildimage/issues/6978). This change will prevent a crash if it is not present, and will in turn save `'N/A'` as the `dom_capability` value in State DB. --- sonic-xcvrd/xcvrd/xcvrd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index 516e415dba56..cecb582b21bd 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -299,7 +299,8 @@ def post_port_sfp_info_to_db(logical_port_name, table, transceiver_dict, ('application_advertisement', port_info_dict['application_advertisement'] if 'application_advertisement' in port_info_dict else 'N/A'), ('is_replaceable', str(is_replaceable)), - ('dom_capability',port_info_dict['dom_capability']), + ('dom_capability', port_info_dict['dom_capability'] + if 'dom_capability' in port_info_dict else 'N/A'), ]) table.set(port_name, fvs) else: