---
# System prepended metadata

title: Generating Redfish Mockup from OpenBMC on Raspberry Pi 5
tags: [樹莓派, RaspberryPi5, RaspberryPi, Redfish, OpenBMC]

---

# Generating Redfish Mockup from OpenBMC on Raspberry Pi 5
## Learning Motivation
熟悉 Redfish 的檔案結構，剛好上次在 Raspberry Pi 5 裝了 OpenBMC ，藉此機會驗證 Redfish 在樹莓派上是否能正常運作。
- [RaspberryPi 5 構建 OpenBMC](https://hackmd.io/@HiT8zS-9RZyrso4DHNCE8Q/SJqsn1fn-e)

## Prerequisites
- Raspberry Pi 5 running OpenBMC
- python3 and pip installed
- Python package management tools you prefer (e.g., venv, Poetry, or uv)
- [Docker](https://www.docker.com/get-started/)
- [Postman](https://www.postman.com/downloads/) (Option)

## Redfish 
- [Redfish Official website](https://redfish.dmtf.org/redfish/v1)
- [Redfish Resource and Schema Guide](https://www.dmtf.org/sites/default/files/standards/documents/DSP2046_2025.4.pdf)
- [Redfish White Paper - DSP2044](https://www.dmtf.org/dsp/DSP2044)
## Redfish Mockup Creator - Introduction
> The Redfish Mockup Creator is a tool that creates a Redfish mockup from a live Redfish service.
- https://github.com/DMTF/Redfish-Mockup-Creator
- 透過對實際運行 Redfish Service 的系統/硬體（ex. OpenBMC）不斷發送 `HTTP GET request` ，擷取 Redfish API 回應資料 ，並以 JSON 格式儲存，最後產生 `Mockup` 。


## Redfish Mockup Server - Introduction
> The Redfish Mockup Server serves Redfish requests against a Redfish mockup. 
- https://github.com/DMTF/Redfish-Mockup-Server
- Default IP address and port : `127.0.0.1:8000`
- 可以從 [DSP2043](https://www.dmtf.org/dsp/DSP2043) 獲取最新的 `Redfish Mockups Data`
- 根據 `Mockup` 去回應使用者發送的 Redfish API Request，讓使用者在沒有實際硬體的情況下進行測試與開發。

## My Plan
先使用 `Redfish Mockup Creator` 擷取 Raspberry Pi 5 上的 Redfish API 回應資料，並建立對應的 `Mockup`，再透過 `Redfish Mockup Server` 根據 `Mockup` 去回應使用者發送的 API Request ，達到模擬 Redfish service 的效果。
> 其實就是練習使用 `Redfish Mockup Creator` , `Redfish Mockup Server`

### 1. Redfish Mockup Creator
- Pull the container from Docker Hub:
```bash
docker pull dmtf/redfish-mockup-creator:latest
```
:::info
我使用 Docker 時，發現後續執行過程不斷出現亂碼，因此改用 Python 😭
:::

**1. Download the source code**
```bash
git clone https://github.com/DMTF/Redfish-Mockup-Creator.git
cd Redfish-Mockup-Creator
```
**2. Create a Virtual Environment using uv**
```bash
uv venv
```

**3. Activate the Virtual Environment**
```bash
source .venv/bin/activate
```

**4. Install Dependencies**
```bash
uv pip install -r requirements.txt
```

**5. Create Output Directory (Option)**
```bash
mkdir ./mockup_sponge_py
```

**6. Run Redfish Mockup Creator**
- Boot up the Raspberry Pi and find its IP address
- [redfishMockupCreate.py](https://github.com/DMTF/Redfish-Mockup-Creator/blob/main/redfishMockupCreate.py#L40C15-L40C30) Input Arguments
```bash
python redfishMockupCreate.py \
  -u <user_name> \         # User Name
  -p <password> \          # Password
  -r <raspberrypi_ip> \    # RaspberryPi IP address
  -S \                     # HTTPS
  -D ./mockup_sponge_py    # Output Directory
```

**7. Result**
![SCR-20260419-siat](https://hackmd.io/_uploads/rylWQWSaZe.png)

```bash
tree -L 1 mockup_sponge_py/redfish/v1 
```
```txt
mockup_sponge_py/redfish/v1
├── $metadata
├── AccountService         ##
├── Cables
├── CertificateService
├── Chassis                ##
├── EventService
├── Fabrics
├── index.json
├── JsonSchemas
├── Managers               ##
├── odata
├── Registries
├── schema
├── SessionService
├── Systems                ##
├── TaskService
├── TelemetryService
└── UpdateService
```

- **Accounts** : `mockup_sponge_py/redfish/v1/AccountService/Accounts/index.json`
```json
{
    "@odata.id": "/redfish/v1/AccountService/Accounts",
    "@odata.type": "#ManagerAccountCollection.ManagerAccountCollection",
    "Description": "BMC User Accounts",
    "Members": [
        {
            "@odata.id": "/redfish/v1/AccountService/Accounts/root"
        }
    ],
    "Members@odata.count": 1,
    "Name": "Accounts Collection"
}
```
- **Chassis** : `mockup_sponge_py/redfish/v1/Chassis/index.json`
```json
{
    "@odata.id": "/redfish/v1/Chassis",
    "@odata.type": "#ChassisCollection.ChassisCollection",
    "Members": [],
    "Members@odata.count": 0,
    "Name": "Chassis Collection"
}
```

### 2. Redfish Mockup Server
**1. Pull the container from Docker Hub**
```bash
docker pull dmtf/redfish-mockup-server:latest
```

**2. Runs the container with a specified mockup**
`<path-to-mockup>` is the path to the mockup directory
Using the previously generated `mockup_sponge_py`
```bash
docker run --rm -p 8000:8000 -v <path-to-mockup>:/mockup \
dmtf/redfish-mockup-server:latest -D /mockup
```

![SCR-20260421-sscg](https://hackmd.io/_uploads/SkHMmWSa-l.png)

**3. Sends requests to the (Redfish API) server**
- Open another new terminal
```bash
curl http://127.0.0.1:8000/redfish/v1
```
![SCR-20260421-ssjx](https://hackmd.io/_uploads/rkU7XWBp-e.png)



```bash
# Example
curl http://127.0.0.1:8000/redfish/v1/Chassis

curl http://127.0.0.1:8000/redfish/v1/Managers
```
![SCR-20260421-sssz](https://hackmd.io/_uploads/H1BEX-Bp-l.png)



- Postman (GUI)
![SCR-20260419-tevi](https://hackmd.io/_uploads/B1u87ZrpWg.png)


## DSP2043 - Redfish Mockups Bundle
> Set of mockups that can be used as sample output from `GET` responses
> from a Redfish service. Informative in nature, it was used to develop the schema. A person can set up an NGINX or similar server and configure it to output JSON format and then use this directory for demonstration purposes.

Because OpenBMC is not fully supported on Raspberry Pi, most of the `mockup data` retrieved from the Raspberry Pi contains zero or no information.

Therefore, **it is recommended to download the files in [DSP2043](https://www.dmtf.org/dsp/DSP2043) for more complete examples**.

## Reference
- [Redfish Official website](https://redfish.dmtf.org/redfish/v1)
- [Redfish模型工具](https://iris123321.blogspot.com/2022/02/redfish-mockup-creator-redfish-mockup.html)
- https://github.com/DMTF/Redfish-Mockup-Creator
- https://github.com/DMTF/Redfish-Mockup-Server
- [API 測試工具 POSTMAN 基本操作](https://medium.com/@ray102467/tools-api-%E6%B8%AC%E8%A9%A6%E5%B7%A5%E5%85%B7-postman-%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C-7340b1ac5be1)