Adding thermal sensor controller changes - #219
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “thermal sensor controller” abstraction to RAFT, adding multiple backends (virtual vDevice control-plane, manual/hardware, programmable chamber, and smart-switch heater/blower control) plus documentation describing how to configure and use them.
Changes:
- Added
ThermalSensorControllerfactory + a common controller interface. - Added controller implementations: virtual (YAML over
/api/postKVP), manual/hardware (operator prompts), programmable chamber (command templates, optional SSH), and smart-switch heater control (viapowerControlClass). - Added docs describing supported YAML payloads and module usage/configuration.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/core/thermalSensorController.py | Factory that selects a controller implementation based on config/type. |
| framework/core/thermalSensorControllerModules/ThermalSensorControllerInterface.py | Abstract interface defining the controller API surface. |
| framework/core/thermalSensorControllerModules/virtualThermalSensorController.py | Virtual controller that posts YAML payloads to the vcomponent control plane. |
| framework/core/thermalSensorControllerModules/actualThermalSensorController.py | Manual/hardware controller that prompts an operator to trigger conditions. |
| framework/core/thermalSensorControllerModules/programmableThermalChamber.py | Chamber controller that executes configured command templates (optionally over SSH). |
| framework/core/thermalSensorControllerModules/smartSwitchThermalController.py | Smart-switch-based heater/blower controller built on powerControlClass. |
| docs/modules/thermalSensorControllerModules/virtual_commands.md | Documentation for virtual controller YAML payloads. |
| docs/modules/thermal_sensor_controller_modules.md | High-level module overview and rack-config usage guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import time | ||
|
|
||
| import yaml | ||
|
|
||
| from framework.core.thermalSensorControllerModules.ThermalSensorControllerInterface import ThermalSensorControllerInterface | ||
|
|
||
|
|
||
| class virtualThermalSensorController(ThermalSensorControllerInterface): | ||
| """ | ||
| Virtual ThermalSensor controller that sends YAML commands to the vcomponent | ||
| control-plane endpoint to simulate thermal events. | ||
| """ | ||
|
|
||
| def _sendCommand(self, payload: dict): | ||
| yaml_str = yaml.dump(payload) | ||
| yaml_str = yaml_str.replace('"', '\\"') | ||
| cmd = ( | ||
| f'curl -X POST -H "Content-Type: application/x-yaml" ' | ||
| f'--data-binary "{yaml_str}" ' | ||
| f'"http://localhost:{self.port}/api/postKVP"' | ||
| ) | ||
| self.session.write(cmd) |
| payload["IThermalSensor"]["sensorName"] = sensorName | ||
| payload["IThermalSensor"]["temperatureCelsius"] = temperatureCelsius | ||
|
|
||
| self._sendCommand(payload) |
| } | ||
| } | ||
|
|
||
| self._sendCommand(payload) |
| from raft.framework.plugins.ut_raft.utUserResponse import utUserResponse | ||
|
|
||
| from framework.core.commandModules.sshConsole import sshConsole | ||
| from framework.core.logModule import logModule | ||
| from framework.core.thermalSensorControllerModules.ThermalSensorControllerInterface import ThermalSensorControllerInterface | ||
|
|
| self.commandSession.write(command) | ||
| if self.stabilizationDelaySeconds > 0: | ||
| time.sleep(self.stabilizationDelaySeconds) | ||
| return True |
| prompt = controllerSettings.get("prompt", prompt) | ||
| port = controllerSettings.get( | ||
| "control_port", | ||
| controllerSettings.get("port", port), | ||
| ) | ||
| return controllerType, controllerSettings, prompt, port |
|
|
||
| ### Purpose | ||
|
|
||
| This command injects a raw temperature reading. The vcomponent evaluates per-sensor thresholds and automatically emits thermal state transitions. This is the supported control-plane command for thermal event simulation. |
| Thermal Sensor controller uses one YAML command payload: | ||
|
|
||
| - **Temperature Update (`temperature_update`)**: Threshold logic computes transitions automatically. | ||
|
|
||
| These definitions are used for thermal event simulation and validation in vDevice test flows. |
| control_port: 8081 | ||
| ``` | ||
|
|
||
| 2. **Initialization:** The helper class instantiates `ThermalSensorController` (factory in `thermalSensorController.py`), which resolves the correct implementation automatically. |
| def __new__(cls, controllerConfig, session, prompt: str = "~#", port: int = 8080): | ||
| controllerType, controllerSettings, prompt, port = cls._normaliseControllerConfig( | ||
| controllerConfig, prompt, port) | ||
| if controllerType in cls.VIRTUAL_CONTROLLER_TYPES: | ||
| return virtualThermalSensorController(session, prompt, port) |
|
@jfreeda - we need to have a meeting to design the layers here... Test specific calls, and vendor specific code is outside of scope for common core raft, which knows no platform, no methods, and isn't related to hals. Something akin to class hierarchy :- -> So raft should have an ability to POST Messages to a port, completely test and platform agnostic. |
Ulrond
left a comment
There was a problem hiding this comment.
let's move this to ut-raft, I think it makes more sense there.
No description provided.