Skip to content

Commit

Permalink
[Mellanox] Fix the issue with sensors with discrete indexes initializ…
Browse files Browse the repository at this point in the history
…ation. (#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.
  • Loading branch information
oleksandrivantsiv authored Feb 27, 2025
1 parent 7f1f300 commit 2d1db1d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ def initialize_chassis_thermals():
thermal_list.append(create_indexable_thermal(rule, index, CHASSIS_THERMAL_SYSFS_FOLDER, position))
position += 1
elif thermal_type == 'discrete':
thermal_list.extend(create_discrete_thermal(rule))
discrete_thermals = create_discrete_thermal(rule, position)
if discrete_thermals:
position += len(discrete_thermals)
thermal_list.extend(discrete_thermals)
else:
thermal_object = create_single_thermal(rule, CHASSIS_THERMAL_SYSFS_FOLDER, position)
if thermal_object:
Expand Down Expand Up @@ -280,10 +283,9 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
return RemovableThermal(name, temp_file, high_th_file, high_crit_th_file, high_th_default, high_crit_th_default, scale, position, presence_cb)


def create_discrete_thermal(rule):
def create_discrete_thermal(rule, position):
search_pattern = rule.get('search_pattern')
index_pattern = rule.get('index_pattern')
position = 1
thermal_list = []
for file_path in glob.iglob(search_pattern):
file_name = os.path.basename(file_path)
Expand Down

0 comments on commit 2d1db1d

Please sign in to comment.