diff --git a/redfish/computersystem.go b/redfish/computersystem.go index c6b49d32..f4d7ac0a 100644 --- a/redfish/computersystem.go +++ b/redfish/computersystem.go @@ -830,7 +830,7 @@ type ComputerSystem struct { OEM json.RawMessage `json:"Oem"` // OperatingSystem shall contain a link to a resource of type OperatingSystem that contains operating system // information for this system. - OperatingSystem string + operatingSystem string // PCIeDevices shall be an array of references of type PCIeDevice. pcieDevices []string // PCIeDevicesCount is the number of PCIeDevices. @@ -960,6 +960,7 @@ func (computersystem *ComputerSystem) UnmarshalJSON(b []byte) error { Processors common.Link Redundancy common.Link Memory common.Link + OperatingSystem common.Link SimpleStorage common.Link SecureBoot common.Link Storage common.Link @@ -994,6 +995,7 @@ func (computersystem *ComputerSystem) UnmarshalJSON(b []byte) error { computersystem.memory = t.Memory.String() computersystem.memoryDomains = t.MemoryDomains.String() computersystem.networkInterfaces = t.NetworkInterfaces.String() + computersystem.operatingSystem = t.OperatingSystem.String() computersystem.redundancy = t.Redundancy.String() computersystem.secureBoot = t.SecureBoot.String() computersystem.simpleStorage = t.SimpleStorage.String() @@ -1114,6 +1116,11 @@ func (computersystem *ComputerSystem) NetworkInterfaces() ([]*NetworkInterface, return ListReferencedNetworkInterfaces(computersystem.GetClient(), computersystem.networkInterfaces) } +// OperatingSystem gets this system's operating system. +func (computersystem *ComputerSystem) OperatingSystem() (*OperatingSystem, error) { + return GetOperatingSystem(computersystem.GetClient(), computersystem.operatingSystem) +} + // PCIeDevices gets all PCIeDevices for this system. func (computersystem *ComputerSystem) PCIeDevices() ([]*PCIeDevice, error) { return common.GetObjects[PCIeDevice](computersystem.GetClient(), computersystem.pcieDevices) diff --git a/redfish/computersystem_test.go b/redfish/computersystem_test.go index c7372796..7ed034a8 100644 --- a/redfish/computersystem_test.go +++ b/redfish/computersystem_test.go @@ -125,6 +125,9 @@ var computerSystemBody = `{ "Storage": { "@odata.id": "/redfish/v1/Systems/1/Storage" }, + "OperatingSystem": { + "@odata.id": "/redfish/v1/Systems/1/OperatingSystem" + }, "LogServices": { "@odata.id": "/redfish/v1/Systems/1/LogServices" }, @@ -310,6 +313,10 @@ func TestComputerSystem(t *testing.T) { //nolint if result.managedBy[0] != "/redfish/v1/Managers/BMC-1" { t.Errorf("Received invalid Managers reference: %s", result.managedBy[0]) } + + if result.operatingSystem != "/redfish/v1/Systems/1/OperatingSystem" { + t.Errorf("Received invalid OperatingSystem reference: %s", result.operatingSystem) + } } // TestComputerSystemUpdate tests the Update call.