Skip to main content

A lightweight, dynamic Python client for Redfish BMC APIs

Project description

rackfish - Dynamic Redfish Client

PyPI version Python Versions License: MIT Build Status codecov Code style: black

A lightweight, dynamic Python client for interacting with Redfish BMC (Baseboard Management Controller) APIs. Provides intuitive access to server hardware management through lazy-loaded object graphs, automatic OEM property surfacing, and validated action invocation.

๐ŸŽฏ Why rackfish?

  • ๐Ÿš€ Zero Dependencies (except requests) - Minimal footprint
  • โšก Lazy Loading - Resources fetched on-demand for performance
  • ๐ŸŽจ Pythonic Interface - JSON properties become Python attributes
  • ๐Ÿ”ง OEM Support - Vendor extensions (Huawei, Dell, HPE) automatically accessible
  • ๐Ÿ”— Smart Navigation - Related resources directly navigable via Links
  • โœ… Action Validation - Parameter validation using ActionInfo schemas
  • ๐Ÿ“š Collection Support - Iterate Redfish collections naturally
  • ๐Ÿ” Flexible Auth - Session tokens or Basic authentication

Features

  • Zero Dependencies (except requests) - Minimal footprint
  • Lazy Loading - Resources fetched on-demand for performance
  • Dynamic Attributes - JSON properties become Python attributes
  • OEM Surfacing - Vendor extensions automatically accessible
  • Links Surfacing - Related resources directly navigable
  • Action Validation - Parameter validation using ActionInfo schemas
  • Collection Support - Iterate Redfish collections naturally
  • Session & Basic Auth - Flexible authentication options

Installation

From PyPI (recommended)

pip install rackfish

From source

git clone https://github.com/thefrolov/rackfish.git
cd rackfish
pip install -e .

Development installation

pip install -e ".[dev]"

Quick Start

from rackfish import RedfishClient

# Connect to BMC
client = RedfishClient("https://bmc.example.com", "admin", "password", 
                       use_session=True, verify_ssl=False)
root = client.connect()

# Power control
system = next(iter(client.Systems))
system.Reset(ResetType="GracefulRestart")

# Access OEM properties (auto-surfaced)
if hasattr(system, "BootMode"):
    print(f"Boot Mode: {system.BootMode}")

# Navigate linked resources
for chassis in system.Chassis:
    print(f"Chassis: {chassis.Name}")

# Logout
client.logout()

Documentation

Common Use Cases

User Management

accounts = client.AccountService.Accounts
new_user = accounts.create({"UserName": "operator", "Password": "pass", "RoleId": "Operator"})
new_user.RoleId = "Administrator"
new_user.delete()

Storage Management

storage = next(iter(client.Systems)).Storage[0]
volume = storage.Volumes.create({"Name": "DataVol", "CapacityBytes": 500*1024**3})

Network Configuration

port = client.Managers[0].EthernetInterfaces[0]
port.patch({"IPv4Addresses": [{"Address": "192.168.1.100", "SubnetMask": "255.255.255.0"}]})

Event Subscriptions

subs = client.EventService.Subscriptions
sub = subs.create({"Destination": "https://listener/events", "EventTypes": ["Alert"]})

Firmware Updates

client.UpdateService.SimpleUpdate(ImageURI="http://server/fw.bin", TransferProtocol="HTTP")

System Health Monitoring

for temp in chassis.Thermal.Temperatures:
    print(f"{temp.Name}: {temp.ReadingCelsius}ยฐC")

See EXAMPLES.md for 100+ more examples covering:

  • BIOS configuration
  • Certificate management
  • Virtual media (KVM)
  • LDAP authentication
  • Boot order configuration
  • SEL/log collection
  • And much more...

Testing

Run the test suite:

# Install with dev dependencies
pip install -e ".[dev]"

# Run all tests
pytest tests/

# Run with coverage
pytest --cov=rackfish tests/

# Run specific test file
pytest tests/test_common_usage.py

Project Structure

rackfish/
โ”œโ”€โ”€ rackfish/          # Main package
โ”‚   โ”œโ”€โ”€ __init__.py       # Package initialization
โ”‚   โ””โ”€โ”€ client.py         # Core library implementation
โ”œโ”€โ”€ tests/                # Test suite
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ test_common_usage.py
โ”‚   โ”œโ”€โ”€ test_oem_links_surfacing.py
โ”‚   โ””โ”€โ”€ test_recursion_fix.py
โ”œโ”€โ”€ examples/             # Usage examples
โ”‚   โ”œโ”€โ”€ examples_comprehensive.py
โ”‚   โ”œโ”€โ”€ demo_surfacing_comprehensive.py
โ”‚   โ””โ”€โ”€ example_oem_links.py
โ”œโ”€โ”€ docs/                 # Documentation
โ”‚   โ”œโ”€โ”€ INDEX.md
โ”‚   โ”œโ”€โ”€ EXAMPLES.md
โ”‚   โ”œโ”€โ”€ USE_CASES.md
โ”‚   โ”œโ”€โ”€ TESTS.md
โ”‚   โ”œโ”€โ”€ OEM_LINKS_SURFACING.md
โ”‚   โ””โ”€โ”€ COMPLETION_SUMMARY.md
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ copilot-instructions.md
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ requirements.txt

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Architecture

