diff --git a/sonic-xcvrd/setup.py b/sonic-xcvrd/setup.py index 27a1ab3bd905..7eea188314af 100644 --- a/sonic-xcvrd/setup.py +++ b/sonic-xcvrd/setup.py @@ -37,7 +37,6 @@ 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.7', 'Topic :: System :: Hardware', ], diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index dc904a040a22..43fad58b8fe6 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -1926,7 +1926,7 @@ def task_worker(self, stopping_event, sfp_error_event): self.sfp_error_dict[key] = (value, error_dict) else: self.sfp_error_dict.pop(key, None) - logical_port_list = self.port_mapping.get_physical_to_logical(key) + logical_port_list = self.port_mapping.get_physical_to_logical(int(key)) if logical_port_list is None: helper_logger.log_warning("Got unknown FP port index {}, ignored".format(key)) continue @@ -1939,15 +1939,15 @@ def task_worker(self, stopping_event, sfp_error_event): continue if value == sfp_status_helper.SFP_STATUS_INSERTED: - helper_logger.log_info("Got SFP inserted event") + helper_logger.log_notice("{}: Got SFP inserted event".format(logical_port)) # A plugin event will clear the error state. update_port_transceiver_status_table_sw( logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED) - helper_logger.log_info("receive plug in and update port sfp status table.") + helper_logger.log_notice("{}: received plug in and update port sfp status table.".format(logical_port)) rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict) # If we didn't get the sfp info, assuming the eeprom is not ready, give a try again. if rc == SFP_EEPROM_NOT_READY: - helper_logger.log_warning("SFP EEPROM is not ready. One more try...") + helper_logger.log_warning("{}: SFP EEPROM is not ready. One more try...".format(logical_port)) time.sleep(TIME_FOR_SFP_READY_SECS) rc = post_port_sfp_info_to_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), transceiver_dict) if rc == SFP_EEPROM_NOT_READY: @@ -1962,10 +1962,10 @@ def task_worker(self, stopping_event, sfp_error_event): notify_media_setting(logical_port, transceiver_dict, self.xcvr_table_helper.get_app_port_tbl(asic_index), self.port_mapping) transceiver_dict.clear() elif value == sfp_status_helper.SFP_STATUS_REMOVED: - helper_logger.log_info("Got SFP removed event") + helper_logger.log_notice("{}: Got SFP removed event".format(logical_port)) update_port_transceiver_status_table_sw( logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_REMOVED) - helper_logger.log_info("receive plug out and pdate port sfp status table.") + helper_logger.log_notice("{}: received plug out and update port sfp status table.".format(logical_port)) del_port_sfp_dom_info_from_db(logical_port, self.port_mapping, self.xcvr_table_helper.get_intf_tbl(asic_index), self.xcvr_table_helper.get_dom_tbl(asic_index), @@ -1975,7 +1975,7 @@ def task_worker(self, stopping_event, sfp_error_event): else: try: error_bits = int(value) - helper_logger.log_info("Got SFP error event {}".format(value)) + helper_logger.log_error("{}: Got SFP error event {}".format(logical_port, value)) error_descriptions = sfp_status_helper.fetch_generic_error_description(error_bits) @@ -1989,7 +1989,7 @@ def task_worker(self, stopping_event, sfp_error_event): # Add error info to database # Any existing error will be replaced by the new one. update_port_transceiver_status_table_sw(logical_port, self.xcvr_table_helper.get_status_tbl(asic_index), value, '|'.join(error_descriptions)) - helper_logger.log_info("Receive error update port sfp status table.") + helper_logger.log_notice("{}: Receive error update port sfp status table.".format(logical_port)) # In this case EEPROM is not accessible. The DOM info will be removed since it can be out-of-date. # The interface info remains in the DB since it is static. if sfp_status_helper.is_error_block_eeprom_reading(error_bits): @@ -2001,7 +2001,7 @@ def task_worker(self, stopping_event, sfp_error_event): self.xcvr_table_helper.get_pm_tbl(asic_index)) delete_port_from_status_table_hw(logical_port, self.port_mapping, self.xcvr_table_helper.get_status_tbl(asic_index)) except (TypeError, ValueError) as e: - helper_logger.log_error("Got unrecognized event {}, ignored".format(value)) + helper_logger.log_error("{}: Got unrecognized event {}, ignored".format(logical_port, value)) else: next_state = STATE_EXIT diff --git a/sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py b/sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py index 1cc1b9f8e1e4..c7965f343ef9 100644 --- a/sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py +++ b/sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py @@ -78,7 +78,8 @@ def get_logical_to_physical(self, port_name): port_index = self.logical_to_physical.get(port_name) return None if port_index is None else [port_index] - def get_physical_to_logical(self, physical_port): + def get_physical_to_logical(self, physical_port: int): + assert isinstance(physical_port, int), "{} is NOT integer".format(physical_port) return self.physical_to_logical.get(physical_port) def logical_port_name_to_physical_port_list(self, port_name):