Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
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
3 changes: 3 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ def get_presence(self):
Returns:
bool: True if device is present, False if not
"""
presence_sysfs = f'/sys/module/sx_core/asic0/module{self.sdk_index}/hw_present' if self.is_sw_control() else f'/sys/module/sx_core/asic0/module{self.sdk_index}/present'
if utils.read_int_from_file(presence_sysfs) != 1:
return False
eeprom_raw = self._read_eeprom(0, 1, log_on_error=False)
return eeprom_raw is not None

Expand Down
6 changes: 6 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def get_temperature(self):
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
if not self.sfp.get_presence():
return None
value = self.sfp.get_temperature()
return value if (value != 0.0 and value is not None) else None

Expand All @@ -446,6 +448,8 @@ def get_high_threshold(self):
A float number, the high threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if not self.sfp.get_presence():
return None
value = self.sfp.get_temperature_warning_threshold()
return value if (value != 0.0 and value is not None) else None

Expand All @@ -457,6 +461,8 @@ def get_high_critical_threshold(self):
A float number, the high critical threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if not self.sfp.get_presence():
return None
value = self.sfp.get_temperature_critical_threshold()
return value if (value != 0.0 and value is not None) else None

Expand Down