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

Huawei Machine support setting boot order error #176

Closed Sn0rt closed 2 years ago

Sn0rt commented 2 years ago

the huawei server is different with Dell/HP . and the boot order is show in Bios attribute.

for example

{
  "@odata.context": "/redfish/v1/$metadata#Systems/Members/1/Bios/$entity",
  "@odata.id": "/redfish/v1/Systems/1/Bios",
  "@odata.type": "#Bios.v1_0_0.Bios",
  "Id": "Bios",
  "Name": "BIOS Configuration Current Settings",
  "AttributeRegistry": "BiosAttributeRegistry.8.0.2",
  "Attributes": {
...
    "WakeOnS5DayOfMonth": 1,
    "BootType": "LegacyBoot",
...
    "BootTypeOrder0": "HardDiskDrive",
    "BootTypeOrder1": "DVDROMDrive",
    "BootTypeOrder2": "PXE",
    "BootTypeOrder3": "Others",
    "OemSecureBoot": "Disabled",

the bug detail is the gofish will auto merege some field of the request. this is beacuse

func (bios *Bios) UpdateBiosAttributesApplyAt(attrs BiosAttributes, applyTime common.ApplyTime) error {
    payload := make(map[string]interface{})

    // Get a representation of the object's original state so we can find what
    // to update.
    original := new(Bios)
    err := original.UnmarshalJSON(bios.rawData)
    if err != nil {
        return err
    }

    for key := range attrs {
        if original.Attributes[key] != attrs[key] { // here
            payload[key] = attrs[key]
        }
    }

so in some cases, if the user want set a boot order with["Others", "PXE", "DVDROMDrive", "HardDiskDrive"], the following request will gernated when current system BootTypeOrder3 is HardDiskDrive

{"Attributes":{"BootTypeOrder0":"Others","BootTypeOrder1":"PXE","BootTypeOrder2":"DVDROMDrive"}}

loss BootTypeOrder3 attribute.

the correct behavior should as follow. whatever BootTypeOrder* as same with the original or not.

PATCH /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
Host: 192.168.142.53
User-Agent: gofish/1.0
Connection: close
Content-Length: 129
Accept: application/json
Content-Type: application/json
Cookie: sessionKey=e940229e0b23c11c0f929bd5e3397539
If-Match: W/"07658377"
X-Auth-Token: e940229e0b23c11c0f929bd5e3397539
Accept-Encoding: gzip

{"Attributes":{"BootTypeOrder0":"Others","BootTypeOrder1":"PXE","BootTypeOrder2":"DVDROMDrive","BootTypeOrder3":"HardDiskDrive"}}

HTTP/1.1 200 OK
Connection: close
Content-Length: 624

@stmcginnis can you assign this issues to me ? I will fix it later.

stmcginnis commented 2 years ago

Closed by #177