ipmi-auto icon indicating copy to clipboard operation
ipmi-auto copied to clipboard

重构IPMI风扇控制工具 添加配置化管理和跨平台支持

Open Stallion-X opened this issue 5 months ago • 1 comments

重构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() to subprocess.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:

  1. Copy config.example.jsonconfig.json with real server details
  2. Run python main.py --test to verify connectivity and temperature reading
  3. Test fan curve mode with multiple temperature readings to verify interpolation
  4. Test traditional threshold mode for backward compatibility
  5. 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.json before 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 .gitignore to prevent accidental commit of IPMI credentials
  • Backward Compatibility: Core IPMI commands unchanged, but execution method switched from os.popen() to subprocess.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.

Stallion-X avatar Jul 15 '25 20:07 Stallion-X

哈喽

Stallion-X avatar Jul 15 '25 20:07 Stallion-X