ipmi-auto
ipmi-auto copied to clipboard
重构IPMI风扇控制工具 添加配置化管理和跨平台支持
重构IPMI风扇控制工具 添加配置化管理和跨平台支持
Summary
This PR completely transforms the IPMI fan control script from a basic procedural approach to a professional, configurable tool with smooth fan curve functionality. The changes address all major issues in the original codebase:
🔧 Core Infrastructure:
- Fixed corrupted
requirements.txt(was binary encoded, now clean) - Complete architectural refactor from procedural script to class-based
IPMIFanController - JSON configuration system replaces all hardcoded server credentials and temperature policies
- Cross-platform support with automatic Windows/Linux detection for ipmitool paths
🎮 Smart Fan Control:
- Fan curve functionality with linear interpolation between temperature points (like gaming laptops)
- Backward compatible threshold-based mode for traditional step-wise control
- Configurable temperature policies with detailed validation
🛡️ Reliability & Monitoring:
- Comprehensive error handling with configurable retry logic and timeouts
- Professional logging system (file + console) replacing simple print statements
- Command-line interface with test mode and custom config paths
- Security improvements with .gitignore for sensitive credentials
Review & Testing Checklist for Human
⚠️ CRITICAL - Hardware Testing Required (Risk: HIGH)
- [ ] End-to-end testing with actual Dell server - Verify temperature reading and fan speed adjustment work correctly with real IPMI connection
- [ ] Fan curve interpolation accuracy - Test that temperature values between curve points produce mathematically correct fan speeds (e.g., 47.5°C between 30°C→5% and 65°C→35% should yield ~20%)
- [ ] IPMI command compatibility - Verify that switching from
os.popen()tosubprocess.run()doesn't break the core raw IPMI commands (0x30 0x30 0x01 0x00, etc.) - [ ] Configuration validation - Test with invalid/missing config.json to ensure proper error messages
- [ ] Cross-platform functionality - Test on both Windows (bundled ipmitool.exe) and Linux (system ipmitool)
Recommended Test Sequence:
- Copy
config.example.json→config.jsonwith real server details - Run
python main.py --testto verify connectivity and temperature reading - Test fan curve mode with multiple temperature readings to verify interpolation
- Test traditional threshold mode for backward compatibility
- Simulate network failures to test retry logic and error handling
Diagram
%%{ init : { "theme" : "default" }}%%
graph TD
main["main.py<br/>(Entry Point)<br/>IPMIFanController"]:::major-edit
config_py["config.py<br/>(Config Management)"]:::major-edit
config_example["config.example.json<br/>(Sample Config)"]:::major-edit
config_user["config.json<br/>(User Config)"]:::context
requirements["requirements.txt<br/>(Fixed Dependencies)"]:::major-edit
readme["README.md<br/>(Documentation)"]:::major-edit
gitignore[".gitignore<br/>(Security)"]:::minor-edit
ipmi_tools["ipmi/<br/>(ipmitool binaries)"]:::context
main -->|"loads config"| config_py
config_py -->|"reads"| config_user
config_example -.->|"template for"| config_user
main -->|"executes"| ipmi_tools
main -->|"fan curve<br/>interpolation"| main
subgraph Legend
L1["Major Edit"]:::major-edit
L2["Minor Edit"]:::minor-edit
L3["Context/No Edit"]:::context
end
classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Notes
- Session Info: Requested by William Wu (@Stallion-X) - Devin Session
- Breaking Changes: Users must create
config.jsonbefore the tool can run (no more hardcoded values) - Fan Curve Algorithm: Uses linear interpolation:
speed = point1_speed + (speed_range × temp_offset / temp_range) - Security: Added
.gitignoreto prevent accidental commit of IPMI credentials - Backward Compatibility: Core IPMI commands unchanged, but execution method switched from
os.popen()tosubprocess.run()
⚠️ Critical Limitation: This refactor cannot be fully validated without Dell server hardware access. The mathematical interpolation and configuration loading work correctly in isolation, but the core IPMI functionality requires real-world testing to ensure reliability.
哈喽