DMTF / Redfish-Mockup-Server

A simple Python 3.4 program that can be copied into a folder at the top of any Redfish mockup and can serve Redfish requests on the specified IP/port.
Other
87 stars 38 forks source link

Adding expand support for all Redfish resources to the Redfish mockup #88

Closed bharadwaj-a closed 2 years ago

bharadwaj-a commented 2 years ago

Tested using the existing rack-mount mockup:

# python3 redfishMockupServer.py -p $PORT &
# wget -qO - localhost:$PORT/redfish/v1/Chassis?\$expand=*\(\$levels=1\)
{
    "@odata.id": "/redfish/v1/Chassis",
    "@odata.type": "#ChassisCollection.ChassisCollection",
    "Members": [
        {
            "@odata.id": "/redfish/v1/Chassis/1U",
            "@odata.type": "#Chassis.v1_11_0.Chassis",
            "AssetTag": "Chicago-45Z-2381",
            "ChassisType": "RackMount",
            "DepthMm": 711,
            "HeightMm": 44.45,
            "Id": "1U",
            "IndicatorLED": "Lit",
            "Links": {
                "ComputerSystems": [
                    {
                        "@odata.id": "/redfish/v1/Systems/437XR1138R2"
                    }
                ],
                "ManagedBy": [
                    {
                        "@odata.id": "/redfish/v1/Managers/BMC"
                    }
                ],
                "ManagersInChassis": [
                    {
                        "@odata.id": "/redfish/v1/Managers/BMC"
                    }
                ]
            },
...
    ],
    "Members@odata.count": 1,
    "Name": "Chassis Collection"
}
# wget -qO - localhost:$PORT/redfish/v1/TaskService?\$expand=~\(\$levels=2\)
{
    "@odata.id": "/redfish/v1/TaskService",
    "@odata.type": "#TaskService.v1_1_4.TaskService",
    "CompletedTaskOverWritePolicy": "Manual",
    "DateTime": "2015-03-13T04:14:33+06:00",
    "Id": "TaskService",
    "LifeCycleEventOnTaskStateChange": true,
    "Name": "Tasks Service",
    "Oem": {},
    "ServiceEnabled": true,
    "Status": {
        "Health": "OK",
        "State": "Enabled"
    },
    "Tasks": {
        "@odata.id": "/redfish/v1/TaskService/Tasks",
        "@odata.type": "#TaskCollection.TaskCollection",
        "Members": [
            {
                "@odata.id": "/redfish/v1/TaskService/Tasks/545",
                "@odata.type": "#Task.v1_4_3.Task",
                "EndTime": "2012-03-07T14:45+06:00",
                "Id": "545",
                "Messages": [
                    {
                        "Message": "The property SKU is a read only property and cannot be assigned a value",
                        "MessageArgs": [
                            "SKU"
                        ],
                        "MessageId": "Base.1.0.PropertyNotWriteable",
                        "RelatedProperties": [
                            "SKU"
                        ],
                        "Severity": "Warning"
                    }
                ],
                "Name": "Task 545",
                "StartTime": "2012-03-07T14:44+06:00",
                "TaskState": "Completed",
                "TaskStatus": "OK"
            }
        ],
        "Members@odata.count": 1,
        "Name": "Task Collection"
    }
}

Note: Exception of '*' expansion of payload annotations

jautor commented 2 years ago

Approved 5/20