Skip to content

Commit d8287d8

Browse files
authored
[Mellanox] Fix the issue with sensors with discrete indexes initialization (sonic-net#21890)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it Fix the issue with the position calculation of the sensors with discrete indexes. ##### Work item tracking - Microsoft ADO **(number only)**: #### 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. <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
1 parent f3dd569 commit d8287d8

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)