From 42ef3d13905d75796228eaeab1cf4639560c5c69 Mon Sep 17 00:00:00 2001 From: anamehra Date: Tue, 23 Aug 2022 14:15:29 -0700 Subject: [PATCH] Use get() to fetch data from dictionary The config db dictionary may not have admin_status available for a port if the same is not set in config db file. Use get() function to prevent crash and set default status to 'down'. Signed-off-by: anamehra --- sonic-xcvrd/xcvrd/xcvrd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index c73ebadb9..6814c1fd3 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -1253,7 +1253,7 @@ def get_port_admin_status(self, lport): found, port_info = cfg_port_tbl.get(lport) if found: # Check admin_status too ...just in case - admin_status = dict(port_info)['admin_status'] + admin_status = dict(port_info).get('admin_status', 'down') return admin_status def configure_tx_output_power(self, api, lport, tx_power):