-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[device/celestica]: Add thermalctld support on DX010 platform APIs (#…
…6089) **- Why I did it** - The thermalctld daemon on the Pmon docker requires support from the thermal manager API. **- How I did it** - Removed the old function for detecting a faulty fan. - Removed the old function for detecting excess temperature. - Implement thermal_manager APIs based on ThermalManagerBase - Implement thermal_conditions APIs based on ThermalPolicyConditionBase - Implement thermal_actions APIs based on ThermalPolicyActionBase - Implement thermal_info APIs based on ThermalPolicyInfoBase - Add thermal_policy.json
- Loading branch information
Showing
16 changed files
with
647 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_actions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
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_infos import ChassisInfo | ||
from .helper import APIHelper | ||
|
||
|
||
@thermal_json_object('thermal_control.control') | ||
class ControlThermalAlgoAction(ThermalPolicyActionBase): | ||
""" | ||
Action to control the thermal control algorithm | ||
""" | ||
# JSON field definition | ||
JSON_FIELD_STATUS = 'status' | ||
|
||
def __init__(self): | ||
self.status = True | ||
|
||
def load_from_json(self, json_obj): | ||
""" | ||
Construct ControlThermalAlgoAction via JSON. JSON example: | ||
{ | ||
"type": "thermal_control.control" | ||
"status": "true" | ||
} | ||
:param json_obj: A JSON object representing a ControlThermalAlgoAction action. | ||
:return: | ||
""" | ||
if ControlThermalAlgoAction.JSON_FIELD_STATUS in json_obj: | ||
status_str = json_obj[ControlThermalAlgoAction.JSON_FIELD_STATUS].lower() | ||
if status_str == 'true': | ||
self.status = True | ||
elif status_str == 'false': | ||
self.status = False | ||
else: | ||
raise ValueError('Invalid {} field value, please specify true of false'. | ||
format(ControlThermalAlgoAction.JSON_FIELD_STATUS)) | ||
else: | ||
raise ValueError('ControlThermalAlgoAction ' | ||
'missing mandatory field {} in JSON policy file'. | ||
format(ControlThermalAlgoAction.JSON_FIELD_STATUS)) | ||
|
||
def execute(self, thermal_info_dict): | ||
""" | ||
Disable thermal control algorithm | ||
:param thermal_info_dict: A dictionary stores all thermal information. | ||
:return: | ||
""" | ||
if ChassisInfo.INFO_NAME in thermal_info_dict: | ||
chassis_info_obj = thermal_info_dict[ChassisInfo.INFO_NAME] | ||
chassis = chassis_info_obj.get_chassis() | ||
thermal_manager = chassis.get_thermal_manager() | ||
if self.status: | ||
thermal_manager.start_thermal_control_algorithm() | ||
else: | ||
thermal_manager.stop_thermal_control_algorithm() | ||
|
||
|
||
@thermal_json_object('switch.power_cycling') | ||
class SwitchPolicyAction(ThermalPolicyActionBase): | ||
""" | ||
Base class for thermal action. Once all thermal conditions in a thermal policy are matched, | ||
all predefined thermal action will be executed. | ||
""" | ||
|
||
def execute(self, thermal_info_dict): | ||
""" | ||
Take action when thermal condition matches. For example, power cycle the switch. | ||
:param thermal_info_dict: A dictionary stores all thermal information. | ||
:return: | ||
""" | ||
thermal_overload_position_path = '/tmp/thermal_overload_position' | ||
thermal_overload_position = APIHelper().read_one_line_file( | ||
thermal_overload_position_path) | ||
|
||
cmd = 'bash /usr/share/sonic/platform/thermal_overload_control.sh {}'.format( | ||
thermal_overload_position) | ||
APIHelper().run_command(cmd) |
Oops, something went wrong.