Copyright 2016-2020 DMTF. All rights reserved.
The Redfish Mockup Server serves Redfish requests against a Redfish mockup. The server runs at either a specified IP address and port or the default IP address and port, 127.0.0.1:8000.
You can find DMTF-published sample mockups at All Published Versions of DSP2043.
To create a mockup from a service, use the Redfish-Mockup-Creator.
The scope of this tool is to serve a static mockup for development purposes. It does support modification requests, such as PATCH and POST, and actions to a limited extent. For a more feature-rich Redfish experience, one of the following tools can be used instead of the Redfish Mockup Server:
- Redfish-Interface-Emulator: A more functional service that implements modification requests and actions.
- Swordfish-API-Emulator: A SNIA extension to the previous tool with more built-in functionality supported.
To run the mockup server natively on your system:
To run the mockup server as a Docker container:
- Install Docker.
The Redfish Mockup Server can be configured using either command-line arguments or a configuration file (config.ini).
You can use a config.ini file in the current working directory with your settings. This is useful for repeated operations with the same configuration.
Example config.ini:
[Server]
host = 127.0.0.1
port = 8000
[Mockup]
Dir = /path/to/mockup
short-form = false
[SSL]
ssl = false
cert =
key =
[Options]
headers = false
time = 0
timefromjson = false
test-etag = false
ssdp = falseTo use a configuration file in a different location, use the --config option:
python redfishMockupServer.py --config /path/to/myconfig.iniNote: Command-line arguments always override configuration file settings, ensuring backward compatibility.
Redfish Mockup Server, version 1.1.4
usage: redfishMockupServer.py [-h] [-c CONFIG] [-H HOST] [-p PORT] [-D DIR]
[-E] [-X] [-t TIME] [-T] [-s] [--cert CERT]
[--key KEY] [-S] [-P]
Serve a static Redfish mockup.
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
Path to configuration file; defaults to 'config.ini'
in current directory
-H HOST, --host HOST, --Host HOST
hostname or IP address (default 127.0.0.1)
-p PORT, --port PORT, --Port PORT
host port (default 8000)
-D DIR, --dir DIR, --Dir DIR
path to mockup dir (may be relative to CWD)
-E, --test-etag, --TestEtag
(unimplemented) etag testing
-X, --headers load headers from headers.json files in mockup
-t TIME, --time TIME delay in seconds added to responses (float or int)
-T delay response based on times in time.json files in
mockup
-s, --ssl place server in SSL (HTTPS) mode; requires a cert and
key
--cert CERT the certificate for SSL
--key KEY the key for SSL
-S, --short-form, --shortForm
apply short form to mockup (omit filepath /redfish/v1)
-P, --ssdp make mockup SSDP discoverable
The mockup server starts an HTTP server at the -H HOST host and -p PORT port. The mockup server provides Redfish resources in the -D DIR mockup directory.
If the mockup does not contain the representation of the /redfish resource, you must provide the --short-form argument. If you omit the mockup, the mockup server serves DMTF's public-rackmount1 mockup.
Using command-line arguments only (backward compatible):
python redfishMockupServer.py -H 127.0.0.1 -p 8000 -D /home/user/redfish-mockupUsing a configuration file:
# Uses config.ini from current directory
python redfishMockupServer.pyUsing a custom configuration file:
python redfishMockupServer.py --config /path/to/custom.iniMixing configuration file and command-line arguments (command-line overrides config):
# Uses settings from config.ini but overrides the port
python redfishMockupServer.py -p 9000python redfishMockupServer.py -D /home/user/redfish-mockupTo run as a Docker container, use one of these actions to pull or build the container:
-
Pull the container from Docker Hub:
docker pull dmtf/redfish-mockup-server:latest
-
Build a container from local source:
docker build -t dmtf/redfish-mockup-server:latest . -
Build a container from GitHub:
docker build -t dmtf/redfish-mockup-server:latest https://github.com/DMTF/Redfish-Mockup-Server.git#main
This command runs the container with the built-in public-rackmount1 mockup:
docker run --rm dmtf/redfish-mockup-server:latestThis command runs the container with a specified mockup, where <path-to-mockup> is the path to the mockup directory:
docker run --rm -v <path-to-mockup>:/mockup dmtf/redfish-mockup-server:latest -D /mockupOr using compose:
docker compose up- Go to the "Actions" page
- Select the "Release and Publish" workflow
- Click "Run workflow"
- Fill out the form
- Click "Run workflow"