Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Redfish support #2

Open
starbops opened this issue Feb 20, 2024 · 7 comments
Open

[FEATURE] Redfish support #2

starbops opened this issue Feb 20, 2024 · 7 comments
Assignees
Labels
area/redfish Front-end protocol related and it's Redfish help wanted Extra attention is needed kind/feature New feature proposed/asked

Comments

@starbops
Copy link
Owner

starbops commented Feb 20, 2024

Is your feature request related to a problem? Please describe.

Currently, KubeBMC only supports limited IPMI functionalities for KubeVirt VMs. It would also be helpful to support Redfish as it is newer, feature-rich, and gradually becomes dominant in such areas.

Describe the solution you'd like

A set of Redfish APIs that supports users to communicate with to instruct KubeBMC to:

  • Retrieve power status,
  • Set power on/off/reset,
  • Set boot device, and
  • Mount/unmount virtual media

for KubeVirt VMs.

Describe alternatives you've considered

N/A

Additional context

We could implement the following resources to provide a minimum viable functionalities. Kudos to @rwleea!

{
    "@odata.type": "#ServiceRoot.v1_16_1.ServiceRoot",
    "@odata.id": "/redfish/v1/",
    "Id": "RootService",
    "Name": "Root Service",
    "Vendor": "Contoso",
    "Product": "WidgetDeluxe 8744",
    "RedfishVersion": "1.6.0",
    "UUID": "92384634-2938-2342-8820-489239905423",
    "Systems": {
        "@odata.id": "/redfish/v1/Systems"
    }
}
{
  "@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
  "Name": "Computer System Collection",
  "@odata.id": "/redfish/v1/Systems",
  "[email protected]": 1,
  "Members": [
    {
      "@odata.id": "/redfish/v1/Systems/1"
    }
  ]
}
{
  "@odata.id": "/redfish/v1/Systems/1",
  "@odata.type": "#ComputerSystem.v1_22_0.ComputerSystem",
  "Id": "1",
  "Name": "My Computer System",
  "UUID": "00000000-0000-0000-0000-000000000000",
  "HostName": "web-srv344",
  "Status": {
    "State": "Enabled",
    "Health": "Warning",
    "HealthRollup": "Warning",
    
  },
  "PowerState": "On",
  "Boot": {
    "BootSourceOverrideEnabled": "Once",
    "BootSourceOverrideMode": "UEFI",
    "BootSourceOverrideTarget": "Pxe",
    "[email protected]": [
      "None",
      "Pxe",
      "Cd",
      "Hdd"
    ]
  },
  "VirtualMedia": {
    "@odata.id": "/redfish/v1/Systems/1/VirtualMedia"
  },
  "Actions": {
    "#ComputerSystem.Reset": {
      "target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset",
      "@Redfish.ActionInfo": "/redfish/v1/Systems"
    }
  }
}
{
    "@odata.type": "#ActionInfo.v1_4_1.ActionInfo",
    "Id": "ResetActionInfo",
    "Name": "Reset Action Info",
    "Parameters": [
        {
            "Name": "ResetType",
            "Required": true,
            "DataType": "String",
            "AllowableValues": [
                "On",
                "ForceOff",
                "GracefulShutdown",
                "GracefulRestart",
                "ForceRestart",
                "Nmi",
                "ForceOn",
                "PushPowerButton"
            ]
        }
    ],
    "@odata.id": "/redfish/v1/Systems/1/ResetActionInfo"
}
{
  "@odata.type": "#VirtualMediaCollection.VirtualMediaCollection",
  "@odata.id": "/redfish/v1/Systems/1/VirtualMedia",
  "Name": "Virtual Media Services",
  "Description": "Redfish Manager Virtual Media Services Settings",
  "[email protected]": 1,
  "Members": [
    {
      "@odata.id": "/redfish/v1/Systems/1/VirtualMedia/CD1"
    }
  ]
}
{
  "@odata.type": "#VirtualMedia.v1_6_3.VirtualMedia",
  "@odata.id": "/redfish/v1/Systems/1/VirtualMedia/CD1",
  "Id": "CD1",
  "Name": "Virtual CD",
  "MediaTypes": [
    "CD",
    "DVD"
  ],
  "Image": "http://myserver/mymedia-read-only.iso",
  "ImageName": "mymedia-read-only.iso",
  "ConnectedVia": "URI",
  "Inserted": true,
  "WriteProtected": true,
  "UserName": "admin",
  "Password": "admin",
  "TransferProtocolType": "HTTP",
  "[email protected]": [
    "HTTP",
    "HTTPS"
  ],
  "TransferMethod": "Stream",
  "Actions": {
    "#VirtualMedia.InsertMedia": {
      "target": "/redfish/v1/Systems/1/VirtualMedia/CD1/Actions/VirtualMedia.InsertMedia",
      "@Redfish.ActionInfo": "/redfish/v1/Systems/1/VirtualMedia/CD1/InsertMediaActionInfo"
    },
    "#VirtualMedia.EjectMedia": {
      "target": "/redfish/v1/Systems/1/VirtualMedia/CD1/Actions/VirtualMedia.EjectMedia"
    }
  }
}
{
  "@odata.type": "#ActionInfo.v1_4_1.ActionInfo",
  "@odata.id": "/redfish/v1/Systems/1/VirtualMedia/CD1/InsertMediaActionInfo",
  "Id": "InsertMediaActionInfo",
  "Name": "Insert Media Action Info",
  "Parameters": [
    {
      "Name": "Image",
      "Required": true,
      "DataType": "String"
    },
    {
      "Name": "Inserted",
      "Required": false,
      "DataType": "Boolean"
    },
    {
      "Name": "Writable",
      "Required": true,
      "DataType": "Boolean"
    },
    {
      "Name": "UserName",
      "Required": false,
      "DataType": "String"
    },
    {
      "Name": "Password",
      "Required": false,
      "DataType": "String"
    },
    {
      "Name": "TransferProtocolType",
      "Required": true,
      "DataType": "String",
      "AllowableValues": [
        "HTTP",
        "HTTPS"
      ]
    },
    {
      "Name": "TransferMethod",
      "Required": true,
      "DataType": "String",
      "AllowableValues": [
        "Stream"
      ]
    }
  ]
}
@starbops starbops added kind/feature New feature proposed/asked help wanted Extra attention is needed area/redfish Front-end protocol related and it's Redfish labels Jul 28, 2024
@e-minguez
Copy link

