This project serves as an API gateway for ipmitool to access Supermicro servers' IPMI, designed to be called by Home Assistant. It provides a simple interface to manage server operations such as starting, stopping, and checking the health of the servers.
π€ Full disclosure: Claude Sonnet 4 wrote all of the Python code. And this readme. Had I done it, there would be a lot more swearing. Swearing is funny, but not always.
- Single & Multi-Server Support - Manage one or multiple IPMI devices
- Power Management - Power on/off/reset servers with graceful and forced options
- System Monitoring - Get sensor readings, system information, and event logs
- Boot Management - Control boot device selection (PXE, disk, CDROM, etc.)
- Bulk Operations - Execute commands across multiple servers simultaneously
- Docker & Kubernetes Ready - Easy deployment with container orchestration
ipmi-api-gateway
βββ src
β βββ app.py # Entry point of the application
β βββ controllers # Contains API request handlers
β β βββ __init__.py
β β βββ ipmi_controller.py # Handles IPMI related API requests
β βββ services # Contains business logic
β β βββ __init__.py
β β βββ ipmi_service.py # Interacts with ipmitool
β βββ utils # Utility functions and validators
β βββ __init__.py
β βββ validators.py # Validates input data for API requests
βββ docker
β βββ Dockerfile # Docker image build instructions
βββ k8s
β βββ deployment.yaml # Kubernetes deployment configuration
β βββ service.yaml # Kubernetes service configuration
β βββ configmap.yaml # ConfigMap for application configuration
βββ requirements.txt # Python dependencies
βββ docker-compose.yml # Docker application configuration
βββ CONFIGURATION.md # Detailed configuration guide
βββ README.md # Project documentation
-
Clone the repository:
git clone https://github.com/JamesDodds/ipmi-api-gateway.git cd ipmi-api-gateway -
Configure IPMI credentials in
docker-compose.yml:environment: - FLASK_ENV=development - IPMI_HOST=192.168.1.xxx # Your IPMI device IP - IPMI_USER=your_username # Your IPMI username - IPMI_PASSWORD=your_password # Your IPMI password
-
Build and run:
docker build -f docker/Dockerfile -t ipmi-api-gateway . docker-compose up -
Test the API:
Invoke-RestMethod -Uri "http://localhost:5000/health" -Method GET
π See CONFIGURATION.md for detailed setup instructions, including:
- Single server setup
- Multi-server configurations
- Kubernetes deployment
- Security considerations
- Troubleshooting guide
GET /health- API service health checkGET /api/v1/health- IPMI connection health checkGET /api/v1/servers- List all configured serversGET /api/v1/docs- Detailed API documentation
GET /api/v1/power/status- Get current power statusPOST /api/v1/power/on- Power on the serverPOST /api/v1/power/off- Power off server (supportsforceparameter)POST /api/v1/power/reset- Reset the server
GET /api/v1/system/info- Get comprehensive system informationGET /api/v1/system/sensors- Get all sensor readings (temperature, voltage, fans)GET /api/v1/system/events- Get system event logDELETE /api/v1/system/events- Clear system event log
GET /api/v1/boot/device- Get current boot devicePOST /api/v1/boot/device- Set boot device (PXE, disk, CDROM, BIOS, etc.)
GET /api/v1/servers/status- Get power status of all serversPOST /api/v1/bulk/power/on- Power on all serversPOST /api/v1/bulk/power/off- Power off all serversGET /api/v1/bulk/sensors- Get sensor data from all servers
# Check power status
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/power/status" -Method GET
# Power on server
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/power/on" -Method POST
# Forced power off
$body = @{ force = $true } | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/power/off" -Method POST -Body $body -ContentType "application/json"
# Power on with 45-second countdown
1..45 | ForEach-Object { Write-Host "Powering on in $($_) seconds..." -NoNewline; Start-Sleep 1; Write-Host "`r" -NoNewline }; Write-Host "Sending power on command..."; Invoke-RestMethod -Uri "http://localhost:5000/api/v1/power/on" -Method POST# Get sensor readings
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/system/sensors" -Method GET
# Get system information
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/system/info" -Method GET
# Get recent events
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/system/events?limit=10" -Method GET# Set PXE boot for next boot
$body = @{ device = "pxe"; persistent = $false } | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/boot/device" -Method POST -Body $body -ContentType "application/json"# List all servers
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/servers" -Method GET
# Get status of all servers
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/servers/status" -Method GET
# Target specific server
Invoke-RestMethod -Uri "http://localhost:5000/api/v1/power/status?server_id=server1" -Method GET# configuration.yaml
rest_command:
server_power_on:
url: "http://your-api-host:5000/api/v1/power/on"
method: POST
server_power_off:
url: "http://your-api-host:5000/api/v1/power/off"
method: POST
payload: '{"force": true}'
content_type: 'application/json'
sensor:
- platform: rest
resource: "http://your-api-host:5000/api/v1/power/status"
name: "Server Power Status"
value_template: "{{ value_json.power_state }}"The API provides structured sensor data that can be easily integrated with monitoring systems for trending and alerting.
Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.
This project is built on top of several excellent open-source tools:
- ipmitool - The foundational IPMI utility that makes all server management operations possible. This project would not exist without the incredible work of the ipmitool maintainers and contributors.
- Flask - The lightweight web framework powering the API
- Docker - For containerization and easy deployment
- Python - The language that ties it all together
Special thanks to the broader IPMI and open-source server management community for building and maintaining the tools that enable projects like this.
This project is licensed under the MIT License. See the LICENSE file for details.
Note: This project is a wrapper around existing tools and does not include any IPMI implementation itself. All IPMI functionality is provided by the excellent ipmitool utility.