Skip to content

Commit 2d1db1d

Browse files
[Mellanox] Fix the issue with sensors with discrete indexes initialization. (#21856)
- Why I did it Fix the issue with the position calculation of the sensors with discrete indexes. - How I did it Pass the base position into create_discrete_thermal function instead of initializing the position with 1. - How to verify it Run snmp/test_snmp_phy_entity.py sonic-mgmt test on the platform with discrete sensors.
1 parent 7f1f300 commit 2d1db1d

File tree

1 file changed

+5
-3
lines changed
  • platform/mellanox/mlnx-platform-api/sonic_platform

1 file changed

+5
-3
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def initialize_chassis_thermals():
173173
thermal_list.append(create_indexable_thermal(rule, index, CHASSIS_THERMAL_SYSFS_FOLDER, position))
174174
position += 1
175175
elif thermal_type == 'discrete':
176-
thermal_list.extend(create_discrete_thermal(rule))
176+
discrete_thermals = create_discrete_thermal(rule, position)
177+
if discrete_thermals:
178+
position += len(discrete_thermals)
179+
thermal_list.extend(discrete_thermals)
177180
else:
178181
thermal_object = create_single_thermal(rule, CHASSIS_THERMAL_SYSFS_FOLDER, position)
179182
if thermal_object:
@@ -280,10 +283,9 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
280283
return RemovableThermal(name, temp_file, high_th_file, high_crit_th_file, high_th_default, high_crit_th_default, scale, position, presence_cb)
281284

282285

283-
def create_discrete_thermal(rule):
286+
def create_discrete_thermal(rule, position):
284287
search_pattern = rule.get('search_pattern')
285288
index_pattern = rule.get('index_pattern')
286-
position = 1
287289
thermal_list = []
288290
for file_path in glob.iglob(search_pattern):
289291
file_name = os.path.basename(file_path)

0 commit comments

Comments
 (0)