stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
224 stars 117 forks source link

Fix VirtualMediaConfig for Supermicro #212

Closed feuerrot closed 2 years ago

feuerrot commented 2 years ago

The redfish implementation of Supermicro doesn't seem to like Inserted or WriteProtected as additional properties for the InsertMedia action target and rejects requests which include them:

{
  "error": {
    "code": "Base.v1_4_0.GeneralError",
    "Message": "A general error has occurred. See ExtendedInfo for more information.",
    "@Message.ExtendedInfo": [
      {
        "MessageId": "Base.1.4.PropertyUnknown",
        "Severity": "Warning",
        "Resolution": "Remove the unknown property from the request body and resubmit the request if the operation failed.",
        "Message": "The property Inserted is not in the list of valid properties for the resource.",
        "MessageArgs": [
          "Inserted"
        ],
        "RelatedProperties": [
          "Inserted"
        ]
      },
      {
        "MessageId": "Base.1.4.PropertyUnknown",
        "Severity": "Warning",
        "Resolution": "Remove the unknown property from the request body and resubmit the request if the operation failed.",
        "Message": "The property WriteProtected is not in the list of valid properties for the resource.",
        "MessageArgs": [
          "WriteProtected"
        ],
        "RelatedProperties": [
          "WriteProtected"
        ]
      }
    ]
  }
}

This PR adds an omitempty attribute to the redfish.VirtualMediaConfig struct, so at least VirtualMedia.InsertMediaConfig() can be used for Supermicro systems. The same problem exists in the VirtualMedia.InsertMedia() function, but I didn't want to change the functions interface and am not sure if there is a good alternative.