Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
prgeor committed Jul 27, 2022
1 parent 491e21f commit 9356a2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 4 additions & 5 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9356a2a

Please sign in to comment.