Core Components

  • RedfishClient - HTTP session management, authentication, base URL handling
  • RedfishResource - Dynamic resource representation with lazy loading
  • _convert - Recursive JSON-to-object mapping with link stub creation
  • _hydrate - Property mapping, OEM/Links surfacing, action binding

Key Design Patterns

  1. Lazy Loading - Link stubs defer fetching until attribute access
  2. OEM Surfacing - Vendor properties promoted to main object (collision-safe)
  3. Links Surfacing - Related resources directly accessible (collision-safe)
  4. Action Methods - Redfish Actions bound as callable instance methods
  5. ActionInfo Validation - Parameter schemas fetched and enforced

Recursion Guard

Deeply nested JSON structures are handled safely by deferring hydration (fetched=False) for all embedded resources, preventing stack overflow.

Supported Use Cases

The library supports 150+ common Redfish operations including:

System Management

  • Power control (Reset, ForceOff, GracefulRestart)
  • Boot order configuration
  • System health monitoring

Storage

  • Logical drive creation/deletion
  • Storage controller management
  • Drive inventory and status

Network

  • IP configuration (IPv4/IPv6)
  • VLAN management
  • DNS/NTP configuration
  • SNMP trap configuration

User & Security

  • User account CRUD
  • Role assignment
  • Password policies
  • LDAP integration

Certificates

  • CSR generation
  • SSL/TLS certificate import
  • SSH public key management
  • Two-factor authentication certs

Firmware & BIOS

  • Firmware updates
  • BIOS configuration
  • BMC reset/rollback

Monitoring & Logs

  • Temperature sensors
  • Fan speeds
  • Voltage readings
  • System event logs (SEL)

Virtual Media

  • ISO mounting (KVM)
  • VNC/KVM configuration
  • Virtual media operations

See EXAMPLES.md for complete list and code samples.

OEM Vendor Support

Works with any Redfish-compliant BMC including:

  • Huawei - TaiShan servers, FruControl, custom boot modes
  • Dell - iDRAC, DellAttributes
  • HPE - iLO, HPE-specific extensions
  • Lenovo - XClarity
  • Supermicro - IPMI/Redfish hybrid
  • And any other vendor implementing Redfish standard

OEM extensions are automatically surfaced to the main object for easy access.

Advanced Features

Generic Request Helpers

For operations not exposed as methods:

response = client.get("/redfish/v1/custom/path")
client.post("/redfish/v1/Actions/Custom", data={"param": "value"})
client.patch("/redfish/v1/Systems/1", data={"AssetTag": "NEW"})
client.delete("/redfish/v1/Collection/Item")

Allowable Values

Get valid parameter values:

reset_types = system.get_allowable_values("ResetType")
print(f"Valid reset types: {reset_types}")

Raw JSON Access

raw_data = resource.to_dict()

Contributing

See .github/copilot-instructions.md for development guidelines and architecture details.

License

See LICENSE file.

Version

Current version: 1.0.0

Requirements

  • Python 3.8+
  • requests library

Support

For issues, questions, or contributions, please refer to the project repository.

Project details


Download files

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

Source Distribution

rackfish-1.0.1.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

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

rackfish-1.0.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file rackfish-1.0.1.tar.gz.

File metadata

  • Download URL: rackfish-1.0.1.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rackfish-1.0.1.tar.gz
Algorithm Hash digest
SHA256 723f8c471f258175e0fec362e503bca752147ac8df7b6f56cf23d6d2859cb401
MD5 4f26c146f7dac679f27f6fcc84263038
BLAKE2b-256 10f5a97deb4619c87199a02356a544bd192018b3358616642484e442f7151335

See more details on using hashes here.

Provenance

The following attestation bundles were made for rackfish-1.0.1.tar.gz:

Publisher: publish.yml on thefrolov/rackfish

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rackfish-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: rackfish-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rackfish-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13b4db1d412fd33ca88070ba13828354354fb7280b1a7ea70bd7cef8da851eb4
MD5 dc1b7b5f013c06dd79100718620fd434
BLAKE2b-256 fa064e796610c590a8205de014ae8b9e08a683e40069d451d3c883b7c1af6205

See more details on using hashes here.

Provenance

The following attestation bundles were made for rackfish-1.0.1-py3-none-any.whl:

Publisher: publish.yml on thefrolov/rackfish

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page