Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load policy interval from thermal_policy.json #178

Merged
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ThermalManagerBase(object):
JSON_FIELD_THERMAL_ALGORITHM = "thermal_control_algorithm"
JSON_FIELD_FAN_SPEED_WHEN_SUSPEND = "fan_speed_when_suspend"
JSON_FIELD_RUN_AT_BOOT_UP = "run_at_boot_up"
JSON_FIELD_INTERVAL = "interval"

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

_run_thermal_algorithm_at_boot_up = None

_interval = 60

_running = True

@classmethod
Expand Down Expand Up @@ -118,7 +121,8 @@ def load(cls, policy_file_name):
}
]
}
]
],
"interval": "30",
}
:param policy_file_name: Path of JSON policy file.
:return:
Expand Down Expand Up @@ -147,6 +151,10 @@ def load(cls, policy_file_name):
cls._fan_speed_when_suspend = \
int(json_thermal_algorithm_config[cls.JSON_FIELD_FAN_SPEED_WHEN_SUSPEND])

if cls.JSON_FIELD_INTERVAL in json_obj:
cls._interval = int(json_obj[cls.JSON_FIELD_INTERVAL])


@classmethod
def _load_policy(cls, json_policy):
"""
Expand Down Expand Up @@ -215,3 +223,10 @@ def init_thermal_algorithm(cls, chassis):
for psu in chassis.get_all_psus():
for fan in psu.get_all_fans():
fan.set_speed(cls._fan_speed_when_suspend)

@classmethod
def get_interval(cls):
"""
Get the wait interval for executing thermal policies
"""
return cls._interval