From 9356a2a0609ddac0ade28b1ac95bb0510a40872f Mon Sep 17 00:00:00 2001 From: Prince George Date: Wed, 27 Jul 2022 23:58:41 +0000 Subject: [PATCH] Addressed review comments --- sonic-xcvrd/tests/test_xcvrd.py | 10 +++++----- sonic-xcvrd/xcvrd/xcvrd.py | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index 1b9e0292e..298b26f3e 100644 --- a/sonic-xcvrd/tests/test_xcvrd.py +++ b/sonic-xcvrd/tests/test_xcvrd.py @@ -452,17 +452,17 @@ def test_CmisManagerTask_get_configured_freq(self, mock_table_helper): cfg_port_tbl.get = MagicMock(return_value=(True, (('laser_freq', 193100),))) mock_table_helper.get_cfg_port_tbl = MagicMock(return_value=cfg_port_tbl) task.xcvr_table_helper.get_cfg_port_tbl = mock_table_helper.get_cfg_port_tbl - assert task.get_configured_laser_freq('Ethernet0') == 193100 + assert task.get_configured_laser_freq_from_db('Ethernet0') == 193100 @patch('xcvrd.xcvrd.XcvrTableHelper') - def test_CmisManagerTask_get_configured_tx_power(self, mock_table_helper): + def test_CmisManagerTask_get_configured_tx_power_from_db(self, mock_table_helper): port_mapping = PortMapping() task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping) cfg_port_tbl = MagicMock() cfg_port_tbl.get = MagicMock(return_value=(True, (('tx_power', -10),))) mock_table_helper.get_cfg_port_tbl = MagicMock(return_value=cfg_port_tbl) task.xcvr_table_helper.get_cfg_port_tbl = mock_table_helper.get_cfg_port_tbl - assert task.get_configured_tx_power('Ethernet0') == -10 + assert task.get_configured_tx_power_from_db('Ethernet0') == -10 @patch('xcvrd.xcvrd.platform_chassis') @patch('xcvrd.xcvrd_utilities.port_mapping.subscribe_port_update_event', MagicMock(return_value=(None, None))) @@ -575,8 +575,8 @@ def test_CmisManagerTask_task_worker(self, mock_chassis): task.get_host_tx_status = MagicMock(return_value='true') task.get_port_admin_status = MagicMock(return_value='up') - task.get_configured_tx_power = MagicMock(return_value=-13) - task.get_configured_laser_freq = MagicMock(return_value=193100) + task.get_configured_tx_power_from_db = MagicMock(return_value=-13) + task.get_configured_laser_freq_from_db = MagicMock(return_value=193100) task.configure_tx_output_power = MagicMock(return_value=1) task.configure_laser_frequency = MagicMock(return_value=1) diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index 9fd302f00..c73ebadb9 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -1207,7 +1207,7 @@ def check_datapath_state(self, api, channel, states): return done - def get_configured_laser_freq(self, lport): + def get_configured_laser_freq_from_db(self, lport): """ Return the Tx power configured by user in CONFIG_DB's PORT table """ @@ -1220,7 +1220,7 @@ def get_configured_laser_freq(self, lport): freq = dict(port_info)['laser_freq'] return int(freq) - def get_configured_tx_power(self, lport): + def get_configured_tx_power_from_db(self, lport): """ Return the Tx power configured by user in CONFIG_DB's PORT table """ @@ -1362,13 +1362,12 @@ def task_worker(self): if api.is_coherent_module(): if 'tx_power' not in self.port_dict[lport]: - self.port_dict[lport]['tx_power'] = self.get_configured_tx_power(lport) + self.port_dict[lport]['tx_power'] = self.get_configured_tx_power_from_db(lport) if 'laser_freq' not in self.port_dict[lport]: - self.port_dict[lport]['laser_freq'] = self.get_configured_laser_freq(lport) + self.port_dict[lport]['laser_freq'] = self.get_configured_laser_freq_from_db(lport) except AttributeError: # Skip if these essential routines are not available self.port_dict[lport]['cmis_state'] = self.CMIS_STATE_READY - assert 1 == 0 continue # CMIS expiration and retries