Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_transceiver_status and get_transceiver_pm to API interface #315

Merged
merged 6 commits into from
Dec 6, 2022
Merged

Add get_transceiver_status and get_transceiver_pm to API interface #315

merged 6 commits into from
Dec 6, 2022

Conversation

longhuan-cisco
Copy link
Contributor

@longhuan-cisco longhuan-cisco commented Oct 18, 2022

Add get_transceiver_status and get_transceiver_pm to API interface

Description

  1. Add get_transceiver_status to API interface
  2. Add get_transceiver_pm API interface in xcvr_api.py
  3. Ignore if "Rx Signal Power" related fields not existing.
  4. Fix a typo in get_pm_all()

Motivation and Context

How Has This Been Tested?

Plz refer to parent PR for UT.

Additional Information (Optional)

Note
This PR serves as dependency for sonic-net/sonic-platform-daemons#304

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 18, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@longhuan-cisco
Copy link
Contributor Author

@prgeor please review. This is dependency of sonic-net/sonic-platform-daemons#304

Copy link
Contributor

@mihirpat1 mihirpat1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will also need to modify testing script to improve code coverage since it's less than 80% currently.

trans_status['rxsigpowerhighwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][7]
trans_status['rxsigpowerlowwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][8]
try:
trans_status['rxsigpowerhighalarm_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][5]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - Are we seeing KeyError exception for ZR since I didn't find this being populated in the UT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.
And I saw similar key error handling in c_cmis.py:get_transceiver_threshold_info() for self.vdm_dict['Rx Signal Power [dBm]']

@longhuan-cisco
Copy link
Contributor Author

I think you will also need to modify testing script to improve code coverage since it's less than 80% currently.

Added testcase in test_ccmis.py to cover the case of 'Rx Signal Power [dBm]' not present.

@longhuan-cisco
Copy link
Contributor Author

@prgeor @mihirpat1 I took care of the existing comments, can you please review?

Add get_transceiver_pm API interface
@longhuan-cisco longhuan-cisco changed the title Add get_transceiver_status to API interface Add get_transceiver_status and get_transceiver_pm to API interface Nov 8, 2022
@longhuan-cisco
Copy link
Contributor Author

longhuan-cisco commented Nov 8, 2022

Added pm table related change, to use this PR to track changes for both status and pm.
@prgeor @mihirpat1 Could you please take another look?

trans_status['rxsigpowerlowalarm_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][6]
trans_status['rxsigpowerhighwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][7]
trans_status['rxsigpowerlowwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][8]
except KeyError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longhuan-cisco how do we know if there is a key error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a debug log here in the case of key error.

@@ -133,6 +133,23 @@ def get_transceiver_threshold_info(self):
"""
raise NotImplementedError

def get_transceiver_status(self):
"""
Retrieves transceiver status of this SFP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you provide more details in the API description what does status mean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, added.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have an existing API "get_transceiver_bulk_status", should we consider combining the new function with this existing one? Otherwise, I would suggest reconsidering the name of the new API for differentiation.


def get_transceiver_pm(self):
"""
Retrieves PM for this xcvr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add more details in this API what does PM mean and where its applicable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, added.

@prgeor prgeor self-assigned this Nov 22, 2022
@prgeor prgeor added the CMIS label Nov 22, 2022
@prgeor prgeor requested a review from keboliu November 22, 2022 02:35
mihirpat1
mihirpat1 previously approved these changes Nov 22, 2022
@lgtm-com
Copy link

lgtm-com bot commented Nov 23, 2022

This pull request introduces 1 alert when merging 5261da7 into ce9aacb - view on LGTM.com

new alerts:

  • 1 for Unnecessary pass

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

trans_status['rxsigpowerhighwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][7]
trans_status['rxsigpowerlowwarning_flag'] = self.vdm_dict['Rx Signal Power [dBm]'][1][8]
except KeyError:
helper_logger.log_debug('Rx Signal Power [dBm] not present in VDM')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the 'debug' level log print out in the running time?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print more generic key error that can print any Key error name?

cfo_avg = FLOAT ; carrier frequency offset avg
cfo_min = FLOAT ; carrier frequency offset min
cfo_max = FLOAT ; carrier frequency offset max
soproc_avg = FLOAT ; state of polarization rate of change avg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longhuan-cisco 'evm_min/avg/max' is missing

@prgeor prgeor merged commit 8f2dffb into sonic-net:master Dec 6, 2022
keboliu pushed a commit to keboliu/sonic-platform-common that referenced this pull request Jan 12, 2023
…onic-net#315)

* Add get_transceiver_status to API interface

* Add test_ccmis support

* Add get_transceiver_pm API interface

* Add debug log and more description for interface

* Remove unnecessary pass
@keboliu
Copy link
Collaborator

keboliu commented Jan 17, 2023

PR sonic-net/sonic-platform-daemons#304 has a dependency on this PR, it has already been included in 202211, this PR shall also be cherry-picked to 202211, otherwise, 202211 will be broken. @prgeor @longhuan-cisco @StormLiangMS

yxieca pushed a commit that referenced this pull request Jan 19, 2023
)

* Add get_transceiver_status to API interface

* Add test_ccmis support

* Add get_transceiver_pm API interface

* Add debug log and more description for interface

* Remove unnecessary pass
StormLiangMS pushed a commit that referenced this pull request Jan 23, 2023
)

* Add get_transceiver_status to API interface

* Add test_ccmis support

* Add get_transceiver_pm API interface

* Add debug log and more description for interface

* Remove unnecessary pass
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-platform-common that referenced this pull request Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants