diff --git a/sonic_platform_base/sonic_xcvr/api/public/c_cmis.py b/sonic_platform_base/sonic_xcvr/api/public/c_cmis.py index 3b6479838..92a4a50fb 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/c_cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/c_cmis.py @@ -158,7 +158,7 @@ def freeze_vdm_stats(self): ''' return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_FREEZE) - def get_freeze_vdm_stats(self): + def get_vdm_freeze_status(self): ''' This function reads and returns the vdm Freeze done status. @@ -176,7 +176,7 @@ def unfreeze_vdm_stats(self): ''' return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_UNFREEZE) - def get_unfreeze_vdm_stats(self): + def get_vdm_unfreeze_status(self): ''' This function reads and returns the vdm unfreeze status. diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py b/sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py index a76c7a39e..dba2a7350 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py @@ -170,14 +170,6 @@ def get_vdm_allpage(self): return None VDM_START_PAGE = 0x20 vdm = dict() - # When raised by the host, causes the module to freeze and hold all - # reported statistics reporting registers (minimum, maximum and - # average values)in Pages 24h-27h. - # When ceased by the host, releases the freeze request, allowing the - # reported minimum, maximum and average values to update again. - self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_FREEZE) - time.sleep(1) - self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_UNFREEZE) vdm_flag_page = self.xcvr_eeprom.read_raw(VDM_FLAG_PAGE * PAGE_SIZE + PAGE_OFFSET, PAGE_SIZE) for page in range(VDM_START_PAGE, VDM_START_PAGE + vdm_page_supported_raw + 1): vdm_current_page = self.get_vdm_page(page, vdm_flag_page) diff --git a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py index 8012212f4..54e5ebf44 100644 --- a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py +++ b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py @@ -61,7 +61,10 @@ def freeze_vdm_stats(self): Returns True if the provision succeeds and False incase of failure. ''' api = self.get_xcvr_api() - return api.freeze_vdm_stats() if api is not None else None + try: + return api.freeze_vdm_stats() if api is not None else False + except (NotImplementedError, AttributeError): + return False def unfreeze_vdm_stats(self): ''' @@ -72,25 +75,36 @@ def unfreeze_vdm_stats(self): Returns True if the provision succeeds and False incase of failure. ''' api = self.get_xcvr_api() - return api.unfreeze_vdm_stats() if api is not None else None + try: + return api.unfreeze_vdm_stats() if api is not None else False + except (NotImplementedError, AttributeError): + return False + - def get_freeze_vdm_stats(self): + def get_vdm_freeze_status(self): ''' This function reads and returns the vdm Freeze done status. Returns True if the vdm stats freeze is successful and False if not freeze. ''' api = self.get_xcvr_api() - return api.get_freeze_vdm_stats() if api is not None else None + try: + return api.get_vdm_freeze_status() if api is not None else False + except (NotImplementedError, AttributeError): + return False - def get_unfreeze_vdm_stats(self): + def get_vdm_unfreeze_status(self): ''' This function reads and returns the vdm unfreeze status. Returns True if the vdm stats unfreeze is successful and False if not unfreeze. ''' api = self.get_xcvr_api() - return api.get_unfreeze_vdm_stats() if api is not None else None + try: + return api.get_vdm_unfreeze_status() if api is not None else False + except (NotImplementedError, AttributeError): + return False + def get_rx_los(self): api = self.get_xcvr_api() diff --git a/tests/sonic_xcvr/test_ccmis.py b/tests/sonic_xcvr/test_ccmis.py index fdb31368b..e81d3bdb2 100644 --- a/tests/sonic_xcvr/test_ccmis.py +++ b/tests/sonic_xcvr/test_ccmis.py @@ -629,20 +629,20 @@ def test_get_transceiver_pm(self, mock_response, expected): (0, 0), (1, 1), ]) - def test_get_freeze_vdm_stats(self, mock_response, expected): + def test_get_vdm_freeze_status(self, mock_response, expected): self.api.xcvr_eeprom.read = MagicMock() self.api.xcvr_eeprom.read.return_value = mock_response - result = self.api.get_freeze_vdm_stats() + result = self.api.get_vdm_freeze_status() assert result == expected @pytest.mark.parametrize("mock_response, expected", [ (0, 0), (1, 1), ]) - def test_get_unfreeze_vdm_stats(self, mock_response, expected): + def test_get_vdm_unfreeze_status(self, mock_response, expected): self.api.xcvr_eeprom.read = MagicMock() self.api.xcvr_eeprom.read.return_value = mock_response - result = self.api.get_unfreeze_vdm_stats() + result = self.api.get_vdm_unfreeze_stats() assert result == expected @pytest.mark.parametrize("mock_response, expected", [ diff --git a/tests/sonic_xcvr/test_sfp_optoe_base.py b/tests/sonic_xcvr/test_sfp_optoe_base.py index f5c53c1bf..54237e71b 100644 --- a/tests/sonic_xcvr/test_sfp_optoe_base.py +++ b/tests/sonic_xcvr/test_sfp_optoe_base.py @@ -49,13 +49,13 @@ def test_unfreeze_vdm_stats(self, mock_response1, mock_response2, expected): (1, ccmis_api, 1), (None, None, None), ]) - def test_get_freeze_vdm_stats(self, mock_response1, mock_response2, expected): + def test_get_vdm_freeze_status(self, mock_response1, mock_response2, expected): self.sfp_optoe_api.get_xcvr_api = MagicMock() self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 - self.ccmis_api.get_freeze_vdm_stats = MagicMock() - self.ccmis_api.get_freeze_vdm_stats.return_value = mock_response1 + self.ccmis_api.get_vdm_freeze_status = MagicMock() + self.ccmis_api.get_vdm_freeze_status.return_value = mock_response1 - result = self.sfp_optoe_api.get_freeze_vdm_stats() + result = self.sfp_optoe_api.get_vdm_freeze_status() assert result == expected @pytest.mark.parametrize("mock_response1, mock_response2, expected", [ @@ -63,12 +63,12 @@ def test_get_freeze_vdm_stats(self, mock_response1, mock_response2, expected): (1, ccmis_api, 1), (None, None, None), ]) - def test_get_unfreeze_vdm_stats(self, mock_response1, mock_response2, expected): + def test_get_vdm_unfreeze_status(self, mock_response1, mock_response2, expected): self.sfp_optoe_api.get_xcvr_api = MagicMock() self.sfp_optoe_api.get_xcvr_api.return_value = mock_response2 - self.ccmis_api.get_unfreeze_vdm_stats = MagicMock() - self.ccmis_api.get_unfreeze_vdm_stats.return_value = mock_response1 + self.ccmis_api.get_vdm_unfreeze_status = MagicMock() + self.ccmis_api.get_vdm_unfreeze_status.return_value = mock_response1 - result = self.sfp_optoe_api.get_unfreeze_vdm_stats() + result = self.sfp_optoe_api.get_vdm_unfreeze_status() assert result == expected