Skip to content

Commit bd694b2

Browse files
Load interval from thermal_policy.json (#178)
Description Update ThermalManagerBase to load an interval field from thermal_policy.json if it is available and provide a getter for this interval. Motivation and Context This interval can be used by thermalctld to run policies at an interval specified in thermal_policy.json, rather than a fixed constant (currently 60 seconds). How Has This Been Tested? Verified that thermalctld runs without exiting. Also ran test_thermalctld.py
1 parent c43dc17 commit bd694b2

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

sonic_platform_base/sonic_thermal_control/thermal_manager_base.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ThermalManagerBase(object):
1414
JSON_FIELD_THERMAL_ALGORITHM = "thermal_control_algorithm"
1515
JSON_FIELD_FAN_SPEED_WHEN_SUSPEND = "fan_speed_when_suspend"
1616
JSON_FIELD_RUN_AT_BOOT_UP = "run_at_boot_up"
17+
JSON_FIELD_INTERVAL = "interval"
1718

1819
# Dictionary of ThermalPolicy objects.
1920
_policy_dict = {}
@@ -25,6 +26,8 @@ class ThermalManagerBase(object):
2526

2627
_run_thermal_algorithm_at_boot_up = None
2728

29+
_interval = 60
30+
2831
_running = True
2932

3033
@classmethod
@@ -118,7 +121,8 @@ def load(cls, policy_file_name):
118121
}
119122
]
120123
}
121-
]
124+
],
125+
"interval": "30",
122126
}
123127
:param policy_file_name: Path of JSON policy file.
124128
:return:
@@ -147,6 +151,10 @@ def load(cls, policy_file_name):
147151
cls._fan_speed_when_suspend = \
148152
int(json_thermal_algorithm_config[cls.JSON_FIELD_FAN_SPEED_WHEN_SUSPEND])
149153

154+
if cls.JSON_FIELD_INTERVAL in json_obj:
155+
cls._interval = int(json_obj[cls.JSON_FIELD_INTERVAL])
156+
157+
150158
@classmethod
151159
def _load_policy(cls, json_policy):
152160
"""
@@ -215,3 +223,10 @@ def init_thermal_algorithm(cls, chassis):
215223
for psu in chassis.get_all_psus():
216224
for fan in psu.get_all_fans():
217225
fan.set_speed(cls._fan_speed_when_suspend)
226+
227+
@classmethod
228+
def get_interval(cls):
229+
"""
230+
Get the wait interval for executing thermal policies
231+
"""
232+
return cls._interval

0 commit comments

Comments
 (0)