Skip to content

[CMIS] Catch Exception to avoid CMIS code crash #299

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

Merged
merged 2 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ def get_transceiver_bulk_status(self):
bulk_status["tx%dpower" % i] = self.mw_to_dbm(tx_power[i - 1]) if self.get_tx_power_support() else 'N/A'

laser_temp_dict = self.get_laser_temperature()
bulk_status['laser_temperature'] = laser_temp_dict['monitor value']
self.vdm_dict = self.get_vdm()
try:
bulk_status['laser_temperature'] = laser_temp_dict['monitor value']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure I understand, I moved bulk_status['laser_temperature'] = laser_temp_dict['monitor value'] to try section to avoid the case that laser_temp_dict is none

bulk_status['prefec_ber'] = self.vdm_dict['Pre-FEC BER Average Media Input'][1][0]
bulk_status['postfec_ber'] = self.vdm_dict['Errored Frames Average Media Input'][1][0]
except (KeyError, TypeError):
Expand Down Expand Up @@ -1856,7 +1856,11 @@ def get_application_advertisement(self):

if not self.is_flat_memory():
# Read the application advertisement in page01
dic.update(self.xcvr_eeprom.read(consts.APPLS_ADVT_FIELD_PAGE01))
try:
dic.update(self.xcvr_eeprom.read(consts.APPLS_ADVT_FIELD_PAGE01))
except TypeError as e:
logger.error('Failed to read APPLS_ADVT_FIELD_PAGE01: ' + str(e))
return ret

for app in range(1, 16):
buf = {}
Expand Down
4 changes: 3 additions & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmisVDM.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def get_vdm_page(self, page, VDM_flag_page):
if page not in [0x20, 0x21, 0x22, 0x23]:
raise ValueError('Page not in VDM Descriptor range!')
vdm_descriptor = self.xcvr_eeprom.read_raw(page * PAGE_SIZE + PAGE_OFFSET, PAGE_SIZE)

if not vdm_descriptor:
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are other eeprom read in this function. can you take care of them also?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

return {}

# Odd Adress VDM observable type ID, real-time monitored value in Page + 4
vdm_typeID = vdm_descriptor[1::2]
# Even Address
Expand Down