Python IPMI Library

0.5.8 · active · verified Thu Apr 16

The `python-ipmi` library provides a pure Python API for interacting with devices via the Intelligent Platform Management Interface (IPMI) protocol. It supports IPMI version 2.0 and offers multiple communication interfaces, including native RMCP (IPMI over LAN), legacy RMCP (requiring the external `ipmitool`), IPMB (requiring a Total Phase Aardvark or Linux `ipmb-dev` driver), and a mock interface for testing. The current version is 0.5.8, released in December 2025, and it actively supports Python > 3.6, with Python 2.x deprecated.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish an IPMI session using the native RMCP interface and retrieve the device ID. It relies on environment variables for sensitive connection details.

import os
import pyipmi
import pyipmi.interfaces

# Environment variables for IPMI connection details
IPMI_HOST = os.environ.get('IPMI_HOST', '192.168.1.100')
IPMI_USER = os.environ.get('IPMI_USER', 'admin')
IPMI_PASSWORD = os.environ.get('IPMI_PASSWORD', 'password')

interface = None
connection = None
try:
    # Using the native RMCP interface (IPMI over LAN)
    interface = pyipmi.interfaces.create_interface('rmcp')
    
    connection = pyipmi.create_connection(interface)
    connection.target = pyipmi.Target(IPMI_HOST)
    connection.session.set_session_type_rmcp(username=IPMI_USER, password=IPMI_PASSWORD)
    
    print(f"Attempting to establish session to {IPMI_HOST}...")
    connection.session.establish()
    print("Session established successfully.")

    # Get Device ID command
    device_id_response = connection.get_device_id()
    print(f"Device ID: {device_id_response.device_id_string}")
    print(f"Manufacturer ID: {hex(device_id_response.manufacturer_id)}")
    print(f"Product ID: {hex(device_id_response.product_id)}")
    print(f"Firmware Revision: {device_id_response.firmware_revision.major}.{device_id_response.firmware_revision.minor}")

except pyipmi.errors.IpmiError as e:
    print(f"IPMI Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
finally:
    if connection:
        try:
            connection.session.close()
            print("Session closed.")
        except Exception as e:
            print(f"Error closing session: {e}")

view raw JSON →