Skip to main content

redfish-python-sdk

redfish-python-sdk is a typed, high-level Python SDK for managing multi-vendor BMCs and bare-metal servers through the DMTF Redfish API.

PyPI version Python versions License PyPI Downloads

English | 中文

A lightweight Python SDK for managing server BMCs (Baseboard Management Controllers) via the DMTF Redfish protocol. Covers system inventory, hardware inspection, power control, boot management, event subscriptions, and more.

Features

  • Comprehensive hardware queries — CPU, memory, drives, GPU, NIC, PCIe, PSU, fans — one line of code each
  • Power & boot management — power on/off, restart, PXE/HDD/BIOS boot source switching
  • Multi-vendor compatible — auto-adapts to OEM extensions from Huawei, xFusion, Lenovo, HPE, Dell, and others
  • Pydantic v2 models — all return values are strongly-typed objects with full IDE autocompletion
  • Context manager — with statement support for automatic connection cleanup
  • Minimal dependencies — only requests, pydantic, and urllib3

Use DMTF standard fields first. In particular, xFusion's PCIe DeviceBDF field is OEM-only; portable code should use PCIeFunctions and only consume the OEM field when the xFusion contract applies.

Requirements

  • Python >= 3.9
  • A network-reachable Redfish-compliant BMC endpoint

Installation

# Install from PyPI
pip install redfish-python-sdk

# Or install from GitHub
pip install git+https://github.com/rednote-infra/redfish-python-sdk.git

# Install a specific version
pip install redfish-python-sdk==1.2.3
pip install git+https://github.com/rednote-infra/redfish-python-sdk.git@v1.2.3

# In requirements.txt
# redfish-python-sdk>=1.2.3

Quick Start

Credential management: All BMC credentials should be injected via environment variables. Never hardcode them in your source code. Before running examples or tests, set export BMC_IP=..., export BMC_USER=..., export BMC_PASSWORD=....

import os
from redfish_sdk import RedfishClient

# Connect to BMC (credentials from environment variables)
client = RedfishClient(
    host=os.environ["BMC_IP"],
    username=os.environ["BMC_USER"],
    password=os.environ["BMC_PASSWORD"],
)

# Get system info
system = client.systems.get()
print(f"Server: {system.manufacturer} {system.model}")
print(f"SN:     {system.serial_number}")
print(f"Power:  {system.power_state}")

# Get CPU info
for cpu in client.get_processors():
    print(f"CPU: {cpu.model}, {cpu.total_cores} cores / {cpu.total_threads} threads")

# Get memory info
for mem in client.get_memory():
    print(f"DIMM: {mem.manufacturer} {(mem.capacity_mib or 0) // 1024} GB")

# Get drive info
for drive in client.get_drives():
    print(f"Drive: {drive.model} {(drive.capacity_bytes or 0) / 1e12:.1f} TB")

# Don't forget to close
client.close()

Testing

# Run unit tests (no BMC or env vars required)
pytest tests/test_models_mock.py tests/test_client_mock.py -v

# Run offline tests (using pre-collected JSON data)
export REDFISH_JSON_DIR="./testdata"
pytest tests/test_offline_json.py -v

# Run integration tests (requires a real BMC)
export BMC_IP="<your-bmc-ip>"
export BMC_USER="<your-bmc-user>"
export BMC_PASSWORD="<your-bmc-password>"
pytest tests/test_real_bmc.py -v

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the BSD 3-Clause License.

Metadata

Release files for redfish-python-sdk 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redfish-python-sdk 1.3.1
File Size Uploaded Provenance Actions
redfish_python_sdk-1.3.1.tar.gz 189.2 kB Without provenance Details for redfish_python_sdk-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redfish-python-sdk 1.3.1
File Interpreter ABI Platform Actions
redfish_python_sdk-1.3.1-py3-none-any.whl Python 3 none any Details for redfish_python_sdk-1.3.1-py3-none-any.whl

Total release size: 351.7 kB

Release files / redfish_python_sdk-1.3.1.tar.gz

Download URL redfish_python_sdk-1.3.1.tar.gz
Size 189.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ac486ebe3a0edb903af55b71191480e773ec04f9d1c660ee8f549138e6df7363
BLAKE2b-256 checksum
How to use checksums
6b55db1bf53ce6cb7a63d9b875f9053481b346e330fc7ef124fa84809e9e8721
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / redfish_python_sdk-1.3.1-py3-none-any.whl

Download URL redfish_python_sdk-1.3.1-py3-none-any.whl
Size 162.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f87bd1e9416089aed2a08563b1c726fe8815b9a1771f81a9cbe8d9427f48900f
BLAKE2b-256 checksum
How to use checksums
89fca947650f6f11b51252a644f7dbdb123254a566152dbb2df363e3d5f96bb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for redfish-python-sdk 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page