diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ff8b0871..5eff1436 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -17,7 +17,7 @@ jobs: # Setup our go environment - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: '1.21' @@ -37,7 +37,7 @@ jobs: # Setup our go environment - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: '1.21' diff --git a/redfish/componentintegrity.go b/redfish/componentintegrity.go index 1b76b693..8278f568 100644 --- a/redfish/componentintegrity.go +++ b/redfish/componentintegrity.go @@ -6,6 +6,7 @@ package redfish import ( "encoding/json" + "net/http" "github.com/stmcginnis/gofish/common" ) @@ -324,21 +325,29 @@ func (spdmgetsignedmeasurementsresponse *SPDMGetSignedMeasurementsResponse) setC } // SPDMGetSignedMeasurements generates an SPDM cryptographic signed statement over the given nonce and measurements of the SPDM Responder. -func (componentintegrity *ComponentIntegrity) SPDMGetSignedMeasurements(request *SPDMGetSignedMeasurementsRequest) (*SPDMGetSignedMeasurementsResponse, error) { +func (componentintegrity *ComponentIntegrity) SPDMGetSignedMeasurements(request *SPDMGetSignedMeasurementsRequest) (*SPDMGetSignedMeasurementsResponse, *Task, error) { resp, err := componentintegrity.PostWithResponse(componentintegrity.spdmGetSignedMeasurementsTarget, request) if err != nil { - return nil, err + return nil, nil, err } defer resp.Body.Close() + // Return Task if applicable + if resp.StatusCode == http.StatusAccepted { + if location := resp.Header["Location"]; len(location) > 0 { + task, err := GetTask(componentintegrity.GetClient(), location[0]) + return nil, task, err + } + } + var response SPDMGetSignedMeasurementsResponse err = json.NewDecoder(resp.Body).Decode(&response) if err != nil { - return nil, err + return nil, nil, err } response.setClient(componentintegrity.GetClient()) - return &response, nil + return &response, nil, nil } // TPMGetSignedMeasurements generates a TPM cryptographic signed statement over the given nonce and PCRs of the TPM for TPM 2.0 devices. diff --git a/redfish/computersystem.go b/redfish/computersystem.go index 30f00ded..1873c68c 100644 --- a/redfish/computersystem.go +++ b/redfish/computersystem.go @@ -510,7 +510,8 @@ type Boot struct { // boot from the UEFI BootOptionReference found in BootNext. Changes to // this property do not alter the BIOS persistent boot order // configuration. - BootSourceOverrideTarget BootSourceOverrideTarget `json:",omitempty"` + BootSourceOverrideTarget BootSourceOverrideTarget `json:",omitempty"` + AllowableBootSourceOverrideTargetValues []BootSourceOverrideTarget `json:"BootSourceOverrideTarget@Redfish.AllowableValues,omitempty"` // The link to a collection of certificates used for booting through HTTPS by this computer system. certificates string // The URI to boot from when BootSourceOverrideTarget is set to UefiHttp. @@ -531,7 +532,8 @@ type Boot struct { // for UEFI Boot Source Override as this setting is defined in UEFI as a // one time boot only. Changes to this property do not alter the BIOS // persistent boot order configuration. - UefiTargetBootSourceOverride string `json:",omitempty"` + UefiTargetBootSourceOverride string `json:",omitempty"` + AllowableUefiTargetBootSourceOverrideValues []string `json:"UefiTargetBootSourceOverride@Redfish.AllowableValues,omitempty"` } // UnmarshalJSON unmarshals a Boot object from the raw JSON. diff --git a/redfish/computersystem_test.go b/redfish/computersystem_test.go index 29311bb9..d5868fb2 100644 --- a/redfish/computersystem_test.go +++ b/redfish/computersystem_test.go @@ -79,6 +79,10 @@ var computerSystemBody = `{ "Boot0002" ], "UefiTargetBootSourceOverride": "uefi device path", + "UefiTargetBootSourceOverride@Redfish.AllowableValues": [ + "UsbClass(0xFFFF,0xFFFF,0xFF,0xFF,0xFF)", + "PciRoot(0x1)/Pci(0x1,0x0)/Pci(0x0,0x3)/MAC(00CDE21FAC3D,0x1)/IPv4(0.0.0.0)" + ], "HttpBootUri": "http://localhost/boot.efi" }, "BiosVersion": "P79 v1.00 (09/20/2013)", @@ -325,6 +329,12 @@ func TestComputerSystem(t *testing.T) { //nolint if result.operatingSystem != "/redfish/v1/Systems/1/OperatingSystem" { t.Errorf("Received invalid OperatingSystem reference: %s", result.operatingSystem) } + if result.Boot.AllowableBootSourceOverrideTargetValues[0] != NoneBootSourceOverrideTarget { + t.Errorf("Received invalid AllowablebootSourceOverrideTargetValue: %s", result.Boot.AllowableBootSourceOverrideTargetValues[0]) + } + if result.Boot.AllowableUefiTargetBootSourceOverrideValues[0] != "UsbClass(0xFFFF,0xFFFF,0xFF,0xFF,0xFF)" { + t.Errorf("Received invalid AllowableUefiTargetBootSourceOverrideValues: %s", result.Boot.AllowableUefiTargetBootSourceOverrideValues[0]) + } } // TestComputerSystemUpdate tests the Update call. diff --git a/redfish/power.go b/redfish/power.go index 61aa50a4..c161d19e 100644 --- a/redfish/power.go +++ b/redfish/power.go @@ -6,6 +6,7 @@ package redfish import ( "encoding/json" + "errors" "fmt" "strconv" @@ -383,17 +384,23 @@ type PowerSupply struct { rawData []byte redundancyLinks []string relateditemLinks []string + + resetTarget string } // UnmarshalJSON unmarshals a PowerSupply object from the raw JSON. func (powersupply *PowerSupply) UnmarshalJSON(b []byte) error { type ps PowerSupply + type actions struct { + Reset common.ActionTarget `json:"#PowerSupply.Reset"` + } var t struct { ps Assembly common.Link `json:"Assembly"` Metrics common.Link `json:"Metrics"` Redundancy common.Links `json:"Redundancy"` RelatedItem common.Links `json:"RelatedItem"` + Actions actions } err := json.Unmarshal(b, &t) @@ -407,6 +414,7 @@ func (powersupply *PowerSupply) UnmarshalJSON(b []byte) error { powersupply.redundancyLinks = t.Redundancy.ToStrings() powersupply.relateditemLinks = t.RelatedItem.ToStrings() powersupply.rawData = b + powersupply.resetTarget = t.Actions.Reset.Target return nil } @@ -422,6 +430,21 @@ func ListReferencedPowerSupplies(c common.Client, link string) ([]*PowerSupply, return common.GetCollectionObjects[PowerSupply](c, link) } +// Reset is an action that resets a power supply. A GracefulRestart ResetType +// shall reset the power supply but shall not affect the power output. A +// ForceRestart ResetType can affect the power supply output. +func (powersupply *PowerSupply) Reset(resetType ResetType) error { + if powersupply.resetTarget == "" { + return errors.New("reset is not supported") //nolint:golint + } + + t := struct { + ResetType ResetType + }{ResetType: resetType} + + return powersupply.Post(powersupply.resetTarget, t) +} + // Update commits updates to this object's properties to the running system. func (powersupply *PowerSupply) Update() error { readWriteFields := []string{"IndicatorLED"} diff --git a/redfish/powersubsystem.go b/redfish/powersubsystem.go index 333b42f3..879aa21d 100644 --- a/redfish/powersubsystem.go +++ b/redfish/powersubsystem.go @@ -46,6 +46,8 @@ type PowerSubsystem struct { PowerSupplyRedundancy []RedundantGroup // Status shall contain any status or health properties of the resource. Status common.Status + // RawData holds the original serialized JSON. + RawData []byte } // UnmarshalJSON unmarshals a PowerSubsystem object from the raw JSON. @@ -83,6 +85,8 @@ func (powersubsystem *PowerSubsystem) UnmarshalJSON(b []byte) error { powersubsystem.batteries = t.Batteries.String() powersubsystem.powerSupplies = t.PowerSupplies.String() + powersubsystem.RawData = b + return nil }