diff --git a/redfish/chassis.go b/redfish/chassis.go index ae3a8336..1a126e93 100644 --- a/redfish/chassis.go +++ b/redfish/chassis.go @@ -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 @@ -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 } @@ -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 @@ -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) +} diff --git a/redfish/coolantconnector.go b/redfish/coolantconnector.go index 836861de..cbe16e80 100644 --- a/redfish/coolantconnector.go +++ b/redfish/coolantconnector.go @@ -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'. @@ -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 @@ -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 @@ -154,7 +169,12 @@ func (coolantconnector *CoolantConnector) Update() error { readWriteFields := []string{ "CoolingLoopName", "CoolingManagerURI", + "DeltaPressureControlkPa", + "DeltaTemperatureControlCelsius", + "FlowControlLitersPerMinute", "LocationIndicatorActive", + "ReturnTemperatureControlCelsius", + "SupplyTemperatureControlCelsius", } originalElement := reflect.ValueOf(original).Elem() diff --git a/redfish/coolingunit.go b/redfish/coolingunit.go index 7a57d598..19f770a6 100644 --- a/redfish/coolingunit.go +++ b/redfish/coolingunit.go @@ -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 @@ -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 @@ -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 @@ -124,8 +135,16 @@ func (coolingunit *CoolingUnit) UnmarshalJSON(b []byte) error { // ManagedBy@odata.count ManagedByCount int `json:"ManagedBy@odata.count"` } + type CoolingUnitActions struct { + SetMode struct { + AllowedCoolingUnitModes []CoolingUnitMode `json:"Mode@Redfish.AllowableValues"` + Target string + } `json:"#CoolingUnit.SetMode"` + } + var t struct { temp + Actions CoolingUnitActions Assembly common.Link CoolantConnectorRedundancy common.Links EnvironmentMetrics common.Link @@ -160,6 +179,8 @@ 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 @@ -167,6 +188,15 @@ func (coolingunit *CoolingUnit) UnmarshalJSON(b []byte) error { 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 diff --git a/redfish/leakdetector.go b/redfish/leakdetector.go index dfb08fb9..698e3870 100644 --- a/redfish/leakdetector.go +++ b/redfish/leakdetector.go @@ -6,6 +6,7 @@ package redfish import ( "encoding/json" + "reflect" "github.com/stmcginnis/gofish/common" ) @@ -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. @@ -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. @@ -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) +} diff --git a/redfish/pump.go b/redfish/pump.go index 0a6533e7..1e275c60 100644 --- a/redfish/pump.go +++ b/redfish/pump.go @@ -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 @@ -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 @@ -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 } @@ -104,6 +123,7 @@ 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 @@ -111,6 +131,16 @@ func (pump *Pump) UnmarshalJSON(b []byte) error { 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 == "" { @@ -135,6 +165,7 @@ func (pump *Pump) Update() error { "AssetTag", "LocationIndicatorActive", "ServiceHours", + "SpeedControlPercent", "UserLabel", }