Skip to main content

Redfish Python SDK

PyPI version Python versions License

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 managerwith statement support for automatic connection cleanup
  • Minimal dependencies — only requests, pydantic, and urllib3

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.0.0
pip install git+https://github.com/rednote-infra/redfish-python-sdk.git@v1.0.0

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

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redfish_python_sdk-1.1.0.tar.gz (104.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redfish_python_sdk-1.1.0-py3-none-any.whl (91.3 kB view details)

Uploaded Python 3

File details

Details for the file redfish_python_sdk-1.1.0.tar.gz.

File metadata

  • Download URL: redfish_python_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 104.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for redfish_python_sdk-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fcb49e95e376f6ab5e0e561ea4a852189b235ab22758b612d82a44884c48c95c
MD5 957f74e468fe0f416c74f14b5624f6c2
BLAKE2b-256 3419c4ff59af4613319b29f68928c4c30a765c78264a68a5dd2b8de768a27275

See more details on using hashes here.

File details

Details for the file redfish_python_sdk-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for redfish_python_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 461f0cc5904b11ddca1c72ba174ae9f32b124def9af0f1f8250a35882e2cfcd3
MD5 2ab05adeb8b04f3e181c4f748ea4a4c9
BLAKE2b-256 871b8b8a14faae4574c6913d31bea34d09d4ad50cf48cbd42a508f8a5b0f780d

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.0

2 files

This release

1.1.0 This release

2 files

1.0.0

2 files

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