diff --git a/redfish/bios.go b/redfish/bios.go index a284e095..e25def3c 100644 --- a/redfish/bios.go +++ b/redfish/bios.go @@ -84,6 +84,9 @@ type Bios struct { // settingsApplyTimes is a set of allowed settings update apply times. If none // are specified, then the system does not provide that information. settingsApplyTimes []common.ApplyTime + // activeSoftwareImage is the @odata.id of SoftwareInventory responsible + // for the active BIOS firmware image (see Links.ActiveSoftwareImage.@odata.id). + activeSoftwareImage string // rawData holds the original serialized JSON so we can compare updates. rawData []byte } @@ -99,9 +102,15 @@ func (bios *Bios) UnmarshalJSON(b []byte) error { Target string } `json:"#Bios.ResetBios"` } + type Links struct { + ActiveSoftwareImage struct { + ODataID string `json:"@odata.id"` + } + } var t struct { temp Actions Actions + Links Links Settings common.Settings `json:"@Redfish.Settings"` } @@ -116,6 +125,7 @@ func (bios *Bios) UnmarshalJSON(b []byte) error { bios.changePasswordTarget = t.Actions.ChangePassword.Target bios.resetBiosTarget = t.Actions.ResetBios.Target bios.settingsApplyTimes = t.Settings.SupportedApplyTimes + bios.activeSoftwareImage = t.Links.ActiveSoftwareImage.ODataID // Some implementations use a @Redfish.Settings object to direct settings updates to a // different URL than the object being updated. Others don't, so handle both. @@ -257,3 +267,13 @@ func (bios *Bios) UpdateBiosAttributes(attrs BiosAttributes) error { return nil } + +// GetActiveSoftwareImage gets the SoftwareInventory which represents the +// active BIOS firmware image. +func (bios *Bios) GetActiveSoftwareImage() (*SoftwareInventory, error) { + if bios.activeSoftwareImage == "" { + return nil, nil + } + + return GetSoftwareInventory(bios.Client, bios.activeSoftwareImage) +} diff --git a/redfish/bios_test.go b/redfish/bios_test.go index c787ad7b..d90ad9e1 100644 --- a/redfish/bios_test.go +++ b/redfish/bios_test.go @@ -54,6 +54,11 @@ var biosBody = `{ "#Bios.ChangePassword": { "target": "/redfish/v1/Systems/437XR1138R2/BIOS/Actions/Bios.ChangePassword" } + }, + "Links": { + "ActiveSoftwareImage": { + "@odata.id": "/redfish/v1/Systems/437XR1138R2/BIOS/FirmwareInventory" + } } }` @@ -146,6 +151,10 @@ func TestBios(t *testing.T) { if len(result.settingsApplyTimes) != 3 { t.Errorf("Invalid settings support apply times: %s", result.settingsApplyTimes) } + + if result.activeSoftwareImage != "/redfish/v1/Systems/437XR1138R2/BIOS/FirmwareInventory" { + t.Errorf("Invalid value of activeSoftwareImage: '%s'", result.activeSoftwareImage) + } } // TestBiosAttributes tests the parsing of Bios objects @Redfish.Attributes.