Skip to main content

parses a binary FRU (Field Replaceable Unit) file and extracts information from it.

Project description

FRU Parser

A comprehensive Python package that parses binary FRU (Field Replaceable Unit) files according to the IPMI Platform Management FRU Information Storage Definition v1.0 rev 1.3 specification.

Features

  • Complete IPMI FRU Support: Parses all standard FRU areas including Common Header, Internal Use, Chassis Info, Board Info, Product Info, and Multi-Record areas
  • Multiple String Encodings: Supports ASCII, BCD+, 6-bit ASCII, and binary string encodings
  • Comprehensive Validation: Validates checksums, format versions, and data integrity
  • Chassis Type Mapping: Includes complete chassis type enumeration according to IPMI specification
  • Multi-Record Support: Parses various multi-record types including Management Access Records (UUID), Power Supply Information, and OEM records
  • Robust Error Handling: Detailed error reporting with specific exception types
  • Command-Line Interface: Easy-to-use CLI with verbose and quiet modes
  • JSON Output: Clean, structured JSON output for easy integration
  • Comprehensive Testing: Full test suite with unit and integration tests

Installation

From PyPI (when published)

pip install fru-parser

From Source

git clone https://github.com/your-username/fru-parser.git
cd fru-parser
pip install -e .

Using uv (recommended)

uv sync

Usage

Command Line Interface

Basic usage:

fru-parser --fru-bin system.fru --output system.json

With verbose output:

fru-parser --fru-bin system.fru --output system.json --verbose

Quiet mode (errors only):

fru-parser --fru-bin system.fru --output system.json --quiet

Help and version:

fru-parser --help
fru-parser --version

Python API

from fru_parser import parse_fru

# Parse a FRU file
fru_data = parse_fru("system.fru", "output.json")

# Access parsed data
print(f"Chassis Type: {fru_data['chassis']['type_name']}")
print(f"Board Manufacturer: {fru_data['board']['mfg']['data']}")
print(f"Product Name: {fru_data['product']['pname']['data']}")

# Check for multi-record data
if 'multirecord' in fru_data:
    for record in fru_data['multirecord']:
        if record['type_name'] == 'Management Access Record':
            print(f"System UUID: {record['uuid']}")

FRU File Structure

The FRU parser extracts information from the following areas:

Common Header

  • Format version validation
  • Area offset pointers
  • Checksum validation

Internal Use Area (Optional)

  • Vendor-specific data
  • Raw hex output

Chassis Info Area

  • Chassis type (with human-readable names)
  • Part number and serial number
  • Custom fields

Board Info Area

  • Manufacturing date/time
  • Board manufacturer and product name
  • Serial number and part number
  • File identifier
  • Custom fields

Product Info Area

  • Product manufacturer and name
  • Version and part number
  • Serial number and asset tag
  • File identifier
  • Custom fields

Multi-Record Area (Optional)

  • Management Access Records (UUID)
  • Power Supply Information
  • Additional Information
  • Onboard Devices Extended Information
  • OEM Records

Output Format

The parser generates structured JSON output:

{
    "internal": "010203040A0B0C0D",
    "chassis": {
        "type": 10,
        "type_name": "Notebook",
        "pn": {
            "type": "text",
            "data": "CHAS-C00L-12"
        },
        "serial": {
            "type": "bcdplus",
            "data": "45678"
        },
        "custom": []
    },
    "board": {
        "date": "20/5/2025 07:55:00",
        "lang": 1,
        "mfg": {
            "type": "text",
            "data": "Biggest International Corp."
        },
        "pname": {
            "type": "text",
            "data": "Some Cool Product"
        },
        "serial": {
            "type": "bcdplus",
            "data": "123456"
        },
        "pn": {
            "type": "6bitascii",
            "data": "BRD-PN-345"
        },
        "file": {
            "type": "text",
            "data": "example1.json"
        },
        "custom": []
    },
    "product": {
        "lang": 1,
        "mfg": {
            "type": "text",
            "data": "Super OEM Company"
        },
        "pname": {
            "type": "text",
            "data": "Label-engineered Super Product"
        },
        "pn": {
            "type": "6bitascii",
            "data": "PRD-PN-1234"
        },
        "ver": {
            "type": "text",
            "data": "v1.1"
        },
        "serial": {
            "type": "6bitascii",
            "data": "OEM12345"
        },
        "atag": {
            "type": "text",
            "data": "Accounting Dept."
        },
        "file": {
            "type": "text",
            "data": "example2.json"
        },
        "custom": []
    },
    "multirecord": [
        {
            "type": 4,
            "type_name": "Management Access Record",
            "subtype": "uuid",
            "uuid": "9BD70799-CCF0-4915-A7F9-7CE7D64385CF"
        }
    ]
}

