diff --git a/client.go b/client.go index dc3ddd84..3e4fa9c4 100644 --- a/client.go +++ b/client.go @@ -437,7 +437,6 @@ func (c *APIClient) runRawRequestWithHeaders(method, url string, payloadBuffer i if c.auth != nil { if c.auth.Token != "" { req.Header.Set("X-Auth-Token", c.auth.Token) - req.Header.Set("Cookie", fmt.Sprintf("sessionKey=%s", c.auth.Token)) } else if c.auth.BasicAuth && c.auth.Username != "" && c.auth.Password != "" { encodedAuth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%v:%v", c.auth.Username, c.auth.Password))) req.Header.Set("Authorization", fmt.Sprintf("Basic %v", encodedAuth)) diff --git a/redfish/bios.go b/redfish/bios.go index b58b945f..b225c7aa 100644 --- a/redfish/bios.go +++ b/redfish/bios.go @@ -89,10 +89,6 @@ type Bios struct { activeSoftwareImage string // rawData holds the original serialized JSON so we can compare updates. rawData []byte - // etag contains the etag header when fetching the object. This is used to - // control updates to make sure the object has not been modified my a different - // process between fetching and updating that could cause conflicts. - etag string } // UnmarshalJSON unmarshals an Bios object from the raw JSON. @@ -158,10 +154,6 @@ func GetBios(c common.Client, uri string) (*Bios, error) { return nil, err } - if resp.Header["Etag"] != nil { - bios.etag = resp.Header["Etag"][0] - } - bios.SetClient(c) return &bios, nil } @@ -271,6 +263,12 @@ func (bios *Bios) UpdateBiosAttributesApplyAt(attrs BiosAttributes, applyTime co } } + resp, err := bios.Client.Get(bios.settingsTarget) + if err != nil { + return err + } + defer resp.Body.Close() + // If there are any allowed updates, try to send updates to the system and // return the result. if len(payload) > 0 { @@ -280,11 +278,11 @@ func (bios *Bios) UpdateBiosAttributesApplyAt(attrs BiosAttributes, applyTime co } var header = make(map[string]string) - if bios.etag != "" { - header["If-Match"] = bios.etag + if resp.Header["Etag"] != nil { + header["If-Match"] = resp.Header["Etag"][0] } - resp, err := bios.Client.PatchWithHeaders(bios.settingsTarget, data, header) + resp, err = bios.Client.PatchWithHeaders(bios.settingsTarget, data, header) if err != nil { return err } diff --git a/redfish/bios_test.go b/redfish/bios_test.go index cf3c3e4a..bc03da27 100644 --- a/redfish/bios_test.go +++ b/redfish/bios_test.go @@ -206,15 +206,15 @@ func TestUpdateBiosAttributes(t *testing.T) { calls := testClient.CapturedCalls() - if len(calls) != 1 { + if len(calls) != 2 { t.Errorf("Expected one call to be made, captured: %v", calls) } - if !strings.Contains(calls[0].Payload, "AssetTag") { + if !strings.Contains(calls[1].Payload, "AssetTag") { t.Errorf("Unexpected update payload: %s", calls[0].Payload) } - if strings.Contains(calls[0].Payload, "@Redfish.SettingsApplyTime") { + if strings.Contains(calls[1].Payload, "@Redfish.SettingsApplyTime") { t.Error("Expected 'SettingsApplyTime' to not be present") } } @@ -240,15 +240,15 @@ func TestUpdateBiosAttributesApplyAt(t *testing.T) { calls := testClient.CapturedCalls() - if len(calls) != 1 { + if len(calls) != 2 { t.Errorf("Expected one call to be made, captured: %v", calls) } - if !strings.Contains(calls[0].Payload, "AssetTag") { + if !strings.Contains(calls[1].Payload, "AssetTag") { t.Errorf("Unexpected update payload: %s", calls[0].Payload) } - if !strings.Contains(calls[0].Payload, "@Redfish.SettingsApplyTime") { + if !strings.Contains(calls[1].Payload, "@Redfish.SettingsApplyTime") { t.Error("Expected 'SettingsApplyTime' to be present") } }