-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add support to set PSU fan speed #10
Changes from 6 commits
27fdea4
f61a363
b285bc8
de6ca46
c16bb1d
ab9132f
af951c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from sonic_platform_base.sonic_thermal_control.thermal_action_base import ThermalPolicyActionBase | ||
from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object | ||
from .thermal import logger | ||
|
||
|
||
class SetFanSpeedAction(ThermalPolicyActionBase): | ||
|
@@ -52,6 +53,21 @@ def execute(self, thermal_info_dict): | |
fan_info_obj = thermal_info_dict[FanInfo.INFO_NAME] | ||
for fan in fan_info_obj.get_presence_fans(): | ||
fan.set_speed(self.speed) | ||
logger.log_info('Set all system FAN speed to {}'.format(self.speed)) | ||
|
||
SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, self.speed) | ||
|
||
@classmethod | ||
def set_psu_fan_speed(cls, thermal_info_dict, speed): | ||
from .thermal_infos import ChassisInfo | ||
if ChassisInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[ChassisInfo.INFO_NAME], ChassisInfo): | ||
chassis = thermal_info_dict[ChassisInfo.INFO_NAME].get_chassis() | ||
for psu in chassis.get_all_psus(): | ||
for psu_fan in psu.get_all_fans(): | ||
psu_fan.set_speed(speed) | ||
|
||
logger.log_info('Updated PSU FAN speed to {}%'.format(speed)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the fan speed here percentage or RPM? if PRM shouldn't have a '%'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is percentage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we don't konw the max speed of PSU fan? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't know the max speed, but we have a vector which contains 11 values, so if cooling level is 5, we use the 6th element to set the PSU FAN speed. |
||
|
||
|
||
|
||
@thermal_json_object('fan.all.check_and_set_speed') | ||
|
@@ -121,10 +137,18 @@ def execute(self, thermal_info_dict): | |
# save power | ||
if Thermal.check_thermal_zone_temperature(): | ||
fan_info_obj = thermal_info_dict[FanInfo.INFO_NAME] | ||
update_psu_fan_speed = False | ||
speed = Fan.min_cooling_level * 10 | ||
for fan in fan_info_obj.get_presence_fans(): | ||
if fan.get_target_speed() != 100: | ||
break | ||
fan.set_speed(Fan.min_cooling_level * 10) | ||
update_psu_fan_speed = True | ||
fan.set_speed(speed) | ||
|
||
if update_psu_fan_speed: | ||
SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, speed) | ||
|
||
logger.log_info('Changed thermal algorithm status to {}'.format(self.status)) | ||
|
||
|
||
class ChangeMinCoolingLevelAction(ThermalPolicyActionBase): | ||
|
@@ -146,12 +170,21 @@ def execute(self, thermal_info_dict): | |
|
||
for key, cooling_level in minimum_table.items(): | ||
temp_range = key.split(':') | ||
temp_min = int(temp_range[0]) * 1000 | ||
temp_max = int(temp_range[1]) * 1000 | ||
temp_min = int(temp_range[0]) | ||
temp_max = int(temp_range[1]) | ||
if temp_min <= temperature <= temp_max: | ||
Fan.min_cooling_level = cooling_level - 10 | ||
break | ||
|
||
current_cooling_level = Fan.get_cooling_level() | ||
if current_cooling_level < Fan.min_cooling_level: | ||
Fan.set_cooling_level(Fan.min_cooling_level) | ||
SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, Fan.min_cooling_level * 10) | ||
|
||
logger.log_info('Changed minimum cooling level to {}'.format(Fan.min_cooling_level)) | ||
|
||
|
||
class UpdatePsuFanSpeedAction(ThermalPolicyActionBase): | ||
def execute(self, thermal_info_dict): | ||
from .thermal_conditions import CoolingLevelChangeCondition | ||
SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, CoolingLevelChangeCondition.cooling_level * 10) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -486,7 +486,7 @@ def test_dynamic_minimum_policy(thermal_manager): | |
assert condition.is_match(None) | ||
assert MinCoolingLevelChangeCondition.trust_state == 'trust' | ||
assert MinCoolingLevelChangeCondition.air_flow_dir == 'p2c' | ||
assert MinCoolingLevelChangeCondition.temperature == 35000 | ||
assert MinCoolingLevelChangeCondition.temperature == 35 | ||
assert not condition.is_match(None) | ||
|
||
Thermal.check_module_temperature_trustable = MagicMock(return_value='untrust') | ||
|
@@ -499,7 +499,7 @@ def test_dynamic_minimum_policy(thermal_manager): | |
|
||
Thermal.get_air_flow_direction = MagicMock(return_value=('c2p', 25000)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why here the temperature not changed from "25000" to "25"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it wiil divide by 1000 in the condition.is_match |
||
assert condition.is_match(None) | ||
assert MinCoolingLevelChangeCondition.temperature == 25000 | ||
assert MinCoolingLevelChangeCondition.temperature == 25 | ||
|
||
chassis = MockChassis() | ||
chassis.sku_name = 'invalid' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to consider the failure case of executing this command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we can catch exception and retry. What's your suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use subprocess.check_call and check the return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure