stmcginnis/gofish

Huawei Machine support Etag when PATCH bios Attributes

Sn0rt opened this issue · 0 comments

Sn0rt commented

the current version

  1. the current version of gofish is not support set header with If-Match.
PATCH /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
Host: 192.168.142.53
User-Agent: gofish/1.0
Connection: close
Content-Length: 41
Accept: application/json
Content-Type: application/json
Cookie: sessionKey=xxx
X-Auth-Token: xxxx
Accept-Encoding: gzip

{"Attributes":{"PXE3Setting":"Disabled"}}

the server will give a response and the status code is 429 .

how to solve this problem : firstly get the setting target, and reuse the header of the response of the query.

for example

curl -k -v -u 'username:password' -XGET https://192.168.142.53/redfish/v1/Systems/1/Bios/Settings -H 'Content-Type: application/json'

....
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=CN; O=Huawei; ST=GuangDong; L=ShenZhen; OU=IT; CN=huawei
*  start date: Nov  7 02:04:51 2018 GMT
*  expire date: Nov  4 02:04:51 2028 GMT
*  issuer: C=CN; O=Huawei; CN=Huawei IT Product CA
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'Administrator'
> GET /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
> Host: 192.168.142.53
...
< HTTP/1.1 200 OK
< Date: Mon, 23 May 2022 07:13:12 GMT
< Referrer-Policy: no-referrer
< X-Frame-Options: SAMEORIGIN
< X-Download-Options: noopen
< Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' wss://*:*; img-src 'self' data:; frame-src 'self'; font-src 'self' data:; object-src 'self'; style-src 'self' 'unsafe-inline'
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Expires: 0
< OData-Version: 4.0
< ETag: W/"93227b24"
< Link: </redfish/v1/SchemaStore/en/Bios.json>;rel=describedby
< Allow: GET,PATCH,POST
< X-XSS-Protection: 1; mode=block
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-Content-Type-Options: nosniff
< Content-Length: 536
< Content-Type: application/json;charset=utf-8
<
* Connection #0 to host 10.129.111.38 left intact
{"@odata.context":"/redfish/v1/$metadata#Systems/Members/1/Bios/Settings/$entity","@odata.id":"/redfish/v1/Systems/1/Bios/Settings","@odata.type":"#Bios.v1_0_0.Bios","Id":"Settings","Name":"BIOS Configuration Pending Settings","AttributeRegistry":"BiosAttributeRegistry.8.0.2","Attributes":{"PXE3Setting":"Disabled"},"Actions":{"Oem":{"Huawei":{"#Settings.Revoke":{"target":"/redfish/v1/Systems/1/Bios/Settings/Actions/Oem/Huawei/Settings.Revoke","@Redfish.ActionInfo":"/redfish/v1/Systems/1/Bios/Settings/SettingsRevokeActionInfo"}}}}}

then reuse the ETag from the response , the etag value is W/"93227b24"

curl -u 'Administrator:Admin@9000' -XPATCH https://192.168.142.53/redfish/v1/Systems/1/Bios/Settings -d '{"Attributes": {"PXE3Setting": "Disabled"}}' -k -v -H 'Content-Type: application/json' -H 'If-Match: W/"93227b24"' -s | jq
...
> PATCH /redfish/v1/Systems/1/Bios/Settings HTTP/1.1
> Host: 192.168.142.53
> Authorization: Basic ....
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Type: application/json
> If-Match: W/"93227b24"
> Content-Length: 43
>
} [43 bytes data]
* upload completely sent off: 43 out of 43 bytes
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [265 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [265 bytes data]
* old SSL session ID is stale, removing

{ [5 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 23 May 2022 07:15:39 GMT
< Referrer-Policy: no-referrer
< X-Frame-Options: SAMEORIGIN
< X-Download-Options: noopen
< Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' wss://*:*; img-src 'self' data:; frame-src 'self'; font-src 'self' data:; object-src 'self'; style-src 'self' 'unsafe-inline'
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Expires: 0
< OData-Version: 4.0
< ETag: W/"93227b24"
< X-XSS-Protection: 1; mode=block
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-Content-Type-Options: nosniff
< Content-Length: 536
< Content-Type: application/json;charset=utf-8
<
{ [536 bytes data]
* Connection #0 to host 10.129.111.38 left intact
{
  "@odata.context": "/redfish/v1/$metadata#Systems/Members/1/Bios/Settings/$entity",
  "@odata.id": "/redfish/v1/Systems/1/Bios/Settings",
  "@odata.type": "#Bios.v1_0_0.Bios",
  "Id": "Settings",
  "Name": "BIOS Configuration Pending Settings",
  "AttributeRegistry": "BiosAttributeRegistry.8.0.2",
  "Attributes": {
    "PXE3Setting": "Disabled"
  },
  "Actions": {
    "Oem": {
      "Huawei": {
        "#Settings.Revoke": {
          "target": "/redfish/v1/Systems/1/Bios/Settings/Actions/Oem/Huawei/Settings.Revoke",
          "@Redfish.ActionInfo": "/redfish/v1/Systems/1/Bios/Settings/SettingsRevokeActionInfo"
        }
      }
    }
  }
}