Just FYI https://github.com/openshift-metal3/fakefish have something for faking redfish for KubeVirt instances

@starbops
Copy link
Owner Author

Hey @e-minguez thanks for the pointer. The way FakeFish works looks interesting. I should've found it earlier. Nevertheless, this gave me some ideas...

@starbops starbops self-assigned this Nov 18, 2024
@starbops
Copy link
Owner Author

So there are different levels of faking for a Redfish server...

  1. Mockup servers that contain static or templated JSON files, e.g., Redfish-Mockup-Server and fakefish
  2. Emulators that can handle not only GET but also other operations that require dynamic handling, e.g., Redfish-Interface-Emulator

Since our use cases involve POST actions, such as power management, we're more likely to implement a tiny but self-contained emulator.

I've checked several implementations on the Internet, but I only found one project that uses the OpenAPI generator to generate the client library in Go from the DMTF-published DSP8010 Redfish OpenAPI schema.

My current plan is to use a Golang-based OpenAPI generator [1][2] to generate models and server stubs from the Redfish OpenAPI schema. It turns out this isn't as easy as I imagine at the beginning. The Golang OpenAPI generators have their own limitations and they're both not as mature as the Java-based openapi-generator. Moreover, the Redfish OpenAPI schema is gigantic and uses some cryptic (or should I say erroneous) OpenAPI syntax that I'm unfamiliar with.

I might go the other way around to trim down the schema a bit since we wouldn't support that many endpoints and resources. Because of that, we'll stick to a specific Redfish version. Though that seems lame, it might be the only way that I can see. If my plan B is not going well, we'll need to fallback to JSON templates, which makes me arrrr...

@starbops
Copy link
Owner Author

My methods for verifying whether our Redfish implementation works mainly involve ad-hoc curl commands, but that might not be sufficient. I know KubeVirtBMC is far from a certified/validated Redfish device, but I'll try to make it as close as possible. Right now, I'll try to drop it into the workflow of the Tinkerbell use case and see what will happen.

@starbops
Copy link
Owner Author

Rufio is complaining about the returned Redfish ComputerSystem resource:

{"level":"error","controller":"machine","controllerGroup":"bmc.tinkerbell.org","controllerKind":"Machine","Machine":{"name":"machine-1","namespace":"tink-system"},"namespace":"tink-system","name":"mac
hine-1","reconcileID":"99daf185-ae31-4907-85de-081315bbd0e9","error":"get power state: 2 errors occurred:\n\t* provider: gofish: failed to retrieve some items: [{\"link\":\"/redfish/v1/Systems/1\",\"e
rror\":\"json: cannot unmarshal object into Go struct field .OperatingSystem of type string\"}]\n\t* failed to get power state\n\n","logger":"controllers/Machine","host":"default-machine-1-virtbmc.172
.19.31.240.sslip.io","caller":"/workspace/controller/machine.go:149","time":"2024-11-20T14:16:12Z","message":"failed to get Machine power state"}

@starbops
Copy link
Owner Author

Rufio is complaining about the returned Redfish ComputerSystem resource...

So the "OperatingSystem"-unmarshalling issue was raised in stmcginnis/gofish#364 and has already been fixed on the main branch (not yet shipped in any releases). But Rufio v0.5.2 depends on bmclib v2.3.4, which depends on gofish v0.19.0. It's relatively complex for us to build everything ourselves just for a working demo.

We can wait for those projects to bump their dependencies eventually. In the meantime, I'll try to modify the generated model and implementation of KubeVirtBMC to see if that's the only issue. I'll also look into Metal3 as a possible replacement for the demo.

@starbops
Copy link
Owner Author

Well, after I modified the OperatingSystem field from the OdataV4IdRef to the string type, Rufio can successfully contact the virtBMC via the Redfish protocol. Hooray!

image

This should be a temporary fix and will be corrected once the upstream fix is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redfish Front-end protocol related and it's Redfish help wanted Extra attention is needed kind/feature New feature proposed/asked
Projects
None yet
Development

No branches or pull requests

2 participants