Skip to content

Commit

Permalink
Add some DMTF 2024.4 release bits (#393)
Browse files Browse the repository at this point in the history
* Add Pump controls

* Add Enabled to LeakDetector

* Add SetMode to CoolingUnit

* Add CoolantConnector controls

* Add LeakDetectors to Chassis
  • Loading branch information
iamsli authored Jan 15, 2025
1 parent 78d6918 commit fecdc11
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
13 changes: 13 additions & 0 deletions redfish/chassis.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ type Chassis struct {
// for the indicator light associated with this system.
// Deprecated v1.14+ in favor of LocationIndicatorActive property
IndicatorLED common.IndicatorLED
// leakdetectors shall contain a link to a the LeakDetectors in this chassis
leakdetectors string
// Location shall contain location information of the
// associated chassis.
Location common.Location
Expand Down Expand Up @@ -490,6 +492,7 @@ func (chassis *Chassis) UnmarshalJSON(b []byte) error {
Thermal common.Link
ThermalSubsystem common.Link
TrustedComponents common.Link
LeakDetectors common.Link
Links chassisLinks
Actions chassisActions
}
Expand Down Expand Up @@ -555,6 +558,7 @@ func (chassis *Chassis) UnmarshalJSON(b []byte) error {
chassis.StorageCount = t.Links.StorageCount
chassis.switches = t.Links.Switches.ToStrings()
chassis.SwitchesCount = t.Links.SwitchesCount
chassis.leakdetectors = t.LeakDetectors.String()
chassis.linkedDrives = t.Links.Drives.ToStrings()
if chassis.DrivesCount == 0 && t.Links.DrivesCount > 0 {
chassis.DrivesCount = t.Links.DrivesCount
Expand Down Expand Up @@ -854,3 +858,12 @@ func (chassis *Chassis) Reset(resetType ResetType) error {
}{ResetType: resetType}
return chassis.Post(chassis.resetTarget, t)
}

// LeakDetectors gets the leak detectors for this chassis.
func (chassis *Chassis) LeakDetectors() (*LeakDetector, error) {
if chassis.leakdetectors == "" {
return nil, nil
}

return GetLeakDetector(chassis.GetClient(), chassis.leakdetectors)
}
20 changes: 20 additions & 0 deletions redfish/coolantconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,26 @@ type CoolantConnector struct {
// present, shall reference a resource of type Sensor with the ReadingType property containing the value
// 'PressurekPa'.
DeltaPressurekPa SensorExcerpt
// DeltaPressureControlkPa contain the control for the desired pressure difference, in kilopascal units, for this
// coolant connector. This control shall only be present for the secondary coolant connector.
DeltaPressureControlkPa ControlSingleExcerpt
// DeltaTemperatureCelsius shall contain the change in temperature, in degree Celsius units, between the supply
// connection and the outflow or return connection to the cooling loop. The value of the DataSourceUri property, if
// present, shall reference a resource of type Sensor with the ReadingType property containing the value
// 'Temperature'.
DeltaTemperatureCelsius SensorExcerpt
// DeltaTemperatureControlCelsius contain the control for the desired temperature difference, in degree Celsius
// for this coolant connector. This control shall only be present for the secondary coolant connector.
DeltaTemperatureControlCelsius ControlSingleExcerpt
// Description provides a description of this resource.
Description string
// FlowLitersPerMinute shall contain the liquid flow rate, in liters per minute units, for this coolant connector.
// The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with the
// ReadingType property containing the value 'LiquidFlowLPM'.
FlowLitersPerMinute SensorExcerpt
// FlowControlLiterPerMinute shall contain the control for the liquid flow rate, in liters per minute units,
// for this coolant connector. This control shall only be present for the secondary coolant connector.
FlowControlLitersPerMinute ControlSingleExcerpt
// HeatRemovedkW shall contain the amount of heat removed, in kilowatt units, by the coolant flow through this
// connector. The value of the DataSourceUri property, if present, shall reference a resource of type Sensor with
// the ReadingType property containing the value 'Heat'.
Expand All @@ -85,6 +94,9 @@ type CoolantConnector struct {
// connection to the cooling loop. The value of the DataSourceUri property, if present, shall reference a resource
// of type Sensor with the ReadingType property containing the value 'Temperature'.
ReturnTemperatureCelsius SensorExcerpt
// ReturnTemperatureControlCelsius contain the control for the desired return temperature, in degree Celsius units
// for this coolant connector. This control shall only be present for the secondary coolant connector.
ReturnTemperatureControlCelsius ControlSingleExcerpt
// Status shall contain any status or health properties of the resource.
Status common.Status
// SupplyPressurekPa shall contain the pressure, in kilopascal units, for the intake or supply connection to the
Expand All @@ -95,6 +107,9 @@ type CoolantConnector struct {
// connection to the cooling loop. The value of the DataSourceUri property, if present, shall reference a resource
// of type Sensor with the ReadingType property containing the value 'Temperature'.
SupplyTemperatureCelsius SensorExcerpt
// SupplyTemperatureControlCelsius contain the control for the desired supply temperature, in degree Celsius units
// of this coolant connector. This control shall only be present for the secondary coolant connector.
SupplyTemperatureControlCelsius ControlSingleExcerpt
// rawData holds the original serialized JSON so we can compare updates.
rawData []byte
connectedChassis []string
Expand Down Expand Up @@ -154,7 +169,12 @@ func (coolantconnector *CoolantConnector) Update() error {
readWriteFields := []string{
"CoolingLoopName",
"CoolingManagerURI",
"DeltaPressureControlkPa",
"DeltaTemperatureControlCelsius",
"FlowControlLitersPerMinute",
"LocationIndicatorActive",
"ReturnTemperatureControlCelsius",
"SupplyTemperatureControlCelsius",
}

originalElement := reflect.ValueOf(original).Elem()
Expand Down
30 changes: 30 additions & 0 deletions redfish/coolingunit.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type CoolingUnit struct {
ODataEtag string `json:"@odata.etag"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// AllowedCoolingUnitModes shall contain the allowed values for setting the mode of this cooling unit.
AllowedCoolingUnitModes []CoolingUnitMode
// Assembly shall contain a link to a resource of type Assembly.
assembly string
// AssetTag shall contain the user-assigned asset tag, which is an identifying string that tracks the equipment for
Expand Down Expand Up @@ -88,6 +90,8 @@ type CoolingUnit struct {
secondaryCoolantConnectors string
// SerialNumber shall contain a manufacturer-allocated number that identifies the equipment.
SerialNumber string
// setMode shall contain the action target for setting the mode of this cooling unit.
setMode string
// Status shall contain any status or health properties of the resource.
Status common.Status
// UserLabel shall contain a user-assigned label used to identify this resource. If a value has not been assigned
Expand All @@ -106,6 +110,13 @@ type CoolingUnit struct {
ManagedByCount int
}

type CoolingUnitMode string

const (
EnabledCoolingUnitMode CoolingUnitMode = "Enabled"
DisabledCoolingUnitMode CoolingUnitMode = "Disabled"
)

// UnmarshalJSON unmarshals a CoolingUnit object from the raw JSON.
func (coolingunit *CoolingUnit) UnmarshalJSON(b []byte) error {
type temp CoolingUnit
Expand All @@ -124,8 +135,16 @@ func (coolingunit *CoolingUnit) UnmarshalJSON(b []byte) error {
// [email protected]
ManagedByCount int `json:"[email protected]"`
}
type CoolingUnitActions struct {
SetMode struct {
AllowedCoolingUnitModes []CoolingUnitMode `json:"[email protected]"`
Target string
} `json:"#CoolingUnit.SetMode"`
}

var t struct {
temp
Actions CoolingUnitActions
Assembly common.Link
CoolantConnectorRedundancy common.Links
EnvironmentMetrics common.Link
Expand Down Expand Up @@ -160,13 +179,24 @@ func (coolingunit *CoolingUnit) UnmarshalJSON(b []byte) error {
coolingunit.facility = t.Links.Facility.String()
coolingunit.managedBy = t.Links.ManagedBy.ToStrings()
coolingunit.ManagedByCount = t.Links.ManagedByCount
coolingunit.AllowedCoolingUnitModes = t.Actions.SetMode.AllowedCoolingUnitModes
coolingunit.setMode = t.Actions.SetMode.Target

// This is a read/write object, so we need to save the raw object data for later
coolingunit.rawData = b

return nil
}

func (coolingunit *CoolingUnit) SetMode(mode CoolingUnitMode) error {
// TODO: check if mode is in Allowable values
properties := map[string]interface{}{
"Mode": mode,
}

return coolingunit.Post(coolingunit.setMode, properties)
}

// Update commits updates to this object's properties to the running system.
func (coolingunit *CoolingUnit) Update() error {
// Get a representation of the object's original state so we can find what
Expand Down
21 changes: 21 additions & 0 deletions redfish/leakdetector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package redfish

import (
"encoding/json"
"reflect"

"github.com/stmcginnis/gofish/common"
)
Expand All @@ -32,6 +33,8 @@ type LeakDetector struct {
Description string
// DetectorState shall contain the state of the leak detector.
DetectorState common.Health
// Enabled shall indicate whether the leak detector is enabled.
Enabled bool
// LeakDetectorType shall contain the reading type of the leak detection sensor.
LeakDetectorType LeakDetectorType
// Location shall indicate the location information for this leak detector.
Expand Down Expand Up @@ -64,6 +67,8 @@ type LeakDetector struct {
SparePartNumber string
// Status shall contain any status or health properties of the resource.
Status common.Status
// RawData holds the original serialized JSON so we can compare updates
RawData []byte
}

// GetLeakDetector will get a LeakDetector instance from the service.
Expand Down Expand Up @@ -102,3 +107,19 @@ type LeakDetectorExcerpt struct {
// DetectorState shall contain the state of the leak detector.
DetectorState common.Health
}

func (leakdetector *LeakDetector) Update() error {
ld := new(LeakDetector)
err := ld.OEM.UnmarshalJSON(leakdetector.RawData)
if err != nil {
return err
}

readWriteFields := []string{
"Enabled",
}

originalElement := reflect.ValueOf(ld).Elem()
currentElement := reflect.ValueOf(leakdetector).Elem()
return leakdetector.Entity.Update(originalElement, currentElement, readWriteFields)
}
31 changes: 31 additions & 0 deletions redfish/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Pump struct {
// FirmwareVersion shall contain a string describing the firmware version of this equipment as provided by the
// manufacturer.
FirmwareVersion string
// InletPressurekPa shall contain the current pressure in kilopascals entering the pump
InletPressurekPa SensorPumpExcerpt
// Location shall contain the location information of this pump.
Location common.Location
// LocationIndicatorActive shall contain the state of the indicator used to physically identify or locate this
Expand Down Expand Up @@ -72,8 +74,12 @@ type Pump struct {
SerialNumber string
// ServiceHours shall contain the number of hours of service that the pump has been in operation.
ServiceHours float64
// setMode shall contain the action target for setting the mode of this pump.
setMode string
// SparePartNumber shall contain the spare or replacement part number as defined by the manufacturer for this pump.
SparePartNumber string
// SpeedControlPercent shall contain the desired speed, in percent units, of this pump.
SpeedControlPercent ControlSingleExcerpt
// Status shall contain any status or health properties of the resource.
Status common.Status
// UserLabel shall contain a user-assigned label used to identify this resource. If a value has not been assigned
Expand All @@ -85,11 +91,24 @@ type Pump struct {
rawData []byte
}

type PumpMode string

const (
EnabledPumpMode PumpMode = "Enabled"
DisabledPumpMode PumpMode = "Disabled"
)

// UnmarshalJSON unmarshals a Pump object from the raw JSON.
func (pump *Pump) UnmarshalJSON(b []byte) error {
type temp Pump

type PumpActions struct {
SetMode common.ActionTarget `json:"#Pump.SetMode"`
}

var t struct {
temp
Actions PumpActions
Assembly common.Link
Filters common.LinksCollection
}
Expand All @@ -104,13 +123,24 @@ func (pump *Pump) UnmarshalJSON(b []byte) error {
// Extract the links to other entities for later
pump.assembly = t.Assembly.String()
pump.filters = t.Filters.ToStrings()
pump.setMode = t.Actions.SetMode.Target

// This is a read/write object, so we need to save the raw object data for later
pump.rawData = b

return nil
}

// SetMode sets the mode of the pump.
func (pump *Pump) SetMode(mode PumpMode) error {
// TODO check if mode is valid
properties := map[string]interface{}{
"Mode": mode,
}

return pump.Post(pump.setMode, properties)
}

// Assembly gets the containing assembly for this pump.
func (pump *Pump) Assembly() (*Assembly, error) {
if pump.assembly == "" {
Expand All @@ -135,6 +165,7 @@ func (pump *Pump) Update() error {
"AssetTag",
"LocationIndicatorActive",
"ServiceHours",
"SpeedControlPercent",
"UserLabel",
}

Expand Down

0 comments on commit fecdc11

Please sign in to comment.