String Encoding Support

The parser supports all IPMI FRU string encodings:

  • Text/ASCII (Type 3): Standard ASCII text
  • 6-bit ASCII (Type 2): Compressed ASCII encoding
  • BCD+ (Type 1): Binary Coded Decimal Plus with special characters
  • Binary (Type 0): Raw binary data (output as hex)

Error Handling

The parser provides detailed error reporting:

  • FRUChecksumError: Checksum validation failures
  • FRUInvalidValueError: Invalid field values
  • FRUFormatError: File format issues
  • FRUStringDecodeError: String decoding problems
  • FRUParseError: General parsing errors

Chassis Types

The parser includes complete chassis type mapping:

  • Desktop, Laptop, Notebook
  • Tower, Mini Tower, Rack Mount
  • Blade, Blade Enclosure
  • Tablet, Convertible, Detachable
  • IoT Gateway, Embedded PC
  • And many more (see CHASSIS_TYPES in the source)

Development

Setup Development Environment

git clone https://github.com/your-username/fru-parser.git
cd fru-parser
uv sync

Running Tests

# Run all tests
python -m pytest tests/

# Run with coverage
python -m pytest tests/ --cov=src/fru_parser

# Run specific test file
python -m pytest tests/test_parser.py

Code Quality

# Linting
flake8 src/ tests/

# Type checking
mypy src/

# Formatting
black src/ tests/

Building and Publishing

  1. Update the version in pyproject.toml
  2. Build and publish:
    uv publish
    

Authentication Options

Option 1: Command-line arguments

# Using API token (recommended)
uv publish --token <your-token>

Option 2: Environment variables

# Using API token (recommended)
export UV_PUBLISH_TOKEN=<your-token>
uv publish

Option 3: Trusted publishing (GitHub Actions)

uv publish --trusted-publishing automatic

Getting PyPI API Token

  1. Go to PyPI and log in
  2. Go to Account Settings → API tokens
  3. Create a new token with "Entire account" scope
  4. Copy the token and use it with the --token option

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

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

References

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

fru_parser-0.1.1.tar.gz (793.7 kB view details)

Uploaded Source

Built Distribution

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

fru_parser-0.1.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file fru_parser-0.1.1.tar.gz.

File metadata

  • Download URL: fru_parser-0.1.1.tar.gz
  • Upload date:
  • Size: 793.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.6

File hashes

Hashes for fru_parser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 39df26d06c27ae3acfc05958eb885c284cfdfa43de3e8dc6ff08e732e62b5fa5
MD5 77d45ab6b5b0d3d702c41ec7b612b279
BLAKE2b-256 2b87952bb53d50efccf4a1d3515637b7005ba3c05e862509677fe3beddfc3997

See more details on using hashes here.

File details

Details for the file fru_parser-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fru_parser-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.6

File hashes

Hashes for fru_parser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b55edf991a3e4c593d49f88723b76534db286d55f02c4e1139112f95535182c2
MD5 8cd9d92293046da96f9ad001212c5b40
BLAKE2b-256 81e6a2c9050bccb38e26816c89df88ddd8357ddb62af0966debaa616cd339b42

See more details on using hashes here